3

I have a document with class revtex4-2 in the APS style. I would like to keep the document class for stylistic reasons, but the document need not be styled for journal submission.

I would like to include a very compact table of contents. Specifically: (1) top-level sections only, (2) minimal vertical whitespace between entries, (3) footnotesize sans serif font, (4) links included. Here is what I have been able to achieve so far:

TOC TEXT

This is not compact enough. I would like to completely remove the vertical whitespace. Is this possible?

Regarding (1). RevTex seems to ignore the tocdepth counter. Using the answer to a related question I got around this with (note: I have no idea what this does)

\makeatletter
\def\l@subsection#1#2{}
\def\l@subsubsection#1#2{}
\makeatother

Regarding (3). I tried the tocloft, minitoc, and parskip packages. The first two seem to be incompatible with RevTex, and the third messed up the RevTex styling in the paragraph text. The only thing that worked at all was adjusting \baselinestretch, but as seen in the above image, it seems to hit a minimum.

Is there any way to decrease this whitespace further?

Here's a minimal example:

\documentclass[reprint, aps, prx]{revtex4-2}
\usepackage{hyperref}
\hypersetup{colorlinks = true, linkcolor = blue, linktoc = all}
\begin{document}
{
\makeatletter
\def\l@subsection#1#2{}
\def\l@subsubsection#1#2{}
\makeatother

\footnotesize \sf 
\renewcommand{\baselinestretch}{0.1}

\tableofcontents
}
\section{Introduction}
For comparison, here is the spacing of normal text.
\section{Results}
\subsection{I don't want this in TOC}
\subsection{I also don't want this in TOC}
\section{Another section}
\section{And another}
\section{Less vertical white space between sections please}
\section{Conclusion}
\clearpage
\end{document}

Any TeX lengths I could try to set would be helpful. An answer that recreated an "unofficial" ToC by looping over sections and writing them in a table would also be very helpful.

1

1 Answer 1

4
\documentclass[reprint, aps, prx]{revtex4-2}
\usepackage{hyperref}
\hypersetup{colorlinks = true, linkcolor = blue, linktoc = all}
\begin{document}

\makeatletter
\def\l@subsection#1#2{}
\def\l@subsubsection#1#2{}
\def\l@f@section{}%
\def\toc@@font{\footnotesize \sffamily}%
\makeatother


\tableofcontents



\section{Introduction}
For comparison, here is the spacing of normal text.
\section{Results}
\subsection{I don't want this in TOC}
\subsection{I also don't want this in TOC}
\section{Another section}
\section{And another}
\section{Less vertical white space between sections please}
\section{Conclusion}
\clearpage
\end{document}

enter image description here

3
  • Fantastic, works perfectly! Would you mind briefly mentioning why this worked? Black magic as far as I can tell :) Apr 18 at 11:09
  • well the space had to come from something so I looked into the code to find the relevant command and saw in passing also a comment looking suitable to set a font. Apr 18 at 11:20
  • Thanks! I assume by the code you mean the revtex class file? While you were in there, did you happen to catch a glimpse how one could also change the contents title font/size? Apr 18 at 15:03

You must log in to answer this question.

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