# combine \oldstylenums and \textsc

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}


-

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}

-
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. – yo' 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}


-
Ok, but is it that this enables them everywhere? – yo' Nov 7 '12 at 10:43
@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
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 '14 at 9:14