![更新](https://linux22.com/image/360909/%E6%9B%B4%E6%96%B0.png)
我想为我的初步论文主题创建一个目录,例如Acknowledgments
,Abstract
等。我会把它放在封面后面,这样读者就可以轻松访问实际的Table of Contents
,,等。这是因为在我的论文模板上,实际和章节之前需要大约 30 页的目录,例如,等Acknowledgments
。Abstract
最初Acknowledgments
,我查看了创建两个目录,发现了以下问题:Abstract
Table of Contents
但是当我尝试使用回忆录类时,我的论文模板出现了几个错误和问题。然后我注意到我实际上只需要一个简单的列表。因此,我开始搜索如何手动创建内容列表。然后我发现了这些问题:
并提出以下可以与该类配合良好的最小示例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}
相关问题:
更新
在完整论文中添加初步目录后,立即引发了问题! No room for a new \write
错误。几个小时后,我弄清楚了发生了什么。关于这个问题高效利用 \writes这已经解释清楚了。将包添加\usepackage{morewrites}
到我的序言顶部可以解决问题。
相关问题! No room for a new \write
: