目录中的边注

目录中的边注

我在页边距部分和章节标题中使用星号来表示更高级或更重要的材料。

我使用该marginnote包来实现此目的,如以下示例所示:

\documentclass{article}

\usepackage{marginnote}
\reversemarginpar

\begin{document}

\tableofcontents{}

\section{Context}

If you wanna go somewhere and you don't have railroad fare, plane fare, train fare, boat fare, or don't have no fare, period.

\section{Method}
\marginnote{*}[-25pt]

There's one way of gettin there, I been using the method for 25 years or more, me and old Sonny, and it seems to have paid off. To a higher debt, man. Just walk on.

\end{document}

现在,我想让星号出现在目录的相应标题旁边。如何实现?

答案1

请参阅第一个版本下面的更好的版本!

一种快捷方式:使用 的可选参数\section,但这很繁琐!

\documentclass{article}

\usepackage{marginnote}
\reversemarginpar

\begin{document}

\tableofcontents{}

\section{Context}

If you wanna go somewhere and you don't have railroad fare, plane fare, train fare, boat fare, or don't have no fare, period.

\section[{\protect\marginnote{*}[0pt]}Method]{Method}


There's one way of gettin there, I been using the method for 25 years or more, me and old Sonny, and it seems to have paid off. To a higher debt, man. Just walk on.

\end{document}

更好的版本

我已经使用xparse并添加了更新的定义\section*在命令末尾添加了一个可选的星号参数\section

\section{foo}→ 边距中没有星号

\section{foo}*→ 在边栏中加星号

\section[bar]{foo}→ 边栏没有星号,可选ToC条目bar

\section[bar]{foo}*→ 在边栏中加星号,可选ToC条目bar

查看输出——记得编译两次!

\documentclass{article}

\usepackage{xparse}
\usepackage{marginnote}

\let\LaTeXStandardSection\section

\RenewDocumentCommand{\section}{soms}{%
  \IfBooleanTF{#1}{%
    \LaTeXStandardSection{#3}
  }{%
    \IfValueTF{#2}{%
      \IfBooleanTF{#4}{%
        \LaTeXStandardSection[{\protect\marginnote{*}}#2]{#3}
      }{%
        \LaTeXStandardSection[#2]{#3}
      }%
    }{%
      \IfBooleanTF{#4}{%
        \LaTeXStandardSection[{\protect\marginnote{*}}#3]{#3}
      }{%
        \LaTeXStandardSection[#3]{#3}
      }%
    }%
  }%
}



\reversemarginpar

\begin{document}

\tableofcontents{}

\section{Context}

If you wanna go somewhere and you don't have railroad fare, plane fare, train fare, boat fare, or don't have no fare, period.

\section{Method}*

\section[Other content]{Other content}

\section[Important stuff]{Other important stuff}*



There's one way of gettin there, I been using the method for 25 years or more, me and old Sonny, and it seems to have paid off. To a higher debt, man. Just walk on.

\end{document}

在此处输入图片描述

答案2

您可以将边注添加到章节文本中:

\documentclass{article}

\usepackage{marginnote,etoolbox}
\reversemarginpar
\robustify\marginnote

\begin{document}

\tableofcontents{}

\section{Context}

If you wanna go somewhere and you don't have railroad fare, plane fare, train fare, boat fare, or don't have no fare, period.

\section{Method\marginnote{*}}


There's one way of gettin there, I been using the method for 25 years or more, me and old Sonny, and it seems to have paid off. To a higher debt, man. Just walk on.

\end{document}

在此处输入图片描述

相关内容