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 would like to have a command that combines \oldstylenums for numbers in the argument and \textsc for text in the argument. I believe that a solution using some for loop is possible, but I think there must be a simpler solution.

MWE:

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\pagestyle{empty}

\begin{document}

I get \oldstylenums{1s}

I want \oldstylenums{1}\textsc{s}

\end{document}

M(n)WE

share|improve this question

2 Answers 2

up vote 5 down vote accepted

well of course what you really want in that case is a font with small caps and old style numerals. As a real or virtual font, then You would just access the font and TeX wouldn't have to do anything. But virtual fonts are not really so popular these days, do perhaps a TeX loop:

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\pagestyle{empty}

\begin{document}

I get \oldstylenums{1s}

I want \oldstylenums{1}\textsc{s}

\makeatletter
\def\zzz#1{%
\@tfor\tmp:=#1\do{%
\ifcat1\tmp\relax\oldstylenums\tmp\else\textsc\tmp\fi}}
\makeatother

\zzz{1s}

\end{document}
share|improve this answer
    
The cfr-lm package provides a complete set of virtual fonts for Latin Modern that supports oldstyle digits, among other things. –  egreg Nov 7 '12 at 10:30
    
Ohh you should give that as an answer then as it's a better answer. –  David Carlisle Nov 7 '12 at 10:34
    
I prefer this one. I really only need it for short pieces of text. –  tohecz Nov 7 '12 at 10:45

The cfr-lm provides support for oldstyle figures in Latin Modern, among other things:

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[rm=oldstyle]{cfr-lm}
\pagestyle{empty}

\begin{document}

1234567890

\textsc{I want 1234567890}

\end{document}

enter image description here

share|improve this answer
    
Ok, but is it that this enables them everywhere? –  tohecz Nov 7 '12 at 10:43
1  
@tohecz Of course; why wouldn't you want it everywhere? You either always use oldstyle figures (except in formulas or, in general, for numbers in their mathematical sense) or never. –  egreg Nov 7 '12 at 10:45
1  
well I'll give you a +1 even if @tohecz prefers my answer:-) –  David Carlisle Nov 7 '12 at 10:55
    
@egreg And also not in tables, I think. (Or is that wrong?) –  henry Jul 3 at 9:14

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.