Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I've seen in some novel that, in the table of contents, the page number is before the chapter title, for example:

3    Down the Rabbit Hole
7    The Pool of Tears
15   The Caucus Race and a Long Tale

How can I obtain the same using memoir class?

share|improve this question
    
This post: Formatting the title of the TOC is not related to memoir, but it might be a good starting point. –  mvarela May 13 '12 at 6:26
1  
@mvarela: Welcome to TeX.sx! I converted your answer to a comment because links to other answers do not qualify as answers themselves. Unfortunately you can't post comments to other peoples questions as long you don't have 50rep. –  Martin Scharrer May 13 '12 at 7:48
add comment

1 Answer

You can achieve the desired result in many ways. Below there's one such possibility; I assumed the sectional unit used was \chapter:

\documentclass{memoir}

% redefinition for the ToC title
\renewcommand\printtoctitle[1]{\HUGE\sffamily#1}

% redefinitions for chapter entries
\renewcommand\chapternumberline[1]{}
\renewcommand\cftchapterfont{\sffamily}
\renewcommand\cftchapterpagefont{\huge\sffamily}

\makeatletter
\newcommand\l@mychap[3]{%
  \vskip2ex%
  \par\noindent
  \parbox{2.5em}{%
    \hfill{\cftchapterpagefont#2}%
  }\hspace*{3em}%
  \parbox{\dimexpr\textwidth-5.5em-15pt\relax}{%
    \cftchapterfont#1%
  }\par%
}

\renewcommand*\l@chapter[2]{%
  \l@mychap{#1}{#2}{\chaptername}%
}
\makeatother

\begin{document}

\tableofcontents*

\chapter{Down the Rabbit Hole}
\chapter{The Pool of Tears}
\chapter{The Caucus Race and a Long Tale}
\setcounter{page}{14}% just for the example

\end{document}

enter image description here

The code above will align the page numbers to the right; to get them aligned to the left, \l@mychap must be defined using something like

\newcommand\l@mychap[3]{%
  \vskip2ex%
  \par\noindent
  \parbox{4.5em}{%
    {\cftchapterpagefont#2}\hfill%
  }%
  \parbox{\dimexpr\textwidth-4.5em-15pt\relax}{%
    \cftchapterfont#1%
  }\par%
}

Using this redefinition (in the full example code above) instead of the initial one, one obtains

enter image description here

share|improve this answer
    
How is it possible to extend the left position of number to section pages too? thanx! –  user41063 Mar 13 at 23:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.