[texhax] Fwd: Re: Upright digits in theorems

Uwe Lück uwe.lueck at web.de
Tue Jun 20 00:31:36 CEST 2006


... all of a sudden, I've found a modification of my earlier
replaing package that stands eqnarray and align.
I hope I can transfer this sample file before my dream
fades away and I wake up.

Still there are problems I addressed before (cf. below)
wherefore I suppose this approach is not appropriate for
a professional/"large-scale" application.
Concerning optional number or glue arguments,
I would have an idea (default vs. individual modifications
of certain commands), but still again ...

I am forwarding a CTAN announcement on Perl
that may be helpful here (in case you know about Perl).

Wishing you that you won't have 20 TeX catastrophes
this day,

   Uwe.

[I'm trying to indicate why I usually wish `Lucky TeXing'
  instead of `Happy TeXing'.]

>Date: Mon, 12 Jun 2006 23:54:34 +0200
>From: Uwe Lück <uwe.lueck at web.de>
>
>At 00:04 09.06.06, Alex Scorpan wrote:
> >Your package seems to collide with {align}, screaming
> >         ! Argument of \@replace has an extra }.
>
>In fact this happens with Standard eqnarray already.
>And I guess there are many (essentially) other ways
>to get this error.
>
>The present version of "righting" is kind of "anarchistic"
>in allowing some typesetting before all numbers have
>been replaced. These errors can be avoided by doing
>all replacements before typesetting the environment.
>
>I must go to bed before I demonstrate this.
>Anyway, this "raw replacing" approach has a
>weakness which I consider even more serious:
>\\[1ex] will produce another error. Well, one could
>devise a routine that doesn't replace within brackets
>-- but (i) some authors may intend that brackets
>are typeset, e.g.: `X is 1-[2-]symmetric if ...'
>(sure?)
>(ii) digits in \item[...] *should* be "righted".
>
>So I am even more convinced than before that
>you better use special (virtual) fonts. My replacing
>macros rather are a toy or an exercise for
>baby TeX gurus.
-------------- next part --------------
% UprDigs.tex -- upright digits in theorem environments 
% Uwe Lueck 2006/06/19 to texhax for Alex Scorpan. 

\NeedsTeXFormat{LaTeX2e}[1994/12/01]
\documentclass[12pt]{article} 
% \usepackage{trace}
\nofiles 

\usepackage{amsmath}
% General macros: 
\makeatletter 
% Modifying some theorem environment #1, 
% adding \upright at digits on the left: 
\newcommand*{\UprightDigitsInEnv}[1]{% 
  \expandafter\def
    \csname#1\expandafter\expandafter\expandafter\endcsname
      \expandafter\expandafter\expandafter {% 
        \expandafter\expandafter\expandafter \upright at digits 
          \csname#1\endcsname}}
\@onlypreamble\UprightDigitsInEnv 
% What the added macro \uright at digits does: 
\def\upright at digits{% 
  \let\env at considered\@currenvir
  \let\env at content\start at env@content
  \gather at env@content}
\def\start at env@content{% 
  \@replace0\@replace1\@replace2\@replace3\@replace4
  \@replace5\@replace6\@replace7\@replace8\@replace9}
\long\def\gather at env@content#1\end#2{% 
  \add at env@content{#1}\def\env at found{#2}% 
  \ifx\env at found\env at considered
    \expandafter\@replacing 
  \else 
    \add at env@content{\end{#2}}% 
    \expandafter\gather at env@content
  \fi}
\long\def\add at env@content#1{% 
  \expandafter\def\expandafter\env at content\expandafter{% 
    \env at content#1}}
\def\@replacing{% 
  \env at content 
  0\@nil1\@nil2\@nil3\@nil4\@nil5\@nil6\@nil7\@nil8\@nil9\@nil 
  \expandafter\end\expandafter{\env at considered}}
\def\@replace#1{% 
  \let\env at content\@empty 
  \long\def\@repl at ce##1#1##2\@nil{% %     \def\passed at by{##1}% 
    \ifx\@nnil##2\@nnil 
      \add at env@content{##1}% 
%      \typeout{** \meaning\env at content\space **}% 
      \expandafter\env at content %       \expandafter \passed at by
    \else 
%       \def\return at modified{% 
%         \passed at by\textup{#1}\replace#1##2\@nil}%
%       \expandafter\return at modified 
      \add at env@content{##1\textup{#1}}% 
      \def\@tempe{\@repl at ce##2\@nil}% 
      \expandafter \@tempe 
%     \fi \typeout{** \string\env at content\space \meaning\env at content\space **}}% 
    \fi}% 
  \@repl at ce} 
%   \expandafter \do at replace \env at content #1\@nil} 
% \def\do at replace#1#2{\let\env at content\@empty \@repl at ce}
\makeatother 

% Applying example: 
\newtheorem{sthm}{Sample-Theorem}
\UprightDigitsInEnv{sthm}

\begin{document}
% \tracingmacros=1 \tracingonline=1 
\begin{sthm}
\begin{eqnarray} %% Standard LaTeX 
x&=&7\\
y&=&8
\end{eqnarray}
\begin{align}      %% AMS LaTeX 
x&=7\\
y&=8
\end{align}
Two more claims: 
\begin{enumerate}
\item 7 by 6 equals 42. 
\item 9 by 6 equals 54. 
\end{enumerate}
\end{sthm}
% \tracingmacros=0
\end{document}



More information about the texhax mailing list