4

I have set up a format for my table of contents in which the page number follows the section name rather than being separated by a dotted leader. But my lists of tables, figures, and so on still have the dotted leader.

How do I format the lists the same way as the table of contents?

Here is the setup for the TOC within a minimal example:

\documentclass{memoir}

% Put TOC page numbers after title, not on right margin
% No dotted leaders
% Set number left-aligned in a box starting 1 em to the right of title
\makeatletter
\renewcommand{\cftchapterleader}{}
\renewcommand{\cftchapterafterpnum}{\cftparfillskip}
\renewcommand*{\cftchapterformatpnum}[1]{%
    \cftchapterformatpnumhook{#1}%
    \nolinebreak[4]\hspace*{1em}\hbox to \@pnumwidth{{\cftchapterpagefont #1}\hfill}%
}

\renewcommand{\cftsectionleader}{}
\renewcommand{\cftsectionafterpnum}{\cftparfillskip}
\renewcommand*{\cftsectionformatpnum}[1]{%
    \cftsectionformatpnumhook{#1}%
    \nolinebreak[4]\hspace*{1em}\hbox to \@pnumwidth{{\cftsectionpagefont #1}\hfill}%
}
\makeatother

\begin{document}

\frontmatter
\tableofcontents*
\listoftables
\listoffigures

\mainmatter
\chapter{Chapter}

\begin{table}
\framebox{TABLE}
\caption{Table}
\label{table1}
\end{table}

\section{Section}

\begin{figure}
\framebox{FIGURE}
\caption{Figure}
\label{figure1}
\end{figure}

\chapter{Chapter}

\begin{table}
\framebox{TABLE}
\caption{Table}
\label{table2}
\end{table}

\section{Section}

\begin{figure}
\framebox{FIGURE}
\caption{Figure}
\label{figure2}
\end{figure}

\end{document}

enter image description here

  • I hope I haven't misunderstood your question... – karlkoeller Mar 30 '15 at 20:17
  • @karlkoeller Nope, you nailed it. – musarithmia Mar 30 '15 at 20:54
6

Add also

\renewcommand{\cfttableleader}{}
\renewcommand{\cftfigureleader}{}
\renewcommand{\cfttableafterpnum}{\cftparfillskip}
\renewcommand{\cftfigureafterpnum}{\cftparfillskip}

MWE

\documentclass{memoir}

% Put TOC page numbers after title, not on right margin
% No dotted leaders
% Set number left-aligned in a box starting 1 em to the right of title
\makeatletter
\renewcommand{\cftchapterleader}{}
\renewcommand{\cftchapterafterpnum}{\cftparfillskip}
\renewcommand*{\cftchapterformatpnum}[1]{%
    \cftchapterformatpnumhook{#1}%
    \nolinebreak[4]\hspace*{1em}\hbox to \@pnumwidth{{\cftchapterpagefont #1}\hfill}%
}

\renewcommand{\cftsectionleader}{}
\renewcommand{\cftsectionafterpnum}{\cftparfillskip}
\renewcommand*{\cftsectionformatpnum}[1]{%
    \cftsectionformatpnumhook{#1}%
    \nolinebreak[4]\hspace*{1em}\hbox to \@pnumwidth{{\cftsectionpagefont #1}\hfill}%
}
\renewcommand{\cfttableleader}{}
\renewcommand{\cftfigureleader}{}
\renewcommand{\cfttableafterpnum}{\cftparfillskip}
\renewcommand{\cftfigureafterpnum}{\cftparfillskip}
\makeatother

\begin{document}

\frontmatter
\tableofcontents*
\listoftables
\listoffigures

\mainmatter
\chapter{Chapter}

\begin{table}
\framebox{TABLE}
\caption{Table}
\label{table1}
\end{table}

\section{Section}

\begin{figure}
\framebox{FIGURE}
\caption{Figure}
\label{figure1}
\end{figure}

\chapter{Chapter}

\begin{table}
\framebox{TABLE}
\caption{Table}
\label{table2}
\end{table}

\section{Section}

\begin{figure}
\framebox{FIGURE}
\caption{Figure}
\label{figure2}
\end{figure}

\end{document} 

enter image description here

  • Thank you! Now I see this is one of those cftK things in the manual where you have to substitute other things for K. For others who like me have defined custom lists using \newfloat, the value for K here is the first argument of \newfloat. E.g., for a list of examples made by \newfloat[chapter]{example}{loe}{\examplename} then you need \renewcommand{\cftexampleleader}{}. – musarithmia Mar 30 '15 at 20:54
  • @AndrewCashner Happy to help. And yes, you're right about the meaning of K ;-) – karlkoeller Mar 30 '15 at 21:25

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.