Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am using Computer Modern font (default) with \oldstylenums command to typeset numbers in oldstyle format. However I am having trouble using it with non-numeric characters such as decimal points and hyphens.

For e.g. decimal points appear as triangles:

Master of Science, Computer Science, \oldstylenums{3.76/4.0}

appears as:

enter image description here

Also, I have trouble with hyphens, etc.

Please suggest remedies.

share|improve this question
    
I have to point out that it's really easy to get oldstyle numbers with fontspec, meaning with XeTeX and LuaTeX and OpenType fonts (like lmodern). –  Martin Schröder Oct 8 '12 at 12:45
add comment

3 Answers

up vote 8 down vote accepted
\usepackage{textcomp}

redefines \oldstylenumsto use the 8-bit encoding TS1 instead of the 7-bit math encoding OML.

Extended support

The following example parses the string to replace the digits by the old style variants.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{lmodern}

\usepackage{textcomp}
\usepackage{ltxcmds}

\makeatletter
\newcommand*{\oldstyle}[1]{%
  \begingroup
  \toks@={}%
  \@oldstyle#1\scrollmode
}
\newcommand*{\@oldstyle}{%
  \ltx@ifnextchar@nospace\scrollmode{%
    \expandafter\endgroup\the\expandafter\toks@\@gobble
  }{%
  \ltx@ifnextchar@nospace\@sptoken{%
    \expandafter
    \@oldstyleadd\expandafter\space\expandafter\@empty
    \romannumeral-`\x
  }{%
  \ltx@ifnextchar@nospace0{\@oldstyleadd\textzerooldstyle}{%
  \ltx@ifnextchar@nospace1{\@oldstyleadd\textoneoldstyle}{%
  \ltx@ifnextchar@nospace2{\@oldstyleadd\texttwooldstyle}{%
  \ltx@ifnextchar@nospace3{\@oldstyleadd\textthreeoldstyle}{%
  \ltx@ifnextchar@nospace4{\@oldstyleadd\textfouroldstyle}{%
  \ltx@ifnextchar@nospace5{\@oldstyleadd\textfiveoldstyle}{%
  \ltx@ifnextchar@nospace6{\@oldstyleadd\textsixoldstyle}{%
  \ltx@ifnextchar@nospace7{\@oldstyleadd\textsevenoldstyle}{%
  \ltx@ifnextchar@nospace8{\@oldstyleadd\texteightoldstyle}{%
  \ltx@ifnextchar@nospace9{\@oldstyleadd\textnineoldstyle}{%
    \@@oldstyle
  }}}}}}}}}}}}%
}
\newcommand*{\@oldstyleadd}[2]{%
  \toks@\expandafter{\the\toks@#1}%
  \@oldstyle
}
  \newcommand*{\@@oldstyle}[1]{%
  \@oldstyleadd{#1}{}%
}
\makeatother

\begin{document}
Master of Science, Computer Science, \oldstyle{0-1--2---3; 7, 3.76/4.0}
\end{document}

Result

share|improve this answer
1  
Good things, when short, are twice as good :) –  Fran Oct 7 '12 at 2:29
    
@HeikoOberdiek: Thanks for the suggestion, it solves the decimal point problem, but hyphen is now converted to = symbol. –  abhinavkulkarni Oct 7 '12 at 2:30
1  
@abhinavkulkarni, but on the contrary, = is converted to a long hyphen in this way. –  Fran Oct 7 '12 at 2:36
    
@Fran: Thanks. How can I get the short hyphen? –  abhinavkulkarni Oct 7 '12 at 2:37
1  
@abhinavkulkarni, I do not know with a single key, but please see the trick of \sout in my answer. It works also with textcomp. –  Fran Oct 7 '12 at 2:57
add comment

If you want old style figures throughout your document, you have a couple of choices assuming you still want to use the Computer Modern fonts or variations thereof.

Package eco

\usepackage[T1]{fontenc}
\usepackage{eco}

Package cfr-lm

\usepackage[T1]{fontenc}
\usepackage[oldstyle=true]{cfr-lm}

The second package uses the Latin Modern fonts, which are very similar to Computer Modern; the first one uses a set of virtual fonts based on European Modern, again a variation of Computer Modern. I'd favor the latter.

share|improve this answer
add comment

I suppose that the best practice would be to leave out characters other than digits.

However, I could be a little messy, but you can obtain decimal points (mid point or down point), hyphens and fractions inside \oldstylenums in this way:

\usepackage{ulem} % needed for \sout{}
 ...
\oldstylenums{3·76=4·0 \sout{~} 3:76=4:0}

Another less tangled solution could be to define a newcommand for use \oldstylenums of another font that allow the use of normal characters inside the command:

\newcommand{\oldnum}[1]{{\fontfamily{artemisia}\scshape #1}}

\oldnum{3·76/4·0 - 3.76/4.0}

Note that in this case in there are text inside \oldnum, it appear as small caps instead of italics.

MWE

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.