如何增加回忆录目录附录与其连字符之间的间距?

如何增加回忆录目录附录与其连字符之间的间距?

修补后(手动,即直接编辑回忆录的代码),如下所示:

在此处输入图片描述

它看起来应该是这样的:

在此处输入图片描述

我尝试使用 修补回忆录xpatch。我做的这个补丁如果能找到正确的代码就会起作用,但xpatch它说找不到要修补的代码:

\documentclass[
12pt,
]{abntex2} % memoir is loaded internally by the `abntex2` class
\usepackage{xpatch}

\makeatletter
\newcommand{\chapternumberlineappendixpatch}[1]{%
\chapternumberlinehook{#1}%
\chapternumberlinebox\@tempdima{\@chapapp@head\@cftbsnum #1~~\@cftasnum~~}%
\@cftasnumb~}%

\patchcmd{\@chapter}{%
  \addcontentsline{toc}{appendix}{\protect\chapternumberline{\thechapter}\f@rtoc}
}{}{\addcontentsline{toc}
  {appendix}{\protect\chapternumberlineappendixpatch{\thechapter}\f@rtoc}}{
  \message{Chapterformat patch for chapternumberline could NOT
  be applied because its code was not found!^^J ^^J^^J^^J^^J^^J^^J^^J^^J^^J^^J}
  \xshowcmd\@chapter
}
\makeatother

\begin{document}
    \tableofcontents
    \chapter{Some}

    \begin{apendicesenv}
        \chapter{Other}
    \end{apendicesenv}

\end{document}

这是memoir代码:

File: memoir.cls
2926:     \ifanappendix
2927:       \addcontentsline{toc}{appendix}{%
2928:         \protect\chapternumberline{\thechapter}\f@rtoc}%
2929:       \memappchapinfo{\thechapter}{\f@rtoc}{\f@rhdr}{#2}%
2930:     \else

它应该停止调用该函数\chapternumberline并调用我的自定义\chapternumberlineappendixpatch函数并增加连字符周围的空间:

\newcommand{\chapternumberlineappendixpatch}[1]{%
\chapternumberlinehook{#1}%
\chapternumberlinebox\@tempdima{\@chapapp@head\@cftbsnum #1~~\@cftasnum~~}%
\@cftasnumb~}%

File: memoir.cls
2926:     \ifanappendix
2927:       \addcontentsline{toc}{appendix}{%
2928:         \protect\chapternumberlineappendixpatch{\thechapter}\f@rtoc}%
2929:       \memappchapinfo{\thechapter}{\f@rtoc}{\f@rhdr}{#2}%
2930:     \else

答案1

我通过修补较小的碎片设法做到了这一点:

\documentclass[12pt,]{abntex2} % memoir is loaded internally by the `abntex2` class
\usepackage{xpatch}
\makeatletter
\xpretocmd{\l@appendix}{\def\@chapapp@extrahyphenspaces{~}}
{\message{^^J^^JChapterformat patch 1 for chapternumberline could SUCCESSFULLY!^^J}}
{\message{^^J^^JChapterformat patch 1 for chapternumberline could NOT be applied!^^J}}

\xpretocmd{\l@chapter}{\def\@chapapp@extrahyphenspaces{}}
{\message{^^J^^JChapterformat patch 2 for chapternumberline could SUCCESSFULLY!^^J}}
{\message{^^J^^JChapterformat patch 2 for chapternumberline could NOT be applied!^^J}}

\patchcmd{\chapternumberline}{\@cftasnum}{%
  \@chapapp@extrahyphenspaces%
  \@chapapp@extrahyphenspaces%
  \@cftasnum%
}
{\message{^^J^^JChapterformat patch 3 for chapternumberline could SUCCESSFULLY!^^J}}
{\message{^^J^^JChapterformat patch 3 for chapternumberline could NOT be applied!^^J}}

\patchcmd{\chapternumberline}{\@cftasnumb}{%
  \@cftasnumb%
  \@chapapp@extrahyphenspaces%
  \@chapapp@extrahyphenspaces%
}
{\message{^^J^^JChapterformat patch 4 for chapternumberline could SUCCESSFULLY!^^J}}
{\message{^^J^^JChapterformat patch 4 for chapternumberline could NOT be applied!^^J}}
\makeatother

\begin{document}
    \tableofcontents
    \chapter{Some}

    \begin{apendicesenv}
        \chapter{Other}
    \end{apendicesenv}
\end{document}

修补之前: 在此处输入图片描述

修补后: 在此处输入图片描述

相关内容