I am using memoir class to create a collection of short stories, and the default space before the table of contents and chapter titles is quite large. I have seen several posts on this site that show how to remove this space for all chapters, but I want to remove it just for the table of contents, keeping it for the chapters. How would I do this?
[Tex/LaTex] How to remove spacing from before the table of contents in memoir class
memoirspacingtable of contents
Related Solutions
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}
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
If some parts of the \chapter
-like entries should be unnumbered but still appear in the ToC
, either use \frontmatter
and switch later on to \mainmatter
where appropiate or say \setcounter{secnumdepth}{-1}
as Johannes suggested.
This approach is not restricted to memoir
by the way -- any class
that supports \frontmatter
etc. will behave like this. (The counter method should work always, anyway!)
\documentclass[a4paper,oneside, 11pt, openany]{memoir}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage{txfonts}
\usepackage[utf8]{inputenc}
\usepackage{wallpaper}
\usepackage{palatino}
\setlength{\parindent}{2.5em}
\usepackage[sorting=none]{biblatex}
\addbibresource{biblio.bib}
\usepackage[inner=2.5cm,outer=2.5cm, tmargin=2.5cm, bmargin=2.5cm]{geometry}
\begin{document}
\tableofcontents*
\frontmatter
\chapter{Abstract}
\chapter{Dedication}
To...
\chapter{Declaration}
I declare that..
\chapter{Acknowledgements}
I want to thank...
\tableofcontents
\mainmatter
\chapter{Introduction}
\chapter{Methods}
\chapter{Results}
\end{document}
Best Answer
An improvement of Brent's answer might be in avoiding to look for the value of
\beforechapskip
:That value of
\beforechapskip
will be used only inside the group and will be restored to the previous one when the group ends.Notice the
*
after\tableofcontents
, that will remove the table of contents entry from the table of contents (it's unclear to me why the default is to include the entry).