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

In a package, I have the following command defined:

        \raisebox{0.2ex}{\rotatebox{-15} {k}}\!

It works just as I'd expect in text, but if I say \section{\fkm} I get an error saying

! TeX capacity exceeded, sorry [input stack size=5000].

Why doesn't this work within sections? What can I do to make it work?

share|improve this question
Also, it doesn't seem to matter if I use the command (\section{\fkm}) or the code directly (\section{$\mathrm{...}$}) - I still get the error... – Tomas Lycken Oct 30 '10 at 19:50
up vote 10 down vote accepted

The argument of \section could be used for the table of contents. In that process, commands within this argument may be expanded and written to the toc file for later use. To prevent expansion, you could use the \protect command:


Or, use \DeclareRobustCommand to define the command such that it's working in such moving arguments. You might also consider to use the optional argument of \section for the toc entry. See: Fragile and Robust commands.

Other commands with such moving arguments are \chapter, \subsection etc. and \caption.

share|improve this answer

This is not the error that I get when I try it. However, the solution is to use \DeclareRobustCommand instead of \newcommand.

share|improve this answer
\DeclareRobustCommand works brilliantly - but out of curiosity, what error do you get? – Tomas Lycken Oct 30 '10 at 22:57

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.