如何让 RevTeX4-2 在目录中使用不同的章节名称?

如何让 RevTeX4-2 在目录中使用不同的章节名称?

我正在使用RevTeX4-2。我在部分名称中有一个数学表达式。我希望它与周围的文本具有相同的字体粗细:在正文中为粗体,在目录中为常规字体。通常的做法是,\section[toc version]{doc version}不起作用,如以下 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}

输出:

在此处输入图片描述


切换到memoir类(虽然report也可以工作),通常的方法确实有效:

\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}

在此处输入图片描述

有没有办法让 RevTex4-2 在目录中使用章节名称的“toc 版本”(其中包含非粗体数学符号)?

答案1

正如您所发现的,revtex4-2不要使用可选\section参数来编写目录。

可以通过更改宏中的一行来修复此问题\@sect@ltx。我不知道如何修补这个长命令,但通过在文档中重新定义它,目录中的粗体字就被删除了。

b

A

尝试一下此代码。它需要编译两次。

\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>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}

相关内容