[texhax] Upright digits in theorems

Uwe Lück uwe.lueck at web.de
Thu Jun 8 23:35:44 CEST 2006

Sorry, contrary to my conviction my previously outgoing posting
didn't contain the attachment. (Oh, so often facts -- including
those that I have produced -- are contrary to my convictions.)
-- Uwe.

[And by mere accidence this has not been the second posting
lacking the attachment.]

At 23:32 06.06.06, Uwe Lück wrote:
>At 16:11 06.06.06, Alex Scorpan wrote:
> >What is the most elegant and robust way to arrange that digits and
> >such always display upright inside a theorem-like environment, when
> >the surrounding text is italic?  This is for a rather large-scale
> >application.
>you can indeed replace 0 by \textup{0} etc. by TeX macros.

Attached is a demo .tex containing macros for these replacements.
A macro \UprightDigitsInEnv modifies an environment for them
after the environment has been defined.

This was more difficult than I expected. My first "multi-tasking"
package -- in a way. First, each of ten replacement processes
does its first move. During typesetting the environment, at
every digit the corresponding process does its next move.

This version doesn't "right" a digit within curly braces.
Some refinement could do this. And I would not bet that
I could find a refinement that also "rights" digits that appear
only after expansion. (The item labels in the demo exemplify
this.) Here your active characters approach would be superior
wrt this. Maybe for the latter approach it suffices to modify
\label and \ref such that the active digits just expand to their
"other" versions. I still think that the font approach is most
clean (see below for recalling).


>A /third/ approach: let \itshape etc. expand such that
>not standard italic/slanted fonts are used, rather your
>own variants where only letters are slanted (italic), not
>the digits. In this case I really rather guess, I only have
>a rough idea of METAFONT, I sometimes read .mf files,
>I would not be able to make .mf files that would be
>needed for this approach. -- Probably the most reliable
>approach -- e.g., the above second approach would have
>difficulties (hence at least not very elegant) with digits
>that only appear after expansion of some macros used
>by the author. -- I guess the most elegant solution for
>this third approach are the so-called "virtual fonts"
>-- someone else should advise on this.
-------------- next part --------------
% UprDigs.tex -- upright digits in theorem environments 
% Uwe Lueck 2006/06/08 to texhax for Alex Scorpan. 

% \usepackage{trace}

% General macros: 
% Modifying some theorem environment #1, 
% adding \uprightdigits on the left: 
      \expandafter\expandafter\expandafter {% 
        \expandafter\expandafter\expandafter \upright at digits 
% What the added macro does: 
\def\upright at digits{% 
  \let\env at considered\@currenvir
  \let\envcontent\start at envcontent
  \gather at envcontent}
\def\start at envcontent{% 
\long\def\gather at envcontent#1\end#2{% 
  \add at envcontent{#1}\def\env at found{#2}% 
  \ifx\env at found\env at considered
    \add at envcontent{\end{#2}}% 
    \expandafter\gather at envcontent
\long\def\add at envcontent#1{% 
  \envcontent 0\@nil1\@nil2\@nil3\@nil4\@nil
  \expandafter\end\expandafter{\env at considered}}
    \def\passed at by{##1}% 
      \expandafter \passed at by
      \def\return at modified{% 
        \passed at by\textup{#1}\replace#1##2\@nil}%
      \expandafter\return at modified 

% Applying example: 

% \tracingmacros=1
Two claims: 
\item 7 by 6 equals 42. 
\item 9 by 6 equals 54. 

More information about the texhax mailing list