更新

更新

我想为我的初步论文主题创建一个目录,例如AcknowledgmentsAbstract等。我会把它放在封面后面,这样读者就可以轻松访问实际的Table of Contents,,等。这是因为在我的论文模板上,实际和章节之前需要大约 30 页的目录,例如,等AcknowledgmentsAbstract最初Acknowledgments,我查看了创建两个目录,发现了以下问题:AbstractTable of Contents

  1. 向目录添加初步元素
  2. 两个独立的 TOC
  3. 如何设置两个独立的目录
  4. ToC 章节号宽度和摘要类别
  5. \part 和 tocloft

但是当我尝试使用回忆录类时,我的论文模板出现了几个错误和问题。然后我注意到我实际上只需要一个简单的列表。因此,我开始搜索如何手动创建内容列表。然后我发现了这些问题:

  1. 如何获取附录列表?
  2. 如何创建我自己的物品清单

并提出以下可以与该类配合良好的最小示例report

\documentclass{memoir}
% \documentclass{report}

\usepackage{tocloft}
\usepackage{hyperref}

\usepackage[english]{babel}
\hypersetup{colorlinks=true}

\newcommand{\listexamplename}{List of mycustomfiction}
\newlistof{mycustomfiction}{mcf}{\listexamplename}

\newcommand{\mycustomfiction}[1]
{%
    \refstepcounter{mycustomfiction}
    \addcontentsline{mcf}{mycustomfiction}
    {\protect\numberline{\themycustomfiction}#1}\par
}

\begin{document}

    \tableofcontents
    \newpage
    \listofmycustomfiction

    \chapter{Two mycustomfiction}
    \mycustomfiction{Your first example}
    \label{1st_ex}
    Your first example

    \mycustomfiction{Your second example}
    \label{2nd_ex}
    Your second example

    \chapter{One example}
    \mycustomfiction{Your third example. (See example \ref{1st_ex} and \ref{2nd_ex})}
    Your third example. (See example \ref{1st_ex} and \ref{2nd_ex})

\end{document}

但是使用回忆录类会抛出这些错误:

! LaTeX Error: Command \mycustomfiction already defined.
               Or name \end... illegal, see p.192 of the manual.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.18 }

Your command was ignored.
Type  I <command> <return>  to replace it with another command,
or  <return>  to continue without it.

Redoing nameref's sectioning
Redoing nameref's label
LaTeX Info: Redefining \nameref on input line 20.
LaTeX Info: Redefining \ref on input line 20.
LaTeX Info: Redefining \pageref on input line 20.
LaTeX Info: Redefining \nameref on input line 20.

{D:/User/Documents/latex/texmfs/data/pdftex/config/pdftex.map}]
! Undefined control sequence.
l.24     \listofmycustomfiction

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

[2

但是,当memoir用类替换类时report,它确实可以编译而没有任何错误:

在此处输入图片描述

如何修复它以便我可以使用 memoir 类来构建它?也许我应该使用除此以外的其他包tocloft


更新

现在我按照回忆录课程手册中的例子,但我的清单却变得疯狂:

在此处输入图片描述

\documentclass{memoir}

\usepackage{hyperref}
\hypersetup{colorlinks=true}

\usepackage[english]{babel}

\newcommand{\listanswername}{List of Answers}
\newlistof{listofanswers}{ans}{\listanswername}

\newcounter{answercounter}[chapter]
\renewcommand{\theanswercounter}{\arabic{answercounter}}

\newcommand{\answer}[1]
{
    \refstepcounter{answercounter}
    \par\noindent\textbf{Answer \theanswercounter. #1}
    \addcontentsline{ans}{answercounter}{\protect\numberline{\theanswercounter}#1}\par
}

\begin{document}

    \tableofcontents
    \newpage
    \listofanswers*

    \chapter{Chapter Two mycustomfiction}
    \answer{Your first example}
    Your first example

    \answer{Your second example}
    Your second example

    \chapter{One example}
    \answer{Your third example.}
    Your third example.

\end{document}

它有什么问题?


更新 2

如果我做:

\newcommand{\answer}[1]
{%
    \refstepcounter{answercounter}
    \addcontentsline{ans}{answercounter}{\newline\newline#1\hfill}
}

我收到这些警告和格式:

Underfull \hbox (badness 10000) in paragraph at lines 1--25

 []


Underfull \hbox (badness 10000) in paragraph at lines 1--25

 []


Underfull \hbox (badness 10000) in paragraph at lines 1--25

 []

[2]
Package hyperref Info: bookmark level for unknown answercounter defaults to 0 o
n input line 27.
 [3

在此处输入图片描述

答案1

任何\addcontentsline语句都需要适当的内容行格式,例如\addcontentsline{toc}{chapter}{...}等等。

此处的chapter名称实际上是通常由类或包定义的宏,名称为\l@chapter,还有\l@section等等。这些宏定义了缩进、级别、间距以及从条目到页码槽(通常在右边距)的距离

使用\newlistof{listofanswers}{ans}{...}没有定义\l@answers宏,但是,必须使用 来完成\newlistentry{answers}{ans}{0},它answers也定义了计数器。

\documentclass{memoir}


\usepackage[english]{babel}

\newcommand{\listanswername}{List of Answers}
\newlistof{listofanswers}{ans}{\listanswername}
\newlistentry[chapter]{answers}{ans}{0}

\newcommand{\answer}[1]
{%
  \refstepcounter{answers}%
  \par\noindent\textbf{Answer \theanswers. #1}%
  \addcontentsline{ans}{answers}{\protect\numberline{\theanswers}#1}\par
}

\usepackage{hyperref}
\hypersetup{colorlinks=true}


\begin{document}

    \tableofcontents
    \newpage
    \listofanswers*

    \chapter{Chapter Two mycustomfiction}
    \answer{Your first example}
    Your first example

    \answer{Your second example}
    Your second example

    \chapter{One example}
    \answer{Your third example.}
    Your third example.

\end{document}

在此处输入图片描述

答案2

我终于修好了更新找到问题后的问题版本带有回忆录的格式不佳的 newlistof我在序言中加上了这一点:

\makeatletter
\let\l@answercounter\l@figure
\makeatother

这是完整版本:

\documentclass{memoir}
\usepackage{hyperref}

\usepackage[english]{babel}
\hypersetup{colorlinks=true}

% How to create my own list of things
% https://tex.stackexchange.com/questions/61086/how-to-create-my-own-list-of-things
\newcommand{\mycustomfictionlistname}{List of mycustomfiction}
\newlistof{mycustomfiction}{mcf}{\mycustomfictionlistname}

% Custom list throw LaTeX Error: Command \mycustomfiction already defined?
% https://tex.stackexchange.com/questions/388489/custom-list-throw-latex-error-command-mycustomfiction-already-defined
\newlistentry{answers}{ans}{0}

% Resetting counter
% https://tex.stackexchange.com/questions/66604/resetting-counter
\newcounter{mycustomfictioncounter}

% Continuing Page Numbering (Roman to Arabic)
% https://tex.stackexchange.com/questions/56131/continuing-page-numbering-roman-to-arabic
\renewcommand{\themycustomfictioncounter}{\arabic{mycustomfictioncounter}}

% Reset section numbering between unnumbered chapters
% https://tex.stackexchange.com/questions/71162/reset-section-numbering-between-unnumbered-chapters
\newcommand{\addtomycustomfiction}[1]
{%
    \refstepcounter{mycustomfictioncounter}
    \addcontentsline{mcf}{mycustomfictioncounter}{\protect\numberline{\themycustomfictioncounter}#1}\par
}

% Poorly formatted newlistof with memoir
% https://tex.stackexchange.com/questions/89743/poorly-formatted-newlistof-with-memoir
\makeatletter
\let\l@mycustomfictioncounter\l@figure
\makeatother

\begin{document}

    % How to remove double “Contents” heading generated by memoir?
    % https://tex.stackexchange.com/questions/47225/how-to-remove-double-contents-heading-generated-by-memoir
    \tableofcontents
    \newpage
    \mycustomfiction*

    \chapter{Two mycustomfiction}
    \addtomycustomfiction{Your first example}
    \label{1st_ex}
    Your first example

    \addtomycustomfiction{Your second example}
    \label{2nd_ex}
    Your second example

    \chapter{One example}
    \addtomycustomfiction{Your third example. (See example \ref{1st_ex} and \ref{2nd_ex})}
    Your third example. (See example \ref{1st_ex} and \ref{2nd_ex})

\end{document}

在此处输入图片描述


相关问题:

  1. 重置未编号章节之间的节编号
  2. 生成自定义环境列表。
  3. 重置计数器
  4. 连续页码(罗马字至阿拉伯字)
  5. 如何删除回忆录产生的双“目录”标题?
  6. 如何从 ToC 中删除 ToC 的自我引用?

更新

在完整论文中添加初步目录后,立即引发了问题! No room for a new \write错误。几个小时后,我弄清楚了发生了什么。关于这个问题高效利用 \writes这已经解释清楚了。将包添加\usepackage{morewrites}到我的序言顶部可以解决问题。

相关问题! No room for a new \write

  1. morewrites 和 scrwfile 之间的区别
  2. 特殊的包装组合给出“没有空间容纳新的 \write”。
  3. 调试 没有空间容纳新的 \write 问题
  4. 无法使用 imakeidx 和 Reledpar 生成 TOC
  5. morewrites 不支持文件内容吗?我可以使用 TeX 原语写入环境主体吗?
  6. 如何增加 TeX 打开文件的限制?
  7. 使用带有回忆录的索引包
  8. KOMA-Script 和回忆录的优点和缺点是什么?
  9. 索引包列表 - 优点和缺点

相关内容