5

Please consider the following code:

\documentclass{article}
\usepackage{enumitem}
\begin{document}
\begin{enumerate}[label=\arabic*$\star$]
\item ABC
\end{enumerate}
\end{document}

Does anyone know why the code above is accepted, but code with the corresponding LaTeX syntax label=\arabic*\(\star\) results in an bad math delimiter error. One would expect that LaTeX math environments are prefered over TeX math.

Ps. I have come across other answers were they point out that one must match the environments properly, e.g. (...) or [...] but this is true in our case.

8
  • 2
    And note that \( ... \) expands to $ ... $ with some error checking. (I guess in the end the answer to your question is about expansion, but I don't know yet.) It is ok to use $ ... $ in LaTeX documents. With $$ ... $$ it is a bit different and you really should avoid that.
    – Ruben
    Jun 5, 2015 at 9:25
  • 2
    The commands \( and \) are not "robust" by default, whereas $ is. Probably the simplest way to make \( and \) robust is to load the package fixltx2e.
    – Mico
    Jun 5, 2015 at 9:28
  • 1
    Incidentally, which TeX distribution (and which vintage) do you have on your system? Starting with the 2015/01/01 version of the LaTeX2e format, it should no longer be necessary to load fixltx2e manually, i.e., the improvements contained in that package should by now be incorporated by default in the LaTeX2e format.
    – Mico
    Jun 5, 2015 at 9:28
  • 3
    The math environment \ensuremath as [label=\arabic*\ensuremath{\star}] works perfectly Jun 5, 2015 at 9:32
  • 3
    @AmbikaVanchinathan Which is one of the cases where \ensuremath is good.
    – egreg
    Jun 5, 2015 at 10:35

1 Answer 1

5

The most likely reason for

\begin{enumerate}[label=\arabic*\(\star\)]

throwing a "bad math delimiter" error, whereas

\begin{enumerate}[label=\arabic*$\star$]

does not, is that you're using an older LaTeX format (specifically, older than 2015/01/01), in which \( and \) are "fragile" commands (in the LaTeX jargon sense of the word). In contrast, $ has been "robust" all along. Trouble lurks when fragile commands are used in the arguments of other commands.

I can think of two fixes (other, than, of course replacing \( and \) with $ or a similarly "robust" method for entering and exiting math mode):

  • Update your (pdf/Xe/Lua)LaTeX format to a version that is more recent than 2015/01/01. You can find out which version of the LaTeX format your system provides by looking at the first or second line of the .log file.

    Up-to-date LaTeX versions should not produce the error message you encounter. To wit, when I run your MWE on my system (MacTeX2015 pre-release, pdfLaTeX format 2015/05/30), I encounter no problems.

  • If you're stuck with a TeX distribution for which you can't obtain an up-to-date version of the LaTeX format, you should load the fixltx2e package via the instruction

    \RequirePackage{fixltx2e}
    

    before executing \documentclass.... As the name of the package indicates, fixltx2e fixes various known quirks in the LaTeX format. Among the fixes -- you guessed it -- are instructions that make \( and \) "robust".

    Coming to think of it, if you're stuck with a pre-2015/01/01 version of LaTeX, it's probably always a good idea to load this package. (Versions of the LaTeX format more recent than 2015/01/01 incorporate the fixes provided by fixltx2e. Consequently, the latest version of the fixltx2e doesn't "do" anything anymore; if loaded, it just reports that "fixltx2e is not required with releases after 2015".)

You must log in to answer this question.

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