附有标题和回忆录的附录

附有标题和回忆录的附录

titletoc我正在尝试在文档中自定义目录布局memoir

样式chapter运行良好,如下所示,但如果我尝试该appendix部分,我会收到缺少数字的错误。

我认为这是因\chapternumberline更新为 而造成的\numberline,并且不将A作为附录编号。

但如果不以这种方式更新,则会在定义中\chapternumberline出现错误:Undefined control sequence\@chapapp@headmemoir

\newcommand{\chapternumberline}[1]{%
  \chapternumberlinehook{#1}%
  \hb@xt@\@tempdima{\@chapapp@head\@cftbsnum #1\@cftasnum\hfil}%
  \@cftasnumb}

看起来好像memoir正在与 发生冲突titlesec。有什么建议可以安抚他们吗?

目的是使附录看起来与章节类似:

 Chapter 1 * It Came Into My Head         3
Appendix A * The Time Machine             5

(在下面的 MWE 中,附录样式被注释掉,否则它将是 MNWE)

在此处输入图片描述

mwe.toc

\contentsline {chapter}{\chapternumberline {1}It Came Into My Head}{3}
\contentsline {appendix}{\chapternumberline {A}The Time Machine}{5}
\contentsfinish 

mwe.tex

\documentclass[11pt]{memoir}

\makeatletter

\usepackage{titletoc}

\usepackage{fontspec}
\defaultfontfeatures{Ligatures={TeX}}
\setmainfont{TeX Gyre Pagella}

% Fixes Undefined control sequence error for \@chapapp@head
\renewcommand\chapternumberline[1]{\numberline{#1}}

\titlecontents{chapter}[6pc]
{\normalsize}%
{%
  \contentsmargin{0pt}%
  \makebox[0pt][r]{%
    \chaptername~{\thecontentslabel}%
    \hspace*{0.5em}$\cdot$\hspace*{0.5em}%
  }%
}
{\contentsmargin{0pt}%
\itshape}
{\hfill\normalsize\thecontentspage}

% FIXME: perhaps \numberline is erroring out b/c "A" is not numerical
%! Missing number, treated as zero.
%<to be read again>
%                   \ttll@appendix
%l.21 ...rline {A}The Time Machine}{11}{appendix.A}

%\titlecontents{appendix}[6pc]
%{\normalsize}%
%{%
%  \contentsmargin{0pt}%
%  \makebox[0pt][r]{%
%    \appendixname~{\thecontentslabel}%
%    \hspace*{0.5em}$\cdot$\hspace*{0.5em}%
%  }%
%}
%{\contentsmargin{0pt}%
%\itshape}
%{\hfill\normalsize\thecontentspage}

\makeatother

\begin{document}

\tableofcontents*

\chapter{It Came Into My Head}

'In another moment we were standing face to face, I and this fragile thing out of futurity\ldots

\appendix

\chapter{The Time Machine}

'There were others coming, and presently a little group of perhaps eight or ten\ldots

\end{document}

答案1

你可以使用以下\let命令:\ttll@appendix\ttll@chapter

\documentclass[11pt]{memoir}
\usepackage{titletoc}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures={TeX}}
%\setmainfont{TeX Gyre Pagella}

% Fixes Undefined control sequence error for \@chapapp@head
\renewcommand\chapternumberline[1]{\numberline{#1}}

\titlecontents{chapter}[6pc]
{\normalsize}%
{%
  \contentsmargin{0pt}%
  \makebox[0pt][r]{%
    \chaptername~{\thecontentslabel}%
    \hspace*{0.5em}$\cdot$\hspace*{0.5em}%
  }%
}
{\contentsmargin{0pt}%
\itshape}
{\hfill\normalsize\thecontentspage}

\makeatletter
\let\ttll@appendix\ttll@chapter
\titlecontents{appendix}[6pc]
{\normalsize}%
{%
  \contentsmargin{0pt}%
  \makebox[0pt][r]{%
    \appendixname~{\thecontentslabel}%
    \hspace*{0.5em}$\cdot$\hspace*{0.5em}%
  }%
}
{\contentsmargin{0pt}%
\itshape}
{\hfill\normalsize\thecontentspage}
\makeatother

\begin{document}

\tableofcontents*

\chapter{It Came Into My Head}

'In another moment we were standing face to face, I and this fragile thing out of futurity\ldots

\appendix
\chapter{The Time Machine}

'There were others coming, and presently a little group of perhaps eight or ten\ldots

\end{document}

在此处输入图片描述

titletoc您可以不使用(如果使用,可能会产生问题),而是使用包中hyperref提供和启发的内置机制;一个小例子产生的结果类似于您想要的结果(一些细节仍然需要调整):memoirtocloft

\documentclass[11pt]{memoir}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures={TeX}}
%\setmainfont{TeX Gyre Pagella}

\newlength\mylen
\renewcommand\cftchapteraftersnum{\hspace{0.5em}$\cdot$\hspace{0.5em}}
\settowidth\mylen{\cftchapterpresnum\cftchapteraftersnum}
\addtolength\cftchapternumwidth{\mylen}
\renewcommand\cftchapterfont{\normalfont}
\renewcommand\cftchapterpagefont{\itshape}

\makeatletter
\renewcommand*{\l@chapter}[2]{%
  \l@chapapp{\makebox[7em][l]{\hfill\chaptername~}#1}{#2}{\cftchaptername}}
\renewcommand*{\l@appendix}[2]{%
  \l@chapapp{\makebox[7em][l]{\hfill\appendixname~}#1}{#2}{\cftappendixname}}
\makeatother

\begin{document}

\tableofcontents*

\chapter{It Came Into My Head}

'In another moment we were standing face to face, I and this fragile thing out of futurity\ldots

\appendix
\chapter{The Time Machine}

'There were others coming, and presently a little group of perhaps eight or ten\ldots

\end{document}

在此处输入图片描述

在我的示例中,我注释掉了该行,\setmainfont{TeX Gyre Pagella}因为我没有该字体。

相关内容