1

In my LaTex paper, I need to produce such a table of contents, list of figures and list of tables, all of which have the title being centered and capitalized, and other special additions (such as inserting lines with words "Chapters", "Figure", and "Table"). My elaborations on this project so far produced this latex code (see below).

However, the only thing that does not work for me is centering the title of the table of contents, which is labelled as one word "Contents." See the picture of the pdf output file below. What should I fix in my code? For my manipulations I used two packages: titlesec and tocloft.

\documentclass[11pt]{article}
% Set the page margins as required
\usepackage[left=1.25in,right=1in,top=1in,bottom=1in]{geometry}
\usepackage{graphicx}     % Required for inserting images
\usepackage{setspace}\doublespacing % Double space 
\usepackage{endnotes}     % All notes 2b place at a separate section 'Endnotes'
\usepackage{soul}
\usepackage{afterpage}
\usepackage{mwe}
\usepackage{tikz}
\usepackage{acro}         % Acronyms/abbreviations
\include{00-Acronyms}     % List of acronyms, 2b updated
%--> acro manual: https://mirror2.sandyriver.net/pub/ctan/macros/latex/contrib/acro/acro-manual.pdf
% Managing sections
\usepackage{titlesec}     % To modify the section titles
\renewcommand\thesection{\arabic{section}} % CHAPTER 1 [New Line] TITLE
\titleformat{\section}[display]            % each chapter has two lines...
  {\normalfont\Large\filcenter}{\MakeUppercase{Chapter~\thesection}}{0pt}{}
% Capitalizing the titles of the respective sections:
\renewcommand{\notesname}{\centering \MakeUppercase{Endnotes}}
\renewcommand{\contentsname}{\centering \MakeUppercase{Contents}}
\renewcommand{\refname}{\centering \MakeUppercase{References}}
\renewcommand{\listfigurename}{\centering \MakeUppercase{List of Illustrations}}
\renewcommand{\listtablename}{\centering \MakeUppercase{List of Tables}}
\usepackage{tocloft}      % <-- ...to modify ToC, LoF, and LoT
\renewcommand{\cfttoctitlefont}{\hfill\Large} % ToC = Table of Contents
\renewcommand{\cftaftertoctitle}{\hfill}
\renewcommand{\cftloftitlefont}{\hfill\Large} % LoF = List of Figures
\renewcommand{\cftafterloftitle}{\hfill}
\renewcommand{\cftlottitlefont}{\hfill\Large} % LoT = List of Tables
\renewcommand{\cftafterlottitle}{\hfill}
\usepackage{natbib}       % Bibliography management
\bibliographystyle{apalike}
% My info
\date{October 14th, 2023}

% ----- Start of the document --------------------------------------------------
\begin{document}
% All notes to be in the separate section 'Endnotes'
\let\footnote=\endnote

% Table of Contents + making TOC not in bold font
{\let\bfseries\mdseries \tableofcontents} \newpage

% List of Figures/Illustrations
\listoffigures 
\addtocontents{lof}{{~Figure}~\hfill{Page}\par} % <- inserting a line w/"Figure"
\addcontentsline{toc}{section}{\uppercase{List of Illustrations}}
\newpage

% List of Tables
\listoftables
\addtocontents{lot}{{~Table}~\hfill{Page}\par} % <- inserting a line w/ "Table"
\addcontentsline{toc}{section}{\uppercase{List of Tables}}
\newpage 

% List of Acronyms/Abbreviations
\printacronyms[pages = {display=all,seq/use=false},
           name  = \uppercase{List of Acronyms}]
\addcontentsline{toc}{section}{\uppercase{List of Acronyms}}

%
% ... some latex code
%

\end{document}
% ----- End of the document ----------------------------------------------------

enter image description here

6
  • Use \usepackage[titles]{tocloft} Commented Oct 19, 2023 at 16:34
  • @SimonDispa thanks very much! It works.
    – Alex
    Commented Oct 19, 2023 at 17:16
  • You can add it as an answer to your question to help other readers. (And accept the answer yourself) Commented Oct 19, 2023 at 17:47
  • Like this? See below @SimonDispa
    – Alex
    Commented Oct 19, 2023 at 17:58
  • x-post stackoverflow.com/q/77325346/2777074 Commented Oct 22, 2023 at 19:15

1 Answer 1

1

The answer to my question was to change this line of the code above:

 \usepackage[titles]{tocloft} 

And it works just fine!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .