I have the following code:









When trying to compile it (the second time to get the list of figures), I get:

! Missing $ inserted.

<inserted text>

l.1 ...es $A_{c}($B_{c_{\mathcal {L}}}^{+}$)$}}{1}

If I comment \listoffigures, everything works fine. When I look at the .lof file, I see:

\contentsline {figure}{\numberline {1}{\ignorespaces $A_{c}($B_{c_{\mathcal {L}}}^{+}$)$}}{1}

Which seems to imply that the \ifmmode command did not work properly...

Is there any way to work around that without having to explicitly use \cma{\cmbs{+}}?

  • @campa Thanks, \ensuremath did the trick!
    – Holt
    Commented May 3, 2018 at 10:17

1 Answer 1


When LaTeX writes the line for the table of contents it is not in math mode.

You could define


and then


will work. On the other hand, I see no improvement over


and the more semantic


Avoid \def.

  • Thanks, it worked with ensuremath. I don't want to use $\cma{\cmb{+}}$ because \cma and \cmb are basically placeholders for algorithm names, and I have yet to decide their final value (and I don't want to have to replace $\cma{\cmb{1}}$ by \cma{\cmb{1}} everywhere if I decide not to use math-mode for the algorithm names).
    – Holt
    Commented May 3, 2018 at 10:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .