TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to show one subsubsection title in the main body of the text and another in the contents page. I have been using:

\subsubsection[contents title]{text title}

This had worked really well. Now one of the titles that I need in the contents has square brackets in and so gives me loads of error messages (I assume because the brackets are getting confused).

This is my minimum working example (\subsubsection[$[\text{PtL}^5\text{(ppy)Cl}]^+$]{Title in text} is the line causing the problem):



\subsubsection{Title in text}
\subsubsection[$[\text{PtL}^5\text{(ppy)Cl}]^+$]{Title in text}


Thanks for your help, sorry, I'm still relatively new to LaTeX!!

share|improve this question
The first ] is mistaken for the end of the optional argument. Use \subsubsection[{$[\text{PtL}^5\text{(ppy)Cl}]^+$}]{Title in text} – egreg Jun 20 '14 at 14:59
Brilliant, thank you. I'd tried a couple of things but not thought of brackets! – Gemma Jun 20 '14 at 15:03
up vote 4 down vote accepted

You have to set the attribute of your toc-text in curley brackets in order to escape the [] command. I also inserted two commands which allow to show the subsubsection in your toc.

Please note that the command \text{} requires the package mathtools or alike.

% arara: pdflatex
% arara: pdflatex

\setcounter{tocdepth}{3} % show also subsections in toc
\setcounter{secnumdepth}{3} % show also subsections number in toc


\subsubsection{Title in text}
\subsubsection[{$[\text{PtL}^5\text{(ppy)Cl}]^+$}]{Title in text}

enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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