Text FormattingError in ToC

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
navega
Posts: 1
Joined: Fri Apr 15, 2022 12:42 am

Error in ToC

Post by navega »

Hi everyone
I get these two messages:

"Overfull \hbox (2.736pt too wide) detected"
"Overfull \hbox (7.41652pt too wide) detected"

in the toc file generate by this code:

Code: Select all

\documentclass{report}

\usepackage[utf8]{inputenc}

%\usepackage{hyperref} % if you want it

\usepackage{lipsum} % just for dummy text

% uncomment the following line if using hyperref
%\renewcommand{\theHchapter}{\arabic{chapter}\thechapter}

\begin{document}
	
	\renewcommand{\thechapter}{\Roman{chapter}}
	
	\chapter{Preface}
	\lipsum[1-2]
	
	\chapter{Acknowledgments}
	\lipsum[1-2]
	
	\chapter{Abbreviations}
	\lipsum[1-2]
	
	\chapter{Preface}
	\lipsum[1-2]
	
	\chapter{Acknowledgments}
	\lipsum[1-2]
	
	\chapter{Abbreviations}
	\lipsum[1-2]
	
	\chapter{Abbreviations}
	\lipsum[1-2]
	
	\chapter{Preface}
	\lipsum[1-2]
	
	\chapter{Acknowledgments}
	\lipsum[1-2]
	
	\chapter{Abbreviations}
	\lipsum[1-2]
	
	\section{Some extra special abbreviations}
	\lipsum[1-2]
	
	\subsection{Some math}
	\lipsum[1-2]
	
	\tableofcontents
	
	\renewcommand{\thechapter}{\arabic{chapter}}
	\setcounter{chapter}{0}
	
	\chapter{Introduction}
	\lipsum[1-2]
	
\end{document}

The toc file shows:

Code: Select all

\contentsline {chapter}{\numberline {I}Preface}{1}{}%
\contentsline {chapter}{\numberline {II}Acknowledgments}{2}{}%
\contentsline {chapter}{\numberline {III}Abbreviations}{3}{}%
\contentsline {chapter}{\numberline {IV}Preface}{4}{}%
\contentsline {chapter}{\numberline {V}Acknowledgments}{5}{}%
\contentsline {chapter}{\numberline {VI}Abbreviations}{6}{}%
\contentsline {chapter}{\numberline {VII}Abbreviations}{7}{}%
\contentsline {chapter}{\numberline {VIII}Preface}{8}{}%
\contentsline {chapter}{\numberline {IX}Acknowledgments}{9}{}%
\contentsline {chapter}{\numberline {X}Abbreviations}{10}{}%
\contentsline {section}{\numberline {X.1}Some extra special abbreviations}{10}{}%
\contentsline {subsection}{\numberline {X.1.1}Some math}{11}{}%
\contentsline {chapter}{\numberline {1}Introduction}{13}{}%
The erros are in line 7 and 8.

The toc in PDF shows:
toc.jpg
toc.jpg (25.86 KiB) Viewed 1478 times
The problem, as you see, is that the "VII" and "VIII" joins whith the name of the chapter

any help will be appreciate

tks in avance

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
Bartman
Posts: 366
Joined: Fri Jan 03, 2020 2:39 pm

Error in ToC

Post by Bartman »

One could have tested your example in the forum if you had marked its code.

Loading the inputenc package with this option has been outdated for years. Read more in ltnews28.

You can give the chapter number more space in a standard class by adjusting the length \cftchapnumwidth of the tocloft package.

With KOMA-Script you can leave the adaptation to the class if you use the dynnumwidth option of the \DeclareTOCStyleEntry command.
Post Reply