I'm trying to use the titletoc package to add the word "Chapter" only to my numbered entries in my Table of Contents. I'm using a report document class. I'm really close (I think), I just need to know how to align the numberless entries with the word "Chapter" from the numbered entries.

Here's what I've got:

\usepackage{titletoc}%
\titlecontents{chapter}% <section-type>
[0pt]% <left>
{}% <above-code>
{\bfseries}% <numberless-entry-format>
{\bfseries\hfill\contentspage}% <filler-page-format>


Which gives me:

I'd like to align those numberless chapters on the left hand side with the word "Chapter". Also, I'm receiving \hbox warnings for the page numbers with four or more characters (such as viii) and am not sure what to do about those. I'm new to LaTeX and am at a loss. I tried looking through the titletoc documentation but was unsuccessful. Thanks in advance!

EDIT: As requested, here is a MWE:

\documentclass[12pt]{report}
\usepackage[utf8]{inputenc}

\usepackage{titletoc}%
\titlecontents{chapter}% <section-type>
[0pt]% <left>
{}% <above-code>
{\bfseries}% <numberless-entry-format>
{\bfseries\hfill\contentspage}% <filler-page-format>

\usepackage{lipsum}

\usepackage{setspace}

\begin{document}

\pagenumbering{roman}
\clearpage
\setcounter{page}{2}

\chapter*{Abstract}
\lipsum[1]

\chapter*{Acknowledgements}
\lipsum[1]

\begin{doublespace}
\tableofcontents
\end{doublespace}

\pagenumbering{arabic}
%\setcounter{page}{255}  % % Uncomment to see \hbox warnings due to long TOC page number

\chapter{Introduction}
\lipsum[1]
\section{Section one}
\lipsum[1]

\chapter{Second Chapter}
\lipsum[1]
\section{Another section}
\lipsum[1]

\end{document}


Note: remove the comment to receive the \hbox warnings. Thanks again

• Welcome to TeX.SX! A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). Apr 12 '14 at 4:24
• Could you provide us with a minimal working example (MWE) so we have something to work with? Since this document seems like it will be very comprehensive (a thesis), be sure to give all details you require in terms of ToC-related packages.
– Werner
Apr 12 '14 at 5:32

You are not using \addcontentsline in the correct way.

\addcontentsline{toc}{chapter}{\numberline{}Abstract}


you have to use

\addcontentsline{toc}{chapter}{Abstract}


and the result will be good.

Also notice that \bfseries can be specified in the first mandatory argument, so not to be repeated in the others:

\titlecontents{chapter}% <section-type>
[0pt]% <left>
{\bfseries}% <above-code>
{}% <numberless-entry-format>
{\hfill\contentspage}% <filler-page-format>


MWE:

\documentclass[12pt]{report}
\usepackage[utf8]{inputenc}

\usepackage{titletoc}%
\titlecontents{chapter}% <section-type>
[0pt]% <left>
{\bfseries}% <above-code>
{}% <numberless-entry-format>
{\hfill\contentspage}% <filler-page-format>

\usepackage{lipsum}

\usepackage{setspace}

\begin{document}

\pagenumbering{roman}
\clearpage
\setcounter{page}{2}

\chapter*{Abstract}
\lipsum[1]

\chapter*{Acknowledgements}
\lipsum[1]

\begin{doublespace}
\tableofcontents
\end{doublespace}

\pagenumbering{arabic}
%\setcounter{page}{255}  % % Uncomment to see \hbox warnings due to long TOC page number

\chapter{Introduction}
\lipsum[1]
\section{Section one}
\lipsum[1]

\chapter{Second Chapter}
\lipsum[1]
\section{Another section}
\lipsum[1]

\end{document}


In regards of the Overfull \hbox warnings, I don't know a good way to solve it with titletoc, but I know a better way with tocloft, which works much better than titletoc.

So, you can replace the titletoc stuff

\usepackage{titletoc}%
\titlecontents{chapter}% <section-type>
[0pt]% <left>
{\bfseries}% <above-code>
{}% <numberless-entry-format>
{\hfill\contentspage}% <filler-page-format>


with

\usepackage[titles]{tocloft}
\newlength\mylength
\renewcommand\cftchappresnum{\chaptername~}
\renewcommand\cftchapaftersnum{:}


and the following MWE

\documentclass[12pt]{report}
\usepackage[utf8]{inputenc}

\usepackage[titles]{tocloft}
\newlength\mylength
\renewcommand\cftchappresnum{\chaptername~}
\renewcommand\cftchapaftersnum{:}

\usepackage{lipsum}

\usepackage{setspace}

\begin{document}

\pagenumbering{roman}
\clearpage
\setcounter{page}{2}

\chapter*{Abstract}
\lipsum[1]

\chapter*{Acknowledgements}
\lipsum[1]

\begin{doublespace}
\tableofcontents
\end{doublespace}

\pagenumbering{arabic}
\setcounter{page}{255}  % % Uncomment to see \hbox warnings due to long TOC page number

\chapter{Introduction}
\lipsum[1]
\section{Section one}
\lipsum[1]

\chapter{Second Chapter}
\lipsum[1]
\section{Another section}
\lipsum[1]

\end{document}


will give you the following result

The following works for me (based on your MWE), but it's a bit of a hack though.

\usepackage{titletoc}%
\titlecontents{chapter}% <section-type>
[0pt]% <left>
{}% <above-code>
{\bfseries\raggedright\hspace{-0.575\linewidth}}% <numberless-entry-format>
{\bfseries\hfill\contentspage}% <filler-page-format>


The hbox warnings look like they are caused by the page numbers being boldface for chapters (but not sections). Do you want it that way, or do you want all page numbers in the same (non-bold) font?

• Welcome to TeX.SX! Nice answer, I cannot help but feel though that your last question would be better suited in a comment to the question. Apr 12 '14 at 8:18
• Sure, but I don't have enough rep to do that. You can repost it there if you want. Apr 12 '14 at 9:00
• Ahh, sorry I tend to forget these things. Apr 12 '14 at 9:25

I realize that you are using titletoc, but I have recently had the same desire for a document that was already heavily dependent on tocloft. For the sake of documenting the solution, I have achieved the same behavior with tocloft using the following:

\let\oldcftchappresnum\cftchappresnum
\renewcommand*{\cftchappresnum}{Chapter \oldcftchappresnum} %change the chapter number to include the word "Chapter"
\setlength{\cftchapnumwidth}{6em} %Make space for the word "Chapter"... was previously set to 1.5em