访问 `DeclareTOCStyleEntry` 中的当前章节编号

访问 `DeclareTOCStyleEntry` 中的当前章节编号

我正在使用 KOMA-Script,我想在目录中显示附加信息。想象一下以下代码:

\section{S}
\immediate\write\@auxout{\global\noexpand\@namedef{@info-\arabic{section}}{Cool information}}

现在我想展示“很酷的信息”在我的目录中的部分旁边。我认为这可以这样做:

\CloneTOCEntryStyle{tocline}{@tocsection}
\DeclareTOCStyleEntry[
    entryformat={\marginpar{\csname @info-\arabic{<current section number>}\endcsname}},
]{@tocsection}{section}

我正在寻找一种方法来访问現在部分號碼为了访问先前存储的“很酷的信息”

平均能量 (https://www.overleaf.com/7456392927dzbtfrpcrrpk):

\documentclass{scrartcl}

\CloneTOCEntryStyle{tocline}{@tocsection}
\DeclareTOCStyleEntry[
    entryformat={\marginpar{\csname s@info-1\endcsname}}
]{@tocsection}{section}

\begin{document}

\tableofcontents

\section{Section 1}
\makeatletter
\immediate\write\@auxout{\global\noexpand\@namedef{s@info-\arabic{section}}{Cool information}}
\makeatother

\end{document}

第 5 行不应包含硬编码,1而应包含当前格式化的部分的编号。

答案1

我认为没有选项,这实际上不是通过 contentline 宏传递的。您可以尝试以下方法:

\documentclass{scrartcl}

\CloneTOCEntryStyle{tocline}{@tocsection}
\DeclareTOCStyleEntry[
    entryformat={},
]{@tocsection}{section}

\usepackage{etoolbox}
\makeatletter
\pretocmd\scr@numberline{\marginpar{\csname s@info-#1\endcsname}}{}{\fail}
\makeatother
\begin{document}
\tableofcontents

\section{Section 1}
\makeatletter
\immediate\write\@auxout{\global\noexpand\@namedef{s@info-\thesection}{Cool information}}
\makeatother

\end{document}

相关内容