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.

While I was answering List of Figures/Tables - eliminate dots? I found some strange behaviour; this document:

\documentclass[aps,pra,reprint]{revtex4-1}

\begin{document}

\listoffigures
\listoftables
\tableofcontents

\section{Test Section}
\subsection{Test Subsection}
\section{Another Test Section}

\end{document}

produces the expected result:

enter image description here

but as soon as \tableofcontents is placed before the other two lists, as in

\documentclass[aps,pra,reprint]{revtex4-1}

\begin{document}

\tableofcontents
\listoffigures
\listoftables

\section{Test Section}
\subsection{Test Subsection}
\section{Another Test Section}

\end{document}

the resulting document shows some problems in the ToC; the section numbers and their titles overlap:

enter image description here

What is the cause of this problem and how can it be corrected?

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

Problem

The problem is that there is generic code for all toc-generating commands which expands to something like (see the definition of \@starttoc in ltxutil.dtx):

\toc@pre      % Loads previously saved \tocmax@section etc. and sets
              % \tocdim@section etc. to a fixes small value (5pt) 
...
\@input{\jobname.#1} % Formats the toc, lof etc. but only
                     % computes \tocdim@section etc. if the 
                     % .toc is loaded
...
\toc@post     % Saves \tocdim@section etc. as \tocmax@section in .aux

The \tocdim@section values are only computed properly in the actual table of contents (the lof and lot do not contain section lines). If a lof of lot appears after the toc, then \toc@pre resets the values and \toc@post saves the reset values, which then get read and used next time.

The only way this code works properly as written is to make sure that the \tableofcontents command comes last.

Quick Fix

Disable the resetting and writing of the various \tocmax@* information after the \tableofcontents is typeset:

\tableofcontents

\makeatletter
\let\toc@pre\relax
\let\toc@post\relax
\makeatother 

\listoffigures
\listoftables
share|improve this answer
    
I have reported this as a bug to the revtex developers. –  mforbes Dec 7 '11 at 4:12
add comment

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.