Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to make this command work in headings and captions

4 views
Skip to first unread message

Leo

unread,
Nov 20, 2009, 10:32:50 AM11/20/09
to
Hi there,

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

Joseph Wright

unread,
Nov 20, 2009, 12:02:38 PM11/20/09
to

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

Leo

unread,
Nov 20, 2009, 12:44:29 PM11/20/09
to
On 2009-11-20 17:02 +0000, Joseph Wright wrote:
> 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}

Thanks a lot. - Leo

0 new messages