Text Formattingdot points in the table of contents

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
qisufeqo
Posts: 1
Joined: Tue Feb 09, 2021 10:20 am

dot points in the table of contents

Post by qisufeqo »

Hello,
i want all table of contents are dotted
(Abstract ,Acknowledgements,Table of Contents, List of Figures,
List of Tables should be dotted)

Code: Select all

\documentclass[12pt]{report}
    \usepackage[utf8]{inputenc}
    \usepackage[titles]{tocloft}
    \newlength\mylength
    \renewcommand\cftchappresnum{\chaptername~}
    \renewcommand\cftchapaftersnum{:}
    \settowidth\mylength{\cftchappresnum\cftchapaftersnum\quad}
    \addtolength\cftchapnumwidth{\mylength}
      \renewcommand*{\contentsname}{Table of Contents}
    \begin{document}
    \pagenumbering{roman}
    \chapter*{Abstract}
    \addcontentsline{toc}{chapter}{Abstract}
      \chapter*{Acknowledgements}
    \addcontentsline{toc}{chapter}{Acknowledgements}
    \tableofcontents
    \addcontentsline{toc}{chapter}{Table of Contents}
    \newpage
    \addcontentsline{toc}{chapter}{List of Figures}
    \listoffigures
    \newpage
    \addcontentsline{toc}{chapter}{List of Tables}
    \listoftables
    \newpage
    \pagenumbering{arabic}
    \chapter{Introduction}
      \section{Section one}
      \chapter{Second Chapter}
      \section{Another section}
      \end{document}
resource where a list of only new porn sites is compiled where content is regularly updated https://newpornsites.pro

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

Bartman
Posts: 369
Joined: Fri Jan 03, 2020 2:39 pm

dot points in the table of contents

Post by Bartman »

Code: Select all

\documentclass[12pt]{report}
%\usepackage[utf8]{inputenc}% issue 28 in ltnews
\usepackage[english]{babel}% added
\usepackage[titles]{tocloft}
\usepackage{tocbibind}% added

\newlength{\mylength}
\renewcommand{\cftchappresnum}{\chaptername~}
\renewcommand{\cftchapaftersnum}{:}
\settowidth{\mylength}{\cftchappresnum\cftchapaftersnum\quad}
\addtolength{\cftchapnumwidth}{\mylength}
        
% necessary because of babel
\addto\captionsenglish{%
    \renewcommand*{\contentsname}{Table of Contents}%
}

\newcommand{\setchapleaders}[1]{
    \addtocontents{toc}{%
        \protect\renewcommand{\protect\cftchapdotsep}{#1}% set chapter leaders
    }
}

\begin{document}
\setchapleaders{\cftdotsep}% set dotted chapter leaders
\pagenumbering{roman}
\addcontentsline{toc}{chapter}{\abstractname}
\chapter*{\abstractname}
\clearpage
\addcontentsline{toc}{chapter}{Acknowledgements}
\chapter*{Acknowledgements}
\tableofcontents
\listoffigures
\listoftables
\setchapleaders{\cftnodots}% reset chapter leaders
\clearpage
\pagenumbering{arabic}
\chapter{Introduction}
\section{Section one}
\chapter{Second Chapter}
\section{Another section}
\end{document}
Peter Wilson's answer made my answer possible.
Post Reply