In my tex file I have changed the chapter name from 'Chapter' to 'Day', using:
\renewcommand \chaptername {Day}
But when I generate a table of contents it only shows '1' and not 'Day 1'. How do I get the 'Day' to show up in the contents?
In my tex file I have changed the chapter name from 'Chapter' to 'Day', using:
\renewcommand \chaptername {Day}
But when I generate a table of contents it only shows '1' and not 'Day 1'. How do I get the 'Day' to show up in the contents?
I recommend using the tocloft package, although I suspect the titletoc package could also be used quite easily. tocloft provides many hooks for content to be inserted into the table of contents.
Here's an example:
\documentclass{book}
\usepackage{tocloft,calc}
\renewcommand\chaptername{Day}
\renewcommand\cftchappresnum{\chaptername\space}
\setlength{\cftchapnumwidth}{\widthof{\textbf{Day~999~}}}
\begin{document}
\tableofcontents
\setcounter{chapter}{500}
\chapter{Hello}
\end{document}
In this case \cftchappresnum inserts its argument in the chap entry, pre (before) the snum (sectioning number).
As mentioned by Juan (thanks!), it's also necessary to increase the size of the space allocated for the "chapter number". In this case we calculate how large Day 999 would be (using the calc package) and use that length.
Woo, answering my own question!
I probably should have mentioned it was Memoir class in the first place. Anyway, after some investigating, I worked out that I had to add the line:
\renewcommand*{\cftchaptername}{Day\space}
Which did it for me.
If you use {polyglossia}, you would change the chaptername with
\usepackage{polyglossia}
\setdefaultlanguage{english}
\addto\captionsenglish{%
\renewcommand\chaptername{%
Day}}
(also works for german, replacing the corresponding strings... respectively)
\setlength{\cftchapnumwidth}{1.4cm}to increase the space available to typeset “Day n”. – Juan A. Navarro Sep 23 '10 at 11:45:)– Will Robertson Sep 23 '10 at 11:50! LaTeX Error: \cftchappresnum undefined.
– whoiscraig Sep 23 '10 at 23:41titleoption along withtocloftpackage if I want to use my custom title. Anyway, thank you for this solution. – meisyal Nov 22 '16 at 16:46