4

Using book class, is it possible (if I'm not wrong, not with tocloft) to put page numbers in the left side? It would be something as

  5       Introduction
 19     I Title first chapter
 54    II Title second chapter
107   III Title third chapter

I considered the following tread: Page number before Chapter title in the Table of Contents with memoir, which however is only for memoir class, and the following one: Formatting the title of the TOC, which however is a mixed question about index and particular format. I need "only" to produce the above format for a classical ToC.

=====================================================

Addendum Here a working code, but only for chapter, not for section:

\documentclass[a4paper]{book} \usepackage{fontspec}
\usepackage{polyglossia} \setmainlanguage{english}
\usepackage{titletoc} \contentsmargin{0pt}
\titlecontents{chapter}[4pc]
{\contentsmargin{0pt}\makebox[0pt][r]{\thecontentspage
\quad\makebox[30pt][r]{\textsc{\romannumeral
\thecontentslabel\quad}}}} {} {} {}

\begin{document} \tableofcontents

\chapter{Some text some text some text some text some text }

\chapter{Some text some text some text some text some text }

\chapter{Some text some text some text some text some text }

\end{document}

=====================================================

ADDENDUM 2

Consider this code, whose realization I'm strongly interested in

\documentclass[a4paper]{report} \usepackage{fontspec}
\usepackage{polyglossia} \setmainlanguage{english}%{italian}
%\PolyglossiaSetup{italian}{indentfirst=false}

\usepackage{titlesec}
\renewcommand{\thechapter}{\scshape\roman{chapter}}
\titleformat{\chapter}[display]  
{\normalfont\fontsize{10pt}{12pt}\selectfont}{\scshape\thechapter}{0pt}{}
%%{\normalfont\fontsize{10pt}{12pt}\selectfont}{\chaptertitlename\space
\thechapter}{11pt}{} \renewcommand{\thesection}{\arabic{section}}
\titleformat{\section}  
{\normalfont\fontsize{10pt}{12pt}\selectfont}{\thesection}{0pt}{}
\titleformat{\subsection}  
{\normalfont\fontsize{10pt}{12pt}\selectfont\itshape}{}{0pt}{}
\titlespacing{\chapter}{0pt}{0pt}{3cm}

\usepackage{titletoc} \contentsmargin{0pt}
\titlecontents{chapter}[4pc]
{\contentsmargin{0pt}\makebox[0pt][r]{\thecontentspage}
\quad\makebox[30pt][r]{\textsc{\romannumeral
\thecontentslabel.\quad}}}} {} {} {}

\usepackage{titletoc} \contentsmargin{0pt}
\titlecontents{section}[4pc]
{\contentsmargin{0pt}\makebox[0pt][r]{\thecontentspage}
\quad\makebox[30pt][r]{\textsc{\romannumeral
\thecontentslabel.\quad}}}} {} {} {}

\begin{document} \tableofcontents

\chapter{Some title 1} Some text some text some text some text some
text

%\section{Some text title a} %Some text some text some text some text
some text

\chapter{Some title 2} Some text some text some text some text some
text

\chapter{Some title 3} Some text some text some text some text some
text

\end{document}

There is a bad interference between titlesec and titletoc, but I'm not able to solve with a correct interaction between these two packages...

  • How do you plan on handling \sections in the ToC or other lower-level sectioning commands? – Werner Mar 20 '14 at 19:10
  • mmm good question... if I've got only chapters, there is no problem. Maybe sections would be inserted in ToC too. Again, if I work with article class, I had to produce the same result only for sections – user41063 Mar 20 '14 at 19:28
  • It differs greatly whether you want to insert \sections into the ToC in book. If not (with something like \setcounter{tocdepth}{0}), then an alteration to \l@chapter (which is unique in a way) would suffice. So be specific. – Werner Mar 20 '14 at 19:32
  • Yes, usually, in book I insert sections too. So it would be useful to have both in ToC – user41063 Mar 20 '14 at 19:36
8

Here's a solution that uses the titletoc package; the important part of the code is

% chapter formatting in toc
\titlecontents{chapter}
[0.0cm]             % left margin
{}                  % above code
{%                  % numbered format
{\llap{\thecontentspage\hspace{.5cm}}\thecontentslabel~}%
}%
{}         % unnumbered format
{}         % filler-page-format, e.g dots

screenshot

Here's a complete MWE to play with.

% arara: pdflatex
% arara: pdflatex
\documentclass{book}
\usepackage{lipsum}
\usepackage{titlesec}
\usepackage{titletoc}

% chapter formatting in toc
\titlecontents{chapter}
[0.0cm]             % left margin
{}                  % above code
{%                  % numbered format
{\llap{\thecontentspage\hspace{.5cm}}\thecontentslabel~}%
}%
{}         % unnumbered format
{}         % filler-page-format, e.g dots

\begin{document}
\tableofcontents

\chapter{mychapter} 
\section{mysection}
\subsection{mysubsection}
\section{mysection}
\subsection{mysubsection}
\subsection{mysubsection}
\subsection{mysubsection}
\subsection{mysubsection}
\subsection{mysubsection}
\chapter{mychapter} 
\section{mysection}
\subsection{mysubsection}
\section{mysection}
\subsection{mysubsection}
\subsection{mysubsection}
\subsection{mysubsection}
\subsection{mysubsection}
\subsection{mysubsection}
\chapter{mychapter} 
\end{document}
  • It seems that nobody upvotes good answers today ;-) – karlkoeller Mar 20 '14 at 19:58
  • Sorry, I don't understand cmhughes solution, for the page numbers are not on the left, as I asked... – user41063 Mar 20 '14 at 20:14
  • @user41063 I don't understand- in my example the 3, 5, 7 are the page numbers, and are on the left, as you asked for – cmhughes Mar 20 '14 at 21:40
  • Oh yes, u're right! But it's like the code I posted above. The interesting thing would be to have sections too similar to chapters (on the contrary, I'm not interested in having subsection in ToC) – user41063 Mar 20 '14 at 22:02
  • @user41063 so couldn't you simply copy the code I have posted for chapter and change it to section? to ditch the subsection, use \setcounter{tocdepth}{1} – cmhughes Mar 20 '14 at 23:38

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.