2

I have a problem with my ToC. If a Chapter title is as long as the width of the TOC, then the page number is forced into the next line. However, the page number is not aligned on the right hand side but on the left. I would like the page number to be in all cases on the right. May be there is a way to set this. I am using the titletoc package.

enter image description here

That is my code

\documentclass[twoside,openany,10pt]{book}  
\usepackage[paperwidth=5in, paperheight=8in, bindingoffset=0.375in, top=0.7in, bottom=0.7in, left=0.5in, right=0.5in]{geometry}
\renewcommand{\baselinestretch}{1.3}
\usepackage{titlesec}
\usepackage {setspace}
\usepackage{librebaskerville}
\usepackage[T1]{fontenc}
\usepackage{anyfontsize}
\usepackage{letterspace}
\usepackage{fancyhdr}
\usepackage{titletoc}%
\usepackage{graphicx}
\usepackage{float}
\usepackage[overload]{textcase}
\usepackage{microtype}
\usepackage[symbol]{footmisc}
\usepackage{enumerate}


\renewcommand{\thefootnote}{\fnsymbol{footnote}}




\titlecontents{chapter}% <section-type>
  [2.3em]% <left>
  {\small}% <above-code>
  {\hspace*{-2.3em}\makebox[2.3em][l]{\thecontentslabel. }}% <numbered-entry-format>
  {}% <numberless-entry-format>
  {\hfill\contentspage}% <filler-page-format>




%Begin Document
\begin{document} 

\pagestyle{empty}
\tableofcontents                        % Print table of contents
\thispagestyle{empty}

%\newcommand{\chaptertolists}{}


%HERE BEGINS TEXT EDITING


\mainmatter                             % only in book class (arabic page #s)    
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{
\markboth{Thought Vibration} {#1}}
\fancyhead[CO]{\small \itshape \rightmark}
\fancyhead[CE]{\small \itshape \leftmark}
\fancyhead[RE,LO]{}
\fancyhead[LE,RO]{}
\fancyfoot[CO, CE]{\small \thepage}



\titleformat{\chapter}[display]
  {\normalfont\huge\bfseries\centering}{\lsstyle\MakeUppercase{\chaptertitlename} \thechapter}{20pt}{\normalfont\LARGE\itshape}
  \titlespacing*{\chapter}{0pt}{30pt}{20pt}

\pagenumbering{arabic}

%ONLY FOR COLLECTIONS
%\addtocontents{toc}{\protect\thispagestyle{empty}}
%\addcontentsline{toc}{part}{The Science of Getting Rich}
%\part*{The Science of Getting Rich}

\addtocontents{toc}{\protect\thispagestyle{empty}}
\addcontentsline{toc}{chapter}{Preface}
\markboth{Thought Vibration} {Preface}
\chapter*{Preface}

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco

\addtocontents{toc}{\protect\thispagestyle{empty}}
\addcontentsline{toc}{chapter}{Foreword}
\markboth{Thought Vibration} {Foreword}
\chapter*{Foreword}

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco

\addtocontents{toc}{\protect\thispagestyle{empty}}
\addcontentsline{toc}{chapter}{My Working Creed}
\markboth{Thought Vibration} {My Working Creed}
\chapter*{My Working Creed}

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco

\chapter{The Law Of Attraction In The Thought World} 

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco

\chapter{Thought‐Waves And Their Process Of Reproduction} 

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco

\end{document}

Thanks in advance. :)

1

You should use \hangindent in the above code. I've made the change to your \titlecontents (remember to delete old toc and double run it):

\titlecontents{chapter}
  [3.3em]
  {\small\hangindent2.3em}% <- Change made here
  {\makebox[2.3em][l]{\thecontentslabel.}}
  {}% 
  {\hfill\contentspage}

This compiles to the following:

changed contents

If possible, you can also use the \chapter command to shorten the text displayed in the toc using the following syntax:

\chapter{short version}{long version}

so that \chapter{The Laws Of Attraction}{The Law Of Attraction In The Thought World}

which compiles to the following:

using chapter

Hope this helps.

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.