Page Layout ⇒ Center Part Headings in ToC
Center Part Headings in ToC
how can I centre \part headings in my table of contents?
Regards
Reza
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
- Stefan Kottwitz
- Site Admin
- Posts: 10348
- Joined: Mon Mar 10, 2008 9:44 pm
Re: Center Part Headings in ToC
welcome to the board!
It depends on the document class you are using. Which one is it?
Stefan
Re: Center Part Headings in ToC
Thank you for your reply. Much appreciated.
I am using \documentclass[12pt,a4paper]{report}
Regards,
Reza
- Stefan Kottwitz
- Site Admin
- Posts: 10348
- Joined: Mon Mar 10, 2008 9:44 pm
Center Part Headings in ToC
here's a quick solution. It redefines the original part TOC entry, uses \hspace*{\fill} on the left and on the right of the heading, to get it centered.
Code: Select all
\documentclass[12pt,a4paper]{report}
\makeatletter
\renewcommand*\l@part[2]{%
\ifnum \c@tocdepth >-2\relax
\addpenalty{-\@highpenalty}%
\addvspace{2.25em \@plus\p@}%
\setlength\@tempdima{3em}%
\begingroup
\parindent \z@ \rightskip \@pnumwidth
\parfillskip -\@pnumwidth
{\leavevmode
\hspace*{\fill}\centering\large\bfseries #1\hspace*{\fill}\llap{#2}}\par
\nobreak
\global\@nobreaktrue
\everypar{\global\@nobreakfalse\everypar{}}%
\endgroup
\fi}
\makeatother
\begin{document}
\tableofcontents
\part{One}
\chapter{First chapter}
\end{document}
Re: Center Part Headings in ToC
Magic. It is working. Thank you so much.
Regards,
Reza