1

I am using RevTeX4-2. I have a math expression in the name of a section. I would like it to be in the same font weight as the surrounding text: bold in the body of the text, and regular in the table of contents. The usual way to do this, \section[toc version]{doc version}, doesn't work, as shown by the following MWE

\documentclass[aps,reprint,superscriptaddress]{revtex4-2}

\usepackage{bm} \begin{document} \title{This is the title}

\author{Bob Author} \affiliation{L.A. Tex University}

\date{\today}

\begin{abstract} Revtex doesn't seem to allow the section titles to have a different name in the table of contents. \end{abstract}

\maketitle

\tableofcontents

\section[Case $\alpha>1$]{Case $\alpha>1$}

Note that $\alpha>1$ is not boldfaced in the section title.

\section[Case $\beta>1$]{Case \bm{$\beta>1$}}

In contrast, $\beta>1$ is indeed boldfaced in the section title. Unfortunately, it is also boldfaced in the Table of Contents. \vfill \end{document}

Output:

enter image description here


Switching to memoir class (though report would also work), the usual way does work:

\documentclass{memoir}
% The `report` class would also work.

\usepackage{bm} \begin{document}

\tableofcontents

\section[Case $\alpha>1$]{Case $\alpha>1$}

This uses the memoir class, but report would also work.

As before, $\alpha>1$ is not boldfaced in the section title.

\section[Case $\beta>1$]{Case \bm{$\beta>1$}}

Again, $\beta>1$ is indeed boldfaced in the section title. However, this time around, it is \emph{not} boldfaced in the Table of Contents.

\end{document}

enter image description here

Is there a way to make RevTex4-2 use the 'toc version' of the section name (which has non-bold math) in the Table of Contents?

1 Answers1

2

As you discovered, revtex4-2 does not use the optional \section argument to write the ToC.

This can be fixed by changing a single line in the \@sect@ltx macro. I don't know how to patch this long command, but by redefining it in the document, the bold face is removed from the ToC.

b

a

Try this code. It needs to be compiled twice.

\documentclass[aps,reprint,superscriptaddress]{revtex4-2}

\usepackage{bm}

\usepackage{showframe} % show margins

%********************************added <<<<<<<<<<<<<<<<<<<<<< \makeatletter

\def@sect@ltx#1#2#3#4#5#6[#7]#8{% @ifnum{#2>\c@secnumdepth}{% \def\H@svsec{\phantomsection}% \let@svsec@empty }{% \H@refstepcounter{#1}% \def\H@svsec{% \phantomsection }% \protected@edef@svsec{{#1}}% @ifundefined{@#1cntformat}{% \prepdef@svsec@seccntformat }{% \expandafter\prepdef \expandafter@svsec \csname @#1cntformat\endcsname }% }% @tempskipa #5\relax @ifdim{@tempskipa>\z@}{% \begingroup \interlinepenalty @M #6{% @ifundefined{@hangfrom@#1}{@hang@from}{\csname @hangfrom@#1\endcsname}% {\hskip#3\relax\H@svsec}{@svsec}{#8}% }% @@par \endgroup @ifundefined{#1mark}{@gobble}{\csname #1mark\endcsname}{#7}% \addcontentsline{toc}{#1}{% @ifnum{#2>\c@secnumdepth}{% \protect\numberline{}% }{% \protect\numberline{\csname the#1\endcsname}% }% #7}% <<<<<<<<<<<<<<<<<<<<<<<< changed from #8 }{% \def@svsechd{% #6{% @ifundefined{@runin@to@#1}{@runin@to}{\csname @runin@to@#1\endcsname}% {\hskip#3\relax\H@svsec}{@svsec}{#8}% }% @ifundefined{#1mark}{@gobble}{\csname #1mark\endcsname}{#7}% \addcontentsline{toc}{#1}{% @ifnum{#2>\c@secnumdepth}{% \protect\numberline{}% }{% \protect\numberline{\csname the#1\endcsname}% }% #8}% }% }% @xsect{#5}}%

\makeatother %*******************************

\begin{document} \title{This is the title}

\author{Bob Author}
\affiliation{L.A. Tex University}

\date{\today}


\begin{abstract}
    Revtex doesn't seem to allow the section titles to have a different name in the table of contents.
\end{abstract}

\maketitle

\tableofcontents

\section[Case $\alpha&gt;1$]{Case $\alpha&gt;1$}

Note that $\alpha&gt;1$ is not boldfaced in the section title.

\section[Case $\beta&gt;1$]{Case \bm{$\beta&gt;1$}}

In contrast, $\beta&gt;1$ is indeed boldfaced in the section title. 
Unfortunately, it is also boldfaced in the Table of Contents.
\vfill

\end{document}

Simon Dispa
  • 39,141