I was looking to create a table of contents for my preliminary thesis topics as Acknowledgments
, Abstract
, etc. I would put it after the cover so the reader can easy access the actual Table of Contents
, Acknowledgments
, Abstract
, etc. This is due because on my thesis template it is required about 30 pages of contents as Acknowledgments
, Abstract
, etc. before the actual Table of Contents
and the chapters. Initially I looked over creating two table of contents and I found these questions:
- Add preliminary elements to the ToC
- Two independent TOCs
- How do I set up two independent tables of contents
- ToC chapter number width & memoir class
- \part and tocloft
But when trying to make things work with memoir class I got several errors and problems on my thesis template. Then I noticed I just actually need a simple list of things. Therefore I started searching on how to create lists of contents manually. Then I found these questions:
And come up with the following minimal example which works fine with the report
class:
\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}
But throw these errors with the memoir class:
! 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
However when replacing the memoir
class with report
class, it does compiles without any errors:
How can it be fixed so I can build it with memoir class? Perhaps I should use another package other than tocloft
Update
Now I following the example from memoir class manual, but my list is going nuts:
\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}
What is wrong with it?
Update 2
If I do:
\newcommand{\answer}[1]
{%
\refstepcounter{answercounter}
\addcontentsline{ans}{answercounter}{\newline\newline#1\hfill}
}
I got these warnings and format:
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
\newlistof
create a control sequence with the same name.memoir
have some external stuff so you don't need to loadtocloft
?\show\mycustomfiction
around your preamble and compile to see where a change happens. Works for other control sequences as well.memoir
does unfortunately emulate some other packages but incomplete, in my point of view, that's why I don't usememoir
, however, it is possible todisemulate
the packages