4

I am trying to typeset a book in LaTeX, but I'm having trouble formatting my table of contents. I've been able to center my title and chapter numbers successfully, but I can't figure out how to center the chapter titles and the pages on which chapters start.

This code reproduces the problem:

\documentclass{scrbook}
\usepackage{titletoc, tocloft, lipsum, fmtcount}
\renewcommand{\thechapter}{\Numberstring{chapter}}

% Centers the table of contents title:
\renewcommand{\cfttoctitlefont}{\hfill}
\renewcommand{\cftaftertoctitle}{\hfill}

% Eliminates the space between the chapter title and the page number:
\renewcommand{\cftchapleader}{}
\renewcommand{\cftchapafterpnum}{\cftparfillskip}
\renewcommand{\cftchapfillnum}[1]{~$\cdot$~#1\cftparfillskip\par} 
% ^Puts a small dot between the chapter and the page number.

% Here's where I need help:
\renewcommand{\cftchapaftersnumb}{\\} 
% ^Puts the chapter title below the chapter number. How do I increase this space?
\renewcommand{\cftchapfont}{\centering} 
% ^Centers the chapter numbers. How do I center the chapter titles/pages?

\begin{document}
\tableofcontents
\chapter{Chapter Title}
\lipsum
\chapter{Another Chapter Title}
\lipsum
\end{document}

Here's a picture:

enter image description here

This is my first time asking a question, so let me know if my MWE is unclear or if I need to provide more information. Thanks!

  • is that answering a part from your question tex.stackexchange.com/questions/107281/… – Ahmed Sokar Aug 6 '16 at 0:22
  • @AhmedSokar: Not quite! Sectsty isn't compatible with KOMA-Script, and the solution in that question only centers chapter titles in the body of the document. I'm trying to center chapter titles in the table of contents. Thank you for the suggestion, though! – Joshua Hoeflich Aug 6 '16 at 1:04
  • 3
    titletoc and tocloft are incompatible with KOMA-script as well. – Johannes_B Aug 6 '16 at 5:02
  • 2
    sigh: KOMA, titletoc and tocloft ... oh my -- use one of them, but not all of them!!!!! – user31729 Aug 6 '16 at 10:07
2

I found a solution! Huzzah!

As Christian Hupfer and Johannes_B pointed out in the comments, combining scrbook with tocloft and titletoc was a terrible idea; as such, I abandoned my original approach completely and switched my document class to memoir. I suspect such radical revision to solve a single problem is akin to nuking fleas, so I'll leave this question open because there's probably a more elegant solution.

Anyway, here's what I came up with:

\documentclass{memoir}
\let\ordinal\relax
\usepackage{fmtcount}
    \renewcommand{\thechapter}{\Numberstring{chapter}}
\renewcommand{\cftchapterleader}{}
\renewcommand{\cftchapterfillnum}[1]{~$\cdot$~#1\cftparfillskip\par}
\renewcommand*{\cftchapterfont}{}

% This code centers the table of contents title.
\renewcommand*{\printtoctitle}[1]{\centering#1} 

% This code centers the rest of my table of contents. Huzzah!
\setrmarg{0em}
\setlength\cftchapternumwidth{0pt}
\renewcommand\chapternumberline[1]{\hfil#1\hfil\strut\par\nopagebreak\hfil}

\setlength{\cftbeforechapterskip}{10pt} % Controls distance between TOC entries.

\linespread{1.25}\selectfont % Controls line-spacing in the whole document. 

\begin{document}
\tableofcontents*
\chapter{Title}
\chapter{Another Title}
\end{document}

Thanks for the help, everyone!

| improve this answer | |
  • 1
    As the unbiased original author of memoir I think that your answer is just the right thing. – Peter Wilson Aug 7 '16 at 17:55

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.