How to make this \switch command work similarly in both text and
headings and captions? Thank you. - Leo
--------------------------------
\documentclass{memoir}
\begingroup
\catcode`\x=\active
\gdefx{\unskip\,\ensuremath{\times}\,\ignorespaces}
\endgroup
\protected\def\switch{%
\begingroup%
\catcode`\x=\active%
\Xswitch%
}
\def\Xswitch#1{%
#1%
\endgroup%
}
\begin{document}
\chapter{\switch{2x2}}
\switch{2x2}
\end{document}
--------------------------------
--
Emacs uptime: 59 days, 6 hours, 43 minutes, 26 seconds
Remember:
- x will be capitalised
- You need to rescan your tokens to get things active
\documentclass{memoir}
\begingroup
\catcode`\x=\active
\catcode`\X=\active
\gdef x{\unskip\,\ensuremath{\times}\,\ignorespaces}
\gdef X{\unskip\,\ensuremath{\times}\,\ignorespaces}
\endgroup
\protected\def\switch#1{%
\begingroup
\catcode`\x=\active
\catcode`\X=\active
\scantokens{#1}%
\endgroup
}
\begin{document}
\chapter{\switch{2x2}}
\switch{2x2}
\end{document}
--
Joseph Wright
Thanks a lot. - Leo