I use the iopart class to write a paper. I include the table of contents with the usual command, but I got the part related with the appendices which overlap with the title (see figure).

How can I fixed this?

NB you will NEED the iopart class to compile.

A minimal working example - sorry some packages are unnecessary.

\documentclass[12pt]{iopart}

\usepackage[dvips]{graphicx}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{latexsym}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
%\usepackage{amsmath} % Error with iopart class
\usepackage{color}
\usepackage{psfrag}
\usepackage{rotating}
\usepackage{pgf,pgfsys,pgffor}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usepackage[caption=false]{subfig}
\usepackage{tikz}
\usepackage{hyperref}
\bibliographystyle{iopart-num}

\begin{document}

\title{Main title}% Force line breaks with \\

\begin{abstract}
bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla

bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla
\end{abstract}

\maketitle

\tableofcontents

bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla

\section{Title 1}

bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla \ref{AppendixA}

\section{Title 2}

bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla bla bla blabla \ref{AppendixB}

\appendix

\section{Title A}
\label{AppendixA}

\section{Title B}
\label{AppendixB}

\end{document}

• The iopart class does not make provisions for appendixes in the TOC. It will need a major rewrite of the \section, \l@section or both. The best advice is not to use a table of contents for IOP articles. – Danie Els Jul 10 '14 at 7:35
• Do you need the word "appendix" in your TOC? If not, just go to the iopart.cls in line 501, find \def\thesection{Appendix \Alph{section}} and replace it by \def\thesection{\Alph{section}}. If this is a solution for you, I will try to patch that or you could rephrase your question in order to find someone who is able to do this. – LaRiFaRi Jul 10 '14 at 7:49

My impression is, agreeing with LaRiFaRi, that iopart doesn't really provide for a table of contents. Indeed, the command \tableofcontents is steadily copied from article.cls (an old version, by the way), because it has an extraneous \@mkboth command that sets the header to an unwanted string (they want the paper title as the header).

Here's a patch, anyway, where I use only the strictly necessary packages; add the ones you need (except lipsum that's only used for producing mock text).

Note that the titles in the TOC might be typeset wrongly if you have something else after the appendices. Please, let me know if this is the case.

\documentclass[12pt]{iopart}

\usepackage{etoolbox}
\usepackage{hyperref}

\usepackage{lipsum}% just for the example

\makeatletter
\def\@mkboth#1#2{}
\newlength\appendixwidth
\newcommand{\patchl@section}{%
\settowidth{\appendixwidth}{\textbf{Appendix }}%
\patchcmd{\l@section}{1.5em}{\appendixwidth}{}{\ddt}%
}
\makeatother

\begin{document}

\title{Main title}

\begin{abstract}
\lipsum[1-2]
\end{abstract}

\maketitle

\tableofcontents

\bigskip

\lipsum[4]

\section{Title 1}

\lipsum[4]

\section{Title 2}

\lipsum[4]

\appendix

\section{Title A}
\label{AppendixA}

\section{Title B}
\label{AppendixB}

\end{document}


If you can live with the absence of the word "Appendix" in your titles, you could do the following patch to the iopart.cls:

% arara: pdflatex

\documentclass[12pt]{iopart}
\makeatletter
\renewcommand\@appendixstar{\@@par
\ifnumbysec
\setcounter{section}{0}
\setcounter{subsection}{0}
\setcounter{subsubsection}{0}
\setcounter{equation}{0}
\setcounter{figure}{0}
\setcounter{table}{0}
\def\thesection{\Alph{section}} % this line has been \def\thesection{Appendix \Alph{section}} before
\def\theequation{\ifnumbysec
\Alph{section}.\arabic{equation}\else
\Alph{section}\arabic{equation}\fi}
\def\thetable{\ifnumbysec
\Alph{section}\arabic{table}\else
A\arabic{table}\fi}
\def\thefigure{\ifnumbysec
\Alph{section}\arabic{figure}\else
A\arabic{figure}\fi}}
\makeatother

\begin{document}
\tableofcontents
\section{Title 1}
\appendix
\section{Title A}
\end{document}


As the word "Contents" appears two times on this page, it seems like it was not intended by iopart to use a table of contents here.