Page LayoutCentered Headings for ToC, LoF and LoT

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
CiC Limits
Posts: 2
Joined: Sun Oct 13, 2013 11:08 pm

Centered Headings for ToC, LoF and LoT

Post by CiC Limits »

I am trying to center and rename the title of my table of contents.

This is what I currently have.

Code: Select all

\chapter*{\Large\bfseries\centering ACKNOWLEDGMENTS}
\phantomsection

\newpage
\renewcommand\contentsname{\centering\Large TABLE OF CONTENTS}
\tableofcontents
I have successfully changed the size of the ToC title, but the problem is that "Acknowledgements" is centered while the ToC is not (still flushed left). I am also having the same issue with List of Figures and List of Tables

I have seen a previous post similar to what I would like to do, and was given

Code: Select all

\renewcommand{\printtoctitle}{\centering\Huge\bfseries}
\renewcommand{\contentsname}{TABLE OF CONTENTS}
Doing this, I get \printtoctitle undefined (I also tried \printcontentstitle).

I am assuming I can fix this by using this.

Code: Select all

\chapter*{\Large\bfseries\centering TABLE OF CONTENTS}
But how will i keep the functionality of the table of contents this way? Is it possible to do something along these lines?

Code: Select all

\renewcommand\contentsname{\centering\Large TABLE OF CONTENTS}
\tableofcontents  %(remove old table of contents title)
Last edited by localghost on Mon Oct 14, 2013 9:37 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

CiC Limits
Posts: 2
Joined: Sun Oct 13, 2013 11:08 pm

Centered Headings for ToC, LoF and LoT

Post by CiC Limits »

I have found my solution (for possible future reference), although still open to opinions. Not entirely sure of what \makeatletter and \makeatother do, but it works for me.

Code: Select all

\newpage
\makeatletter
\chapter*{\Large\bfseries\centering TABLE OF CONTENTS}
\phantomsection
\@starttoc{toc}
\makeatother

\newpage
\makeatletter
\renewcommand{\cftfigfont}{Figure } %to change label of '1.1' to 'Figure 1.1'
\chapter*{\Large\bfseries\centering LIST OF FIGURES}
\addcontentsline{toc}{chapter}{LIST OF FIGURES} %to have in ToC
\phantomsection
\@starttoc{lof}
\makeatother

\newpage
\makeatletter
\renewcommand{\cfttabfont}{Table } %to change label of '1.1' to 'Table 1.1'
\chapter*{\Large\bfseries\centering LIST OF TABLES}
\addcontentsline{toc}{chapter}{LIST OF TABLES} %to have in ToC
\phantomsection
\@starttoc{lot}
\makeatother
Last edited by localghost on Mon Oct 14, 2013 9:38 am, edited 1 time in total.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Centered Headings for ToC, LoF and LoT

Post by localghost »

Your method is definitely not the way to go. It violates (La)TeX's basic principal of separation of form and content. Furthermore the presented code fragments are not very helpful. A complete solution in form of a self-contained example document would be much better. Presumably you use some code from hyperref and tocloft, but you don't mention that. Hence your code, incorporated in a simple document, would fail.

It is much smarter and easier to use the titlesec package and let it format the unnumbered chapters. For corresponding ToC entries for the LoF and LoT you can use tocbibind.

Code: Select all

\documentclass[11pt]{report}
\usepackage[T1]{fontenc}
\usepackage{geometry}
\usepackage[explicit]{titlesec}
\usepackage[nottoc]{tocbibind}
\usepackage{blindtext}  % drop in actual document

\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}
{\chaptertitlename\ \thechapter}
{20pt}
{\Huge #1}

\titleformat{name=\chapter,numberless}[display]
{\normalfont\huge\filcenter\bfseries}
{}
{20pt}
{\Huge\MakeUppercase{#1}}

\begin{document}
  \tableofcontents
  \listoffigures
  \listoftables

  \chapter*{Acknowledgments}
  \addcontentsline{toc}{chapter}{Acknowledgments}
    \blindtext  % drop in actual document

  \blinddocument  % drop in actual document
\end{document}
I would not recommend to do a formatting like this because different formats for chapter headings are not consistent.


Best regards and welcome to the board
Thorsten
Post Reply