1

I'm using memoir class and want to create ToC that:

  1. Using em dash (instead of default dot leaders) between TOC item and page number.
  2. This style should apply to both part and chapter name.
  3. Only the part name using bold font.
  4. Add vertical space between each part group.

like this one:

TOC style that I want to create

\documentclass[12pt,twoside]{memoir}
\usepackage[paperwidth=140mm,paperheight=210mm,margin=20mm]{geometry}
\usepackage{libertine}
\chapterstyle{dash}
\usepackage{lipsum}

\begin{document}

\tableofcontents
\newpage

% Part 1
\part{Title of part 1 goes here}
\chapter[Title of chapter 1]{Title of chapter 1} \chaptermark{Title of chapter 1} % Chapter 1
\lipsum[1-2]
\newpage
\chapter[Just another chapter]{Just another chapter} \chaptermark{Just another chapter} % Chapter 2
\lipsum[1-2]
\newpage
\chapter[Yes, keep up writing]{Yes, keep up writing} \chaptermark{Yes, keep up writing} % Chapter 3
\lipsum[1-2]
\newpage

% Part 2
\part{Just another part}
\chapter[Another part, another chapter]{Another part, another chapter} \chaptermark{Another part, another chapter} % Chapter 4
\lipsum[1-2]
\newpage
\chapter[Another chapter goes here]{Another chapter goes here} \chaptermark{Another chapter goes here} % Chapter 5
\lipsum[1-2]
\newpage

% ...and so on...

\end{document}
  • Thank you, Hupfer. It's great to be here. I'm a novice to LaTeX. – Eko san Sep 16 '14 at 6:48
0

The following is taken directly from the memoir basic user manual; specifically section 9.2.2 Typesetting the entries on the class ToC methods:

enter image description here

\documentclass[12pt,twoside]{memoir}
\usepackage[paperwidth=140mm,paperheight=210mm,margin=20mm]{geometry}
\usepackage{libertine}
\chapterstyle{dash}
\usepackage{lipsum}

% Redefinitions of \part-entry in ToC
\renewcommand{\cftpartname}{Part~}
\renewcommand{\cftpartaftersnum}{:}
\renewcommand{\cftpartleader}{---}
\renewcommand{\cftpartformatpnum}[1]{%
  \cftpartformatpnumhook{#1}%
  {\cftpartpagefont #1}}
\renewcommand{\cftpartafterpnum}{\hfill\null}

% Redefinition of \chapter-entry in ToC
\renewcommand{\cftchaptername}{Chapter~}
\renewcommand{\cftchapteraftersnum}{:}
\renewcommand{\cftchapterleader}{---}
\let\oldcftchapterfont\cftchapterfont
\renewcommand{\cftchapterfont}{\oldcftchapterfont\mdseries}
\renewcommand{\cftchapterformatpnum}[1]{%
  \cftchapterformatpnumhook{#1}%
  {\cftchapterpagefont #1}}
\let\oldcftchapterpagefont\cftchapterpagefont
\renewcommand{\cftchapterpagefont}{\oldcftchapterpagefont\mdseries}
\renewcommand{\cftchapterafterpnum}{\hfill\null}

\begin{document}

\tableofcontents
\newpage

% Part 1
\part{Title of part 1 goes here}
\chapter{Title of chapter 1}% Chapter 1
\lipsum[1-2]

\chapter{Just another chapter}% Chapter 2
\lipsum[1-2]

\chapter{Yes, keep up writing}% Chapter 3
\lipsum[1-2]

% Part 2
\part{Just another part}
\chapter{Another part, another chapter}% Chapter 4
\lipsum[1-2]

\chapter{Another chapter goes here}% Chapter 5
\lipsum[1-2]

% ...and so on...

\end{document}

Specific to your requirements (where X denotes either part or chapter):

  1. Set \cftpartleader to ---;

  2. Set \cftchapterleader to ---;

  3. Remove the \bfseries from \cftchapterfont by saving it (via \let) as \oldcftchapterfont and appending \mdseries to it. This also holds for the page number font \cftchapterpagefont.

  4. The default is to insert a vertical skip before every \part in the ToC.

Some additional steps were added:

  1. Precede each entry with its name (Part or Chapter);

  2. Change the component after the sectional unit number (\cftXaftersnum) to be a colon :;

  3. Update each entry to end with \hfill\null, thereby avoiding underfull \hboxes, since every entry in the ToC is set in a box of fixed width.

  • You might be interested in adding \setlength{\cftbeforechapterskip}{0pt} to remove the space before every \chapter setting. – Werner Sep 16 '14 at 5:51
  • May I ask another questions, please? – Eko san Sep 16 '14 at 8:28
  • (1) How to adjust font size of the Part Name; – Eko san Sep 16 '14 at 8:30
  • (2) How to change font attribute of the Part name to normal (instead of bold); – Eko san Sep 16 '14 at 8:30
  • (3) How to start the Part or Chapter number to greater number, let's say Part number 30, and Chapter number 100. PS: I have 583 chapters in 61 parts. I want to see how it looks like before jumping into real code. Thank you. – Eko san Sep 16 '14 at 8:33

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.