0

I am getting the error

! Extra }, or forgotten $. \sbox ...hbox {\color@setgroup #2\color@endgroup }
l.6  \item[$]
        $]

! LaTeX Error: Something's wrong--perhaps a missing \item.

With the MWB

\documentclass{article}

\begin{document}

\begin{description}
  \item[$]$]
\end{description}

\end{document}

It also fails when using \(]\). Clearly that contained bracket is being matched as the one that closes the optional argument, so how do I prevent that?

1
  • 2
    Just write \item[${]}$].
    – user121799
    Nov 28 '17 at 20:13
3

A ] inside an optional argument with [] must be grouped into a {} pair (unless the macro is defined with \NewDocumentCommand etc. from xparse, which is not the case here)

In my point of view there is no need for $]$ then at all.

\documentclass{article}

\begin{document}

\begin{description}
  \item[{]}]
\end{description}

\end{document}
2
  • "In my point of view there is no need for $]$ then at all. " Well the non-minimal case I encountered is actually a math formula that contains ], so for my purposes, math mode is needed. But the general concept still works, so thanks. (I always figured math mode provided an implicit grouping, but I guess not.) [ by itself seems to work just fine either way, though.
    – JAB
    Nov 28 '17 at 20:17
  • @JAB: You're right that [ works, but more rather by 'chance' . Grouping does no harm there.
    – user31729
    Nov 28 '17 at 20:20

Not the answer you're looking for? Browse other questions tagged or ask your own question.