TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am getting an error while trying to compile this minimal example:




\def\aaa{test }
\expandafter\def\csname bbb\endcsname{$4\sqrt{2}$}
\edef\aaa{\aaa \bbb}







Running latex over mintest.tex produces this error:

ERROR: Use of \@sqrt doesn't match its definition.

--- TeX said ---
\@ifnextchar ...eserved@d =#1\def \reserved@a {#2}
                                                  \def \reserved@b {#3}\futu...
l.7 \end{myenv}

Peculiar. I want to expand the definition of \aaa by concatenation. Any thoughts?

share|improve this question
LaTeX doesn't like that commands with optional arguments are passed through an \edef. It's difficult to say more from your example, but \protected@edef\aaa{\aaa\bbb} should work. – egreg Oct 29 '12 at 10:07
@egreg WOW, thanks, it worked. Can you post as an answer so I can mark it? – hos Oct 29 '12 at 10:09
up vote 6 down vote accepted

TeX doesn't like to find commands with optional arguments or defined with \DeclareRobustCommand inside an \edef; \sqrt fall in the first type, \bfseries in the second one.

In your case


will work.

Be careful, though: fragile commands such as \linebreak can't go in \protected@edef directly and must be preceded by \protect. Some knowledge of how dubious commands are defined is necessary.

See also Minimal \protected@edef example and Problem with nested \noexpand and \edef

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.