Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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):

\documentclass[12pt,a4paper,oneside]{memoir}

\begin{document}
\tableofcontents

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

\end{document}

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

share|improve this question
3  
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 at 14:59
    
Brilliant, thank you. I'd tried a couple of things but not thought of brackets! –  Gemma Jun 20 at 15:03

1 Answer 1

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

\documentclass[12pt,a4paper,oneside]{memoir}
\setcounter{tocdepth}{3} % show also subsections in toc
\setcounter{secnumdepth}{3} % show also subsections number in toc
\usepackage{mathtools}

\begin{document}
\tableofcontents

\chapter{chapter}
\section[test]{section}
\subsection{subsection}
\subsubsection{Title in text}
\subsubsection[{$[\text{PtL}^5\text{(ppy)Cl}]^+$}]{Title in text}
\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

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.