# Why doesn't “\vphantom” work in section titles?

For reasons of my own (so please don't advise me to simply not do that, I considered that already) I want to have this expression in the title of a section

\section{$\left< a \vphantom{L} \right| \left. b\vphantom{L} \right>$}


but this gives me

! Incomplete \iffalse;


Any idea why that happens? And maybe a workaround?

-

The command \vphantom is fragile. You need to protect it:

\section{$\left< a \protect\vphantom{L} \right| \left. b\protect\vphantom{L} \right>$}


However, there's a better way to do it:

\documentclass{article}
\begin{document}

\section{$\left< a \protect\vphantom{L} \right| \left. b\protect\vphantom{L} \right>$}

\section{$\langle a \mid b \rangle$}

\section{$\left< a \;\middle|\; b\right>$}

\end{document}


The first is your code, the second is what I'd prefer, because \left and \right are really doing nothing. The third uses \middle. As you notice, the first has the spacing wrong.

-
thanks for the tip with \mid –  fifaltra Jan 24 at 17:19