First post and certainly a tyro at LaTeX. Thanks to all those who have made this site such a helpful resource.

I'm using the memoir class to typeset a novel, and would like to have the Table of Contents page numbers appear ragged right, each page number set a fixed horizontal distance from the end of each chapter title, regardless of chapter title length. I would like to be able to try different spacings to find the most pleasing horizontal gap between the end of chapter title lines and the page numbers.

Any solutions or pointers greatly appreciated.

-
Welcome to TeX.sx! You don't have to sign with your name since it automatically appears in the lower right corner of your post. –  Werner Apr 23 '12 at 21:34

Change the family of commands \cftXleader \cftXafterpnum as shown below:

\documentclass{memoir}

\renewcommand{\cftchapterafterpnum}{\cftparfillskip}
\renewcommand{\cftsectionafterpnum}{\cftparfillskip}

\begin{document}

\tableofcontents
\chapter{Test Chapter}
\section{Test Section}

\end{document}


To control the distance you could define auxiliary lengths to be used as the box width used by \cftXformatpnum to format the page number:

\documentclass{memoir}

\newlength\chaplength
\newlength\seclength
\setlength\chaplength{7em}
\setlength\seclength{2em}

\renewcommand{\cftchapterafterpnum}{\cftparfillskip}
\renewcommand*{\cftchapterformatpnum}[1]{%
\hbox to \chaplength{\hfill{\cftchapterpagefont #1}}}

\renewcommand{\cftsectionafterpnum}{\cftparfillskip}
\renewcommand*{\cftsectionformatpnum}[1]{%
\hbox to \seclength{\hfill{\cftsectionpagefont #1}}}

\begin{document}

\tableofcontents
\chapter{Test Chapter}
\section{Test Section}

\end{document}


-