I would like to have the Table of Contents of the book I am editing showing first the pages of the chapters and then the chapter titles. Something like this book:
I am working with XeTeX (through LyX) and my document class is Memoir.
I would like to have the Table of Contents of the book I am editing showing first the pages of the chapters and then the chapter titles. Something like this book:
I am working with XeTeX (through LyX) and my document class is Memoir.
Here's one possibility (chapter number for unnumbered chpaters have been included before the corresponding titles, as has been requested in a comment):
\documentclass{memoir}
\usepackage{graphicx}
\renewcommand\partnumberline[1]{}
\renewcommand\chapternumberline[1]{#1~\raisebox{.2ex}{\scalebox{0.75}{\textbullet}~}}
\renewcommand\cftpartpagefont{\huge\bfseries}
\renewcommand\cftpartfont{\LARGE\bfseries}
\renewcommand\cftchapterpagefont{\normalfont\large\itshape}
\renewcommand\cftchapterfont{\normalfont}
\newlength\ToCindent
\setlength\ToCindent{4em}
\makeatletter
\renewcommand*{\l@part}[2]{%
\ifnum \c@tocdepth >-2\relax
\cftpartbreak
\begingroup
{\leftskip0pt\noindent
\interlinepenalty\@M
\leavevmode
\parbox[t]{\ToCindent}{\makebox[2em][r]{\cftpartpagefont #2}\hfill}%
\parbox[t]{\dimexpr\textwidth-\ToCindent\relax}{\cftpartfont #1}%
}
\par\nobreak
\global\@nobreaktrue
\everypar{\global\@nobreakfalse\everypar{}}%
\endgroup
\fi}
\newcommand*{\l@mychap}[3]{%
\def\@chapapp{#3}
\vskip2ex%
\par%
\noindent\parbox[t]{\ToCindent}{\makebox[2em][r]{\cftchapterpagefont#2}\hfill}%
\parbox[t]{\dimexpr\textwidth-\ToCindent\relax}{\cftchapterfont#1}\par%
}
\renewcommand*{\l@chapter}[2]{%
\l@mychap{#1}{#2}{\chaptername}%
}
\renewcommand*{\l@appendix}[2]{%
\l@mychap{#1}{#2}{\appendixname}%
}
\makeatother
\begin{document}
\tableofcontents*
\part{A test part}
\chapter{Test chapter with a really long title spanning several lines just for the example}
\chapter{Another test chapter}
\addcontentsline{toc}{chapter}{A test unnumbered chapter}
\chapter{Another test chapter with an interesting title}
\part{Another test part}
\chapter{Test chapter with a really long title spanning several lines just for the example}
\chapter{Another test chapter}
\addcontentsline{toc}{chapter}{Another test unnumbered chapter}
\chapter{Another test chapter with an interesting title}
\part{Yet another test part}
\chapter{Test chapter with a really long title spanning several lines just for the example}
\chapter{Another test chapter}
\chapter{Another test chapter with an interesting title}
\end{document}
I add here another option showing the page number and chapter number separated by a bullet, as was originally required in the comment; I prefer the previous solution since this one might result in confusion:
\documentclass{memoir}
\usepackage{graphicx}
\renewcommand\partnumberline[1]{}
\renewcommand\chapternumberline[1]{\makebox[0pt][l]{%
\llap{\raisebox{.2ex}{\scalebox{0.75}{\textbullet}}\,#1\hspace{1.2em}}}}
\renewcommand\cftpartpagefont{\huge\bfseries}
\renewcommand\cftpartfont{\LARGE\bfseries}
\renewcommand\cftchapterpagefont{\normalfont}
\renewcommand\cftchapterfont{\normalfont}
\newlength\ToCindent
\setlength\ToCindent{4.5em}
\makeatletter
\renewcommand*{\l@part}[2]{%
\ifnum \c@tocdepth >-2\relax
\cftpartbreak
\begingroup
{\leftskip0pt\noindent
\interlinepenalty\@M
\leavevmode
\parbox[t]{\ToCindent}{\makebox[2em][r]{\cftpartpagefont #2}\hfill}%
\parbox[t]{\dimexpr\textwidth-\ToCindent\relax}{\cftpartfont #1}%
}
\par\nobreak
\global\@nobreaktrue
\everypar{\global\@nobreakfalse\everypar{}}%
\endgroup
\fi}
\newcommand*{\l@mychap}[3]{%
\def\@chapapp{#3}
\vskip2ex%
\par%
\noindent\parbox[t]{\ToCindent}{\makebox[2em][r]{\cftchapterpagefont#2}\hfill}%
\parbox[t]{\dimexpr\textwidth-\ToCindent\relax}{\cftchapterfont#1}\par%
}
\renewcommand*{\l@chapter}[2]{%
\l@mychap{#1}{#2}{\chaptername}%
}
\renewcommand*{\l@appendix}[2]{%
\l@mychap{#1}{#2}{\appendixname}%
}
\makeatother
\begin{document}
\tableofcontents*
\part{A test part}
\chapter{Test chapter with a really long title spanning several lines just for the example}
\chapter{Another test chapter}
\addcontentsline{toc}{chapter}{A test unnumbered chapter}
\chapter{Another test chapter with an interesting title}
\part{Another test part}
\chapter{Test chapter with a really long title spanning several lines just for the example}
\chapter{Another test chapter}
\addcontentsline{toc}{chapter}{Another test unnumbered chapter}
\chapter{Another test chapter with an interesting title}
\part{Yet another test part}
\chapter{Test chapter with a really long title spanning several lines just for the example}
\chapter{Another test chapter}
\chapter{Another test chapter with an interesting title}
\end{document}
The \ToCindent
length controls the separation between page numbers and titles.