I am writing a report for which I am required to use the iopart
class, which can be downloaded from this page, and I'm having some problems with the word 'Appendix' overlapping with its title in the Table of Contents.
Let me explain. Notice in the image how the Appendix
word overlaps with the appendix's name.
Latex code:
\documentclass[12pt]{iopart}
\pdfoutput=1
\begin{document}
\title{Title}
\author{Author$^1$, Author$^2$, Author$^1$}
\address{
{\small $^1$University department.} \\
{\small $^2$Company.}
}
\begin{abstract}
Abstract.
\end{abstract}
\maketitle
\tableofcontents
\clearpage
\section{Section 1}
\section{Section 2}
\appendix
\section{Extra 1}
\subsection{Extra 1.1}
\subsection{Extra 1.2}
\section{Extra 2}
\subsection{Extra 2.1}
\subsection{Extra 2.2}
\end{document}
Now, I found an answer here that helped me fix the problem, but only partially: some of the Appendix
do not overlap their own title any more, but this only happens with those that correspond to sections (Appendix A, Appendix B, ...). The appendices corresponding to subsections (Appendix A.1, A.2, B.1, B.2, ...) still overlap.
The new code is
\documentclass[12pt]{iopart}
\pdfoutput=1
\usepackage{lipsum}
\usepackage{etoolbox}
\makeatletter
\def\@mkboth#1#2{}
\newlength\appendixwidth
\preto\appendix{\addtocontents{toc}{\protect\patchl@section}}
\newcommand{\patchl@section}{%
\settowidth{\appendixwidth}{\textbf{Appendix }}%
\addtolength{\appendixwidth}{1.5em}%
\patchcmd{\l@section}{1.5em}{\appendixwidth}{}{\ddt}%
}
\makeatother
\begin{document}
\title{Title}
\author{Author$^1$, Author$^2$, Author$^1$}
\address{
{\small $^1$University department.} \\
{\small $^2$Company.}
}
\begin{abstract}
Abstract.
\end{abstract}
\maketitle
\tableofcontents
\clearpage
\section{Section 1}
\section{Section 2}
\appendix
\section{Extra 1}
\subsection{Extra 1.1}
\subsection{Extra 1.2}
\section{Extra 2}
\subsection{Extra 2.1}
\subsection{Extra 2.2}
\end{document}
I tried coming up with a solution by adding
\makeatletter
\def\@mkboth#1#2{}
\newlength\subappendixwidth
\preto\subappendix{\addtocontents{toc}{\protect\patchl@subsection}}
\newcommand{\patchl@subsection}{%
\settowidth{\subappendixwidth}{\textbf{Appendix }}%
\addtolength{\subappendixwidth}{1.5em}%
\patchcmd{\l@subsection}{1.5em}{\subappendixwidth}{}{\ddt}%
}
\makeatother
but unfortunately, it does not work. Do any of you have any idea how to fix the overlapping of the appendixes A.1, A.2, B.1, B.2, ...? I've been using LaTeX for quite a while but I don't know how to fix it myself, or even whether it can be fixed or not.
Thanks to all of you for your time.