Text FormattingDot after number in TOC

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Dot after number in TOC

Post by localghost »

Kaspars wrote:Can't anyone help me? Really? :?
Your example doesn't work for me and spits out a lot of errors.


Thorsten

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

Kaspars
Posts: 37
Joined: Mon Feb 14, 2011 11:51 am

Re: Dot after number in TOC

Post by Kaspars »

What errors? For me everyting works fine! :shock:
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Dot after number in TOC

Post by localghost »

Kaspars wrote:What errors? For me everyting works fine! […]
Oh, sorry. My mistake. Didn't run XeLaTeX on the code. Now I only get one error caused by the missing bibliography database file and several font related warnings.

You already use the \titlecontents command to format the ToC entries of sections and subsections. Just add a dot at the right place. Probably you will have to fiddle around a little bit.
User avatar
Kaspars
Posts: 37
Joined: Mon Feb 14, 2011 11:51 am

Dot after number in TOC

Post by Kaspars »

Ok. Thanks :) After some experiments with dot, hspace ect I found how to solve my problem. Here is the code:

Code: Select all

\titlecontents{section}
   [0.5em]
   {\vspace{1em}}
   {\hspace{-1em}.\contentslabel{0.7em}\hspace{1em}}
   {\hspace*{-1.5em}}
   {\titlerule*[1pc]{.}\contentspage}
   []

\titlecontents{subsection}
   [2.3em]
   {}
   {\hspace{0.5em}.\contentslabel{1.5em}\hspace{1em}}
   {\hspace*{-2.3em}}
   {\titlerule*[1pc]{.}\contentspage}
   []
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Dot after number in TOC

Post by localghost »

In the meantime I stumbled upon much simpler solution also based on the titletoc package.

Code: Select all

\documentclass[11pt,a4paper,english]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{geometry}
\usepackage[pagestyles,raggedright]{titlesec}
\usepackage[dotinlabels]{titletoc}
\usepackage{blindtext}

\begin{document}
  \tableofcontents

  \blinddocument
\end{document}
Post Reply