[texhax] A sign-change puzzle

pierre.mackay pierre.mackay at comcast.net
Sun Dec 10 22:36:49 CET 2006


Your answer inspired me to dig really deep, and ultimately to discover 
what I did wrong. 

After some fretting, I have come up with this. which does the right 
thing by letters, numbers and punctuation marks.
(They want them letterspaced too.)  Then I made sure that I could also 
include control sequences. 

Thank you for giving me the push to get it right at last.

\newdimen \letterspacing
\newdimen \lspkern

\def\[#1]{\lsp#1\empty\psl}%
\def\lsp#1#2\psl{%
\ifx#1\empty
\else
  \ifcat\noexpand#1a#1\kern\letterspacing
  \else
     \ifx#1~\kern\lspkern
     \else
       \ifcat#10#1\kern\letterspacing
       \else\kern-\letterspacing#1 % When a character is immediately
                                   % followed by control sequence, cancel
                                   % the previous letterspace
       \fi
     \fi
  \fi
\lsp#2\psl
\fi}

\def\kr{\kern1pc}
\letterspacing=.15em
\lspkern=.5em
\[THIS~IS~LETTER\kr SPACED~\qquad~~A12345;;;]

\leavevmode\hskip 8.45pc\vrule height 1pc width 1pc % To measure the 
space left by \kr

Again many thanks

Pierre MacKay








More information about the texhax mailing list