2

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!!

2
  • 3
    The first ] is mistaken for the end of the optional argument. Use \subsubsection[{$[\text{PtL}^5\text{(ppy)Cl}]^+$}]{Title in text}
    – egreg
    Commented Jun 20, 2014 at 14:59
  • Brilliant, thank you. I'd tried a couple of things but not thought of brackets!
    – Gemma
    Commented Jun 20, 2014 at 15:03

1 Answer 1

4

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

2
  • To escap charaters add a \ befor it
    – y2k
    Commented Jul 9, 2023 at 17:44
  • Hi @y2k where should I escape what?
    – LaRiFaRi
    Commented Jul 14, 2023 at 8:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .