How do you move the beginning of the table of contents, list of figures, and list of tables further up the page? The default is to start those sections above a third of the way down the page.
[Tex/LaTex] Table of Contents, List of Figures, and List of Tables Positions
spacingtable of contents
Related Solutions
[Tex/LaTex] Header with roman and arabic numerals, list of figures integrated into table of contents
Here's some code. Note that I removed all packages that are unnecessary for the example.
\documentclass[12pt,oneside,a4paper]{article}
\usepackage[
left=40mm,
top=30mm,
right=20mm,
bottom=20mm,
headsep=12.5mm,
headheight=14.5pt, %%% 3mm is too small
heightrounded
]{geometry}
\usepackage{fancyhdr,xpatch}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0.0pt}
\fancyhf{}
\fancyhead[R]{Title of topic --- \thepage}
\makeatletter
\let\ORI@section\section
\renewcommand{\section}{\@ifstar\s@section\ORI@section}
\newcommand{\s@section}[1]{%
\ORI@section*{#1}
\csname phantomsection\endcsname % for hyperref
\addcontentsline{toc}{section}{#1}
}
\xpatchcmd{\tableofcontents}{\section}{\ORI@section}{}{} % toc not in toc
\makeatother
\begin{document}
\pagenumbering{roman}
\tableofcontents
\clearpage
\listoffigures
\clearpage
\listoftables
\clearpage
\section*{Section A}
\clearpage
\pagenumbering{arabic}
\section{Section B}
\end{document}
The code redefines \section
so that \section*
will automatically add it to the table of contents. There's only one catch: \tableofcontents
uses \section*
, so it has been patched in order to use the original version of the command.
Some points to note about your original code:
\special
is not needed, becausegeometry
takes care of it- the
headheight
you specified is too small \makebox[0pt][r]{Title of topic}
does nothing more than the simpleTitle of topic
, becausefancyhdr
uses right alignment anyway there; I also added a dash to separate the title from the page number.\onehalfspacing
is countermanded by\setstretch{1.3}
; if you can, avoid increasing the leading.
If you want to reduce the spacing between section titles, add the following line
\xpatchcmd{\l@section}{1.0em}{0.5ex}{}{}
immediately before \makeatother
in the given code. Adjust 0.5ex
to what suits you. For the image, I added two subsections in order to give the flavor.
refcount
allows you to extract page references in an expandable way. The following method uses the \label
-\ref
system to set a \label
on the first page of the LoF/LoT and then add the entries to the ToC where they are needed, expanding the page number using \getpagerefnumber
:
\documentclass{book}
\usepackage{refcount}
\begin{document}
\frontmatter
\tableofcontents
\clearpage
\label{listoffigures}
\listoffigures
\clearpage
\label{listoftables}
\listoftables
\mainmatter
\chapter{First chapter}
\chapter{Second chapter}
\chapter{Third chapter}
% Insert delayed LoF/LoT
\addtocontents{toc}{\protect\contentsline{chapter}{\listfigurename}{\getpagerefnumber{listoffigures}}}
\addtocontents{toc}{\protect\contentsline{chapter}{\listtablename}{\getpagerefnumber{listoftables}}}
\end{document}
Best Answer
Using the
tocloft
package (of course, instead of-2cm
you can use the length that best suits your needs):