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 do use the \substack-command in text for creating a small (2,1)-Vector. Unfortunately it does not work in the title of a section.

Here a minimal example, which does not work:

\section{$\substack{ a\\b }$}

To my surprise it works, if I use \section* instead of \section. I am far from understanding enough about TeX to tell why this happens, but can anyone give me an advise how I can fix it?

PS: I also tried to substitute \substack by smallmatrix, which did work for the first two times I compiled the file. After the third compilation I got the same problems.

EDIT: The Problem was solved, using the \protect-command. But now I want to use the same sectiontitle for a beamer presentation, using the beamer-class. Also using the \protect-command I receive an error. How can I solve this?

share|improve this question
Welcome to TeX.SE. – Peter Grill Mar 3 '13 at 19:49
@PeterGrill (and @Greyfox) A \protect will help: What is the difference between Fragile and Robust commands? – Qrrbrbirlbel Mar 3 '13 at 19:52
@Qrrbrbirlbel: Oh yeah, really should try harder to not forget about \protection. :-) – Peter Grill Mar 3 '13 at 19:53
Amazing. It works. You are a wizard. :-) Thanks a lot. – Greyfox Mar 3 '13 at 20:13
@Greyfox -- your edit may not be noticed by many readers. it's better to enter a new question, pointing back to this one. – barbara beeton Apr 12 '13 at 20:45
up vote 7 down vote accepted

\substack is what is known as a fragile command in LaTex and needs protecting in situations like section titles and captions that get written to external files for producing tables of contents etc. See What is the difference between Fragile and Robust commands? for some more information on fragile commands.

Sample output




\section{$\protect\substack{ a\\b }$}


If you have the hyperref package loaded then you will also need to provide a plain text version, via

\section{\texorpdfstring{$\protect\substack{ a\\b }$}{a/b}}

Finally, if using the beamer class there is an extra problem with \\ which beamer redefines. One work around in this case is to define a custom command to be used in the title:







Notice here that you can make the command robust from the start.

Beamer sample

share|improve this answer
Thx, for this Extension. Using the \textorpdfstring-command, I can now solve all my problems. – Greyfox Apr 14 '13 at 19:42

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.