In a description like


, how do I escape the "]" character?

  • 1
    I was obviously having some kind of meltdown here, I was reading this question even as I was suggesting \[\]. I blame the lack of coffee. – You Jul 19 '11 at 10:43
  • In this particular case you don't need any special precaution, of course, since the ] is already protected by braces. In general \item[...{...[]...}...] – egreg Jul 19 '11 at 10:51

Group only the brackets or the whole expression with additional curly braces.


| improve this answer | |
  • 1
    This is the correct answer which I would have posted as well. I therefore undeleted it. – Martin Scharrer Jul 19 '11 at 10:44
  • 3
    The reason a ] breaks and adding { } works is that optional arguments are not handled like normal ones (which can be cascaded) but are read as part of a macros parameter text from the [ to the very next ]. Placing the ] inside { } effectively hides it from TeX token scanner which is forced to obey the group. Note that macros defined with xparse handle cascaded [ ] correctly (through some extra effort done by that package). – Martin Scharrer Jul 19 '11 at 10:49
  • @Martin: Thanks. I wasn't sure since \item[\texttt{DoSomething(items[])}:] works as is and doesn't need grouping. Additional braces are only necessary when writing \item[{DoSomething(items[]):}]. – Thorsten Donig Jul 19 '11 at 15:51
  • @Thorsten: Any braces around ] will do. It doesn't matter if they are part of a macro argument or not. – Martin Scharrer Jul 19 '11 at 15:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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