1

I have two questions somewhat relating to the memoir table of contents, as both concern the same thing to me I hope it is alright if I group the two of them together, let me know if in the future I should ask separate questions and I will do so.

First: I want to indent only the \mainmatter entries in a short table of contents but haven't been able to do so with \cftsetindents as it indents all of the entries when I use \cftsetindents{chapter}, is there a way to discriminate between \frontmatter, \mainmatter and \appendix entries in a TOC?

\documentclass[oneside]{memoir}

% Creating short table of contents (Comes before main TOC in my actual file)
\newcommand*{\setupshorttoc}{%
    \renewcommand*{\contentsname}{Short Contents}       % Title of the contents
    \renewcommand*{\changetocdepth}[1]{}            % Changes toc depth
    \setcounter{tocdepth}{0}                        % Chapters and above
    \cftsetindents{chapter}{1.5em}{3.0em} % Indents front matter, main matter and appendices
    }

\begin{document}

\frontmatter
\tableofcontents*
\newpage
\setupshorttoc
\tableofcontents*
\newpage
\listoffigures

\mainmatter
\chapter{Introduction}
\section{Research Aims}

\appendix
\chapter{Research}
\end{document}

Second: I am trying to make the page contents {empty} and add 'Page' above the page numbers but naturally when I issued the arguments separately they overwrote whichever one came first. I am sure this is basic and not related specifically to memoir but once I know how to group arguments in the same command then I know from this point on. For example:

\documentclass{memoir}
\usepackage{blindtext}

% Trying to combine commands is leading to unexpected output such as increased lengths in between `Page' and numbers
\newcommand*{\setuptoc}{%
    \renewcommand*{\aftertoctitle}{%
        \par\nobreak \mbox{}\hfill{\normalsize\bfseries Page}\par\nobreak%
         \thispagestyle{empty}\afterchaptertitle} % Instruction
    }

\begin{document}
\frontmatter
\setuptoc
\tableofcontents
\mainmatter
\chapter{Introduction}
\section{Research Aims}
\Blindtext[1]
\end{document}

This achieves what I want, empty page style and page above the page numbers, but leads to gaps such as this:

enter image description here

What is the correct way to have multiple arguments/instructions in the same \newcommand or \renewcommand?

2
  • I'm always surprised when I see guidelines made by academic authorities that prescribe “Page” above the page numbers in the table of contents. What else should those figures be?
    – egreg
    Jul 1 at 20:55
  • Yeah it is extremely redundant but I have no choice :( I was wondering if you had any thoughts or improvements on my solution to the first question I just posted below. I am quite new so I doubt that manual trial-and-error \hspace is the most optimal way to align entries, I would appreciate any improvements if you had the time. Jul 3 at 0:26
1

For your first question I don't know the answer to your presented problem. Both the long and short ToCs will take their input from the document's .toc file, so whatever is in the .toc file is used as the source for the two ToCs.

You could use \addtocontents{toc}{<stuff>} after \frontmatter, mainmatter and backamatter to change the ToC output but this will apply to both your long and short ToCs.

Regarding your second question you need to change the ordering of your code in \renewcommand*{\aftertoctitle}{%

% memtocs2prob.tex  SE 603431 (second question)

\documentclass{memoir}
\usepackage{blindtext}

% Trying to combine commands is leading to unexpected output such as increased lengths in between `Page' and numbers
\newcommand*{\setuptoc}{%
    \renewcommand*{\aftertoctitle}{%
          \thispagestyle{empty}%\afterchaptertitle} % Instruction
       \par\nobreak \mbox{}\hfill{\normalsize\bfseries Page}\par\nobreak%
%         \thispagestyle{empty}\afterchaptertitle} % Instruction
    }}

\begin{document}
\frontmatter
\setuptoc
\tableofcontents
\mainmatter
\chapter{Introduction}
\section{Research Aims}
\Blindtext[1]
\end{document}

enter image description here

1
  • Thank you for your help on the second question, worked perfectly. I was wondering if you had any thoughts on my answer I have just posted which solves the first issue - mainly if using some other command then \hspace{} could improve my method? Jul 3 at 0:21
1

Managed to solve how to discriminate between different \mainmatter and \appendix entries into a short memoir table of contents so that one type can be indented only. From daleif a while ago, the command to add 'Appendix' before entries is given by:

\renewcommand\cftappendixname{\appendixname~}

Which can be modified by adding \hspace{} or something similar. After manual trial-and-error finding the cm length that lines up best, an example is given by:

\documentclass[oneside]{memoir}

% Preamble to set up the short table of contents
\newcommand*{\setupshorttoc}{%
    \renewcommand*{\contentsname}{Short Contents}   % Title of the contents
    \let\oldchangetocdepth\changetocdepth           % Defining oldchangetocdepth to be the default definition
    \renewcommand*{\changetocdepth}[1]{}            % Changes toc depth
    \setcounter{tocdepth}{0}                        % Chapters and above
    \renewcommand*{\cftchapterfont}{\normalsize}    % Changes font, spacing of the list on the left
    \renewcommand*{\cftchapterdotsep}{\cftdotsep}   % Chapters include dots in short contents
    \renewcommand*{\cftchapterleader}{%
        \sffamily\cftdotfill{\cftchapterdotsep}}    % Font and format of leader between page numbers and content
    \renewcommand*\cftappendixname{\appendixname~}  % Adds `Appendix' before appendix letter
    \setpnumwidth{2.55em}                           % Changes page number width to standard 2.55em
    \renewcommand*{\cftchapteraftersnum}{.}         % Added dots after ch. names, applied globally so may affect lists
    \renewcommand*{\cftchapterformatpnum}[1]{%
        \hbox {\hfil{\cftchapterfont ##1}}}         % Sets page number font
        
    % Change either \hspace to something else or change the dimensions %
    \renewcommand*\cftchaptername{%
        \hspace{0.245cm}\chaptername~}
        
%   % The below equally works as above
%   \renewcommand*\cftchaptername{%
%       \hspace{0.245cm}Chapter }       
    }

%
%\newcommand*{\setupmaintoc}{%
%   % Instructions here for reverting back from short TOC to long TOC
%   }

\begin{document}
\frontmatter
\setupshorttoc
\tableofcontents*
\newpage
\listoftables
\newpage
\listoffigures
\newpage

\mainmatter
\chapter{One}
\section{Aims}
\chapter{Two}
\section{Research}
\chapter{One}
\section{Aims}
\chapter{Two}
\section{Research}

\appendix
\chapter{One}
\section{Aims}
\chapter{Two}
\section{Research}
\chapter{One}
\section{Aims}
\chapter{Two}
\section{Research}

\end{document}

This then indents only the chapter headings as desired and could be changed to appendices if needed as well. I wanted the chapters to indent slightly so they stand out, a full page of contents in a straight-line does not look as nice to me anyway.

If anyone has any improvements, particularly on how to automatically align the adjoining chapter titles between types (such as in the picture below: Chapter 4 - Appendix A) then that would be nice. Hope this helps someone in the future.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.