Document ClassesToC garbled in revtex4-1. What the Hell !?

Information and discussion about specific document classes and how to create your own document classes.
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

ToC garbled in revtex4-1. What the Hell !?

Post by Cham »

What is happening with this simple code ? The preview output is nice, but the ToC is garbled once exported as a PDF document! :o

Code: Select all

\RequirePackage[l2tabu,orthodox]{nag}
\documentclass[11pt]{revtex4-1}

\begin{document}

\title{Big Title}
\author{Isaac Newton}
\email[email: ]{isaac.newton@somewhere.net}
\affiliation{Somewhere}

\begin{abstract}
Text.
\end{abstract}

\maketitle
\tableofcontents

\section{Introduction}

Text.

\section{Title}

Text.

\section{Title}

Text.

\subsection{Title}

Text.

\subsubsection{Title}

Text.

\subsubsection{Title}

Text.

\section*{Thanks}

Text.

\begin{thebibliography}{999}

\bibitem{bibitem1}
R.~Bob \& P.~Peter, \textit{Title}, Found.\ Phys.\  \textbf{47}, no. 6, 797 (2017).
\bibitem{bibitem2}
F.~Charles \& R.~Alice, \textit{Title}, Phys.\ Rev.\ D \textbf{65}, 103522 (2002).
    
\end{thebibliography}

\end{document}
What is wrong here ? I know that the revtex4-1 class have some problems with customization, but why this crap with a minimal code ?

Preview :
garbledToC.jpg
garbledToC.jpg (14.22 KiB) Viewed 6712 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

ToC garbled in revtex4-1. What the Hell !?

Post by Johannes_B »

Please click on Open in Overleaf just above the code you posted.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

ToC garbled in revtex4-1. What the Hell !?

Post by Cham »

Johannes, I don't understand what you want to show. As I said, the preview is fine, but the compiled PDF file isn't. The OverLeaf feature is broken on my old browser since about a year now. It no longer works after some change has been made on this site.

EDIT : I just noticed these warnings in the console (this comes from the simple MWE code I posted above) :
Package nag Warning: Command \it is an old LaTeX 2.09 command.
(nag) Use \itshape or \textit instead on input line 18.

[1{/usr/local/texlive/2015/texmf-var/fonts/map/pdftex/updmap/pdftex.map}] (./TSWLatexianTemp_000002.toc
Overfull \hbox (6.49583pt too wide) detected at line 6
\OT1/cmr/m/n/10.95 I.

Overfull \hbox (0.475pt too wide) detected at line 6
\OT1/cmr/m/n/10.95 2

...
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

ToC garbled in revtex4-1. What the Hell !?

Post by Stefan Kottwitz »

Hi Cham,

you have to compile several (three) times, without deleting .toc or .aux file. At the first time, the toc is created. In the second run, the toc is displayed, but not yet all spaces for numbers reserved since they are now calculated and written to .toc or .aux, at the third time all is printed with correct placement and spacing. At least this is what I guess from looking at revtex4-1, some auto-adjusting table of contents packages do the same.

Stefan
LaTeX.org admin
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

ToC garbled in revtex4-1. What the Hell !?

Post by Cham »

Stefan, apparently, you are right ! My preview was typesetting three times, while my export was doing it 2 times only. Changing this solves the issue, but I've done it on another computer (I'm at work right now). I'll confirm this later when I'll be on my main home computer.

But it's weird that I need 3 passes for a revtex4-1 file (without any index), while 2 passes is usually enough for all my other normal documents (book, article, etc, with a ToC but without index). Is this a "normal" non-standard behavior for the revtex4 class ?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

ToC garbled in revtex4-1. What the Hell !?

Post by Stefan Kottwitz »

Yes, but it's automatically adjusting the width instead of using fixed widths like base classes. With the latter, one can easily run into overlapping numbers when they are too hight, so too wide, such as with Roman numbers.

Stefan
LaTeX.org admin
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

ToC garbled in revtex4-1. What the Hell !?

Post by Cham »

Ahaa ! You see? I'm again learning new LaTeX things while just experimenting with the revtex4 class! (even if I already said in another topic that I'll abandon that class) :)

So the space between numbers and their section title in the ToC is a constant for most classes, while it's a variable that need 3 passes to be defined in revtex4?

Thanks for the interesting explanation !
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

ToC garbled in revtex4-1. What the Hell !?

Post by Cham »

Yep, I confirm that the revtex4-1 ToC need 3 passes. It's even actually a +1 point for that class, since it knows how to calculate the proper space in the ToC. I had a space problem with the book class before (space too small for some large section numbers, in a huge book), so I had to hack the ToC using some package.

Now I'm having a last problem with the revtex4-1 class : its ToC title "Contents" isn't translated in French, while the rest appears to be. Why ? How to make the ToC properly saying "Table des matières" (or something similar in French) ?
Last edited by Cham on Fri Dec 01, 2017 2:38 am, edited 1 time in total.
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

ToC garbled in revtex4-1. What the Hell !?

Post by Cham »

Apparently, I have to add the following command to translate "Contents" :

Code: Select all

\def\tocname{Table des matières}
I'm wondering if this is an "hack", or if there's something else to do the translation more "naturally". Any idea on this ?
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

ToC garbled in revtex4-1. What the Hell !?

Post by Johannes_B »

Not a hack. Since that class has a very limited purpose, it is fixed. If you want to make a customiation, you need to whack it with a hammer. In this case, it is \defing the tocname.

By the way, you should check out latexmk. Great tool.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply