# Custom list throw LaTeX Error: Command \mycustomfiction already defined?

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:

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}

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

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

\begin{document}

\tableofcontents
\newpage
\listofmycustomfiction

\chapter{Two mycustomfiction}
\label{1st_ex}

\label{2nd_ex}

\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 }

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}

\usepackage[english]{babel}

{
}

\begin{document}

\tableofcontents
\newpage

\chapter{Chapter Two mycustomfiction}

\chapter{One example}

\end{document}


What is wrong with it?

# Update 2

If I do:

\newcommand{\answer}[1]
{%
}


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. – Johannes_B Aug 27 '17 at 17:21
• Doesn't memoir have some external stuff so you don't need to load tocloft? – Johannes_B Aug 27 '17 at 17:22
• Advanced tip: Sprinkle \show\mycustomfiction around your preamble and compile to see where a change happens. Works for other control sequences as well. – Johannes_B Aug 27 '17 at 17:29
• @Johannes_B: memoir does unfortunately emulate some other packages but incomplete, in my point of view, that's why I don't use memoir, however, it is possible to disemulate the packages – user31729 Aug 27 '17 at 17:52
• The thing is, after decades of LaTeX several (broadly used) classes came up and solutions to specific problems depend on the classes in use. Like cars ... The ashtray of a BMW won't fit into a Volkswagen, nor into a Mercedes, nor into a Mazda (to name just a few) but all ashtrays are doing the same job. It is a kind of messiness you have to accept. – Johannes_B Aug 27 '17 at 19:17

Any \addcontentsline statement needs a proper format of contentsline, i.e. \addcontentsline{toc}{chapter}{...} etc.

This chapter name here is actually a macro defined usually by the class or package and has the name \l@chapter, there are \l@section etc. as well. Those macros define the indentation, the level, the spacings and the distance from the entry to the page number slot (usually on the right margin)

Using \newlistof{listofanswers}{ans}{...} does not define the \l@answers macro, however, this must be done with \newlistentry{answers}{ans}{0}, which defines the answers counter as well.

\documentclass{memoir}

\usepackage[english]{babel}

{%
}

\usepackage{hyperref}

\begin{document}

\tableofcontents
\newpage

\chapter{Chapter Two mycustomfiction}

\chapter{One example}

\end{document}


• Thanks! This complements the answer on Poorly formatted newlistof with memoir teaching on how to create my own \l@answers macro instead of copy one from some other command. – user Aug 27 '17 at 21:13
• Adding the table of preliminary contents to may full thesis immediately raised the issue ! No room for a new \write error. After I few more hours I figured out what was going. On the question Making efficient use of \writes this is explained. Adding the package \usepackage{morewrites} to my preamble top solves the problem. – user Aug 28 '17 at 1:01
• @user: Yes, but this morewrites issue is nothing what was in your original question ;-) Of course morewrites is the solution then – user31729 Aug 28 '17 at 10:57

I finally fixed my update version of the question after finding the question Poorly formatted newlistof with memoir I added this to my preamble:

\makeatletter
\makeatother


This is the full version:

\documentclass{memoir}
\usepackage{hyperref}

\usepackage[english]{babel}

% 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?

% 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
{%
\refstepcounter{mycustomfictioncounter}
}

% 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?
\tableofcontents
\newpage
\mycustomfiction*

\chapter{Two mycustomfiction}
\label{1st_ex}

\label{2nd_ex}

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

\end{document}


Related questions:

# Update

Adding the table of preliminary contents to may full thesis immediately raised the issue ! No room for a new \write error. After I few more hours I figured out what was going. On the question Making efficient use of \writes this is explained. Adding the package \usepackage{morewrites} to my preamble top solves the problem.

Related question to ! No room for a new \write`: