[OS X TeX] A problem with catcodes

Alessio Guglielmi lists at alessio.guglielmi.name
Thu Apr 12 14:29:38 CEST 2007


Hi,

I've been on this list for several years, and kept quiet, but I often 
found it very useful. Perhaps somebody can help me on a TeX problem.

I'm writing some macros for proof theoretical typing (see at 
<http://alessio.guglielmi.name/res/vl>) and I encountered a nasty 
problem that I'm not able to solve. The problem is not Mac specific, 
but I thought about trying this forum first, because it's the only 
one I know, I hope you don't mind. (I only work on Macs, five of 
them!)

The essence of the problem is illustrated by the LaTeX file below. 
Its actual output is a cross and a dot, while the intended output 
should be two crosses.

The macro \aaa redefines the `.' character as active, so that when 
one types `.', one gets a cross.

This generally works, but it doesn't when what follows \aaa is an 
argument in a macro call, for example, when used inside a \bbb call 
as below. The example shows the two different behaviours. I gather 
that the problem is due to the fact that when arguments are read, 
they are transformed into lists of tokens, so that the \catcode 
commands in \aaa lose their effect. I'm not entirely sure I 
understood this right.

My problem is to define \aaa in such a way that the dot is always 
typed as a cross, and without altering in any way \bbb and its use. I 
can change the way \aaa is used. For example, \aaa could be a macro 
accepting one argument. In other words, a different definition of 
\aaa, for example involving calling it as \aaa{.}, would be 
acceptable.

Any help is very much appreciated, not just by me, but also by a 
small (but growing) community of people using my macros.

Ciao,

-Alessio


%----------------------------------------------------
\documentclass{article}

{
\catcode`.=\active
\gdef\aaa {\catcode`.=\active\let.=\times}
}

\def\bbb #1{#1}

\begin{document}

$\aaa .$

\bbb{$\aaa .$}

\end{document}
%----------------------------------------------------

------------------------- Helpful Info -------------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
TeX FAQ: http://www.tex.ac.uk/faq
List Archive: http://tug.org/pipermail/macostex-archives/
List Reminders & Etiquette: http://www.esm.psu.edu/mac-tex/list/





More information about the macostex-archives mailing list