[pdftex] bug with closing square brackets in description environment

Robin Fairbairns Robin.Fairbairns at cl.cam.ac.uk
Thu Mar 23 18:06:42 CET 2006


> if in the following code the "\rbkt" is replaced by just "]",
> latex fails to produce a dvi file.
> 
> \documentclass{article}
> 
> \newcommand{\rbkt}{]}
> 
> \begin{document}
> 
> \begin{description}
>   \item[$a[a\rbkt$] here the problem arrises:  just $]$ does not work.
> \end{description}
> 
> \end{document}

as expected.  tex balances braces automatically, but not brackets.  so
\item[$a[a]$] is terminated at the first right bracket, and the
optional argument becomes "$a[a", which goes into a box, where it
isn't valid tex.

the normal technique for dealing with this is to put the brackets in
matched braces, but that's not necessarily a good idea in maths code.

try

  \item[{$a[a]$}]

instead.



More information about the pdftex mailing list