In beamer, I would like to be able to use the tilde character ~ in the name of a command sequence. I tried with adjusting catcodes. While this was successful with the standard article class, it failed with beamer:
Working article example:
\documentclass{article}
\begin{document}
\section{cs with tilde}
\catcode`\~=12%
\expandafter\def\csname cswith~\endcsname{foo}
cs value:\csname cswith~\endcsname.
\catcode`\~=13%
\end{document}
Beamer example producing Missing \endcsname inserted error:
\documentclass{beamer}
\begin{document}
\begin{frame}{cs with tilde}
\catcode`\~=12%
\expandafter\def\csname cswith~\endcsname{foo}
cs value:\csname cswith~\endcsname.
\catcode`\~=13%
\end{frame}
\end{document}
What am I doing wrong?
\begingroup\catcode`\~=12 \expandafter … \endgroup, since this will restore the whatever catcode~had. – Andrey Vihrov Mar 21 '11 at 09:59frameenvironment is a pseudo-environment, i.e. actually a macro that reads everything until\end{frame}as an argument. – Hendrik Vogt Mar 21 '11 at 10:09\begin{frame}[fragile]– Ulrike Fischer Mar 21 '11 at 10:13Runaway argument? ! File ended while scanning use of \next. <inserted text> \parerror, with whatever frame content.fragileis not an option anyway, because I need the problem solved for package writing purposes. (Don't want the user to set thefragileoption.) – AlexG Mar 21 '11 at 10:25[fragile]works for your minimal example. – Martin Scharrer Mar 21 '11 at 10:32[fragile]works fine for me andbeamer 2010/06/21 development version 3.10(and it should work fine!). – Ulrike Fischer Mar 21 '11 at 10:36beamerframes, so you really should post it as an answer. – Martin Scharrer Mar 21 '11 at 10:42fragileis mentioned in your answer and this is quite enough at my opinion. – Ulrike Fischer Mar 21 '11 at 11:08