[texhax] \emph in \edef

Wolfgang Lorenz wl-chmw at gmx.de
Sat Apr 9 22:01:49 CEST 2011

Hello Heiko,

Am Sat, 9 Apr 2011 00:54:07 +0200
schrieb Heiko Oberdiek <heiko.oberdiek at googlemail.com>:

> On Fri, Apr 08, 2011 at 11:48:35PM +0200, Wolfgang Lorenz wrote:
> > %%% edeftest.tex %%%
> > \documentclass{book}
> > \begin{document}
> > 	\edef\e{\emph{text}}
> > \end{document}
> > %%% EOF %%%
> > 
> > This short document gives an error message at line 3:
> > > l.3     \edef\e{\emph{text}
> Use \protected at edef\e{\emph{test}}, then LaTeX's
> protecting mechanisms (\DeclareRobustCommand, \protect, ...)
> have a chance.

Thank you, very much! This did the trick. And after knowing this, I
found the FAQ page, which explains why:

> Perhaps there is a better solution, but I don't know the
> purpose of this exercise.

I'm writing a package, that provides an environment for lyrics placing.
In the environment the stanzas are read one by one and saved as macros.
Originally I wanted to put them in boxes, but as the number of usable
boxes is limited and I don't know how many stanzas will be needed, this
wasn't a good idea after all.

So, only after all stanzas are read and the environment is closed via
\end, the package tries to fit the stanzas on the pages, but of course
until then they need to be stored somewhere. I think, I've come about
the "macro store" somewhere in "TeX in Practice". I don't know if there
is a better solution for this thing, but the current one is working
great. ...now...

> Yours sincerely
>   Heiko Oberdiek

Thanks again,
  Wolfgang Lorenz

More information about the texhax mailing list