GeneralEntries for unnumbered Chapters in ToC

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
fruitfrisje
Posts: 10
Joined: Wed Dec 05, 2012 12:26 pm

Entries for unnumbered Chapters in ToC

Post by fruitfrisje »

Hi I'm having problems by creating a table of content. If googles everything but unfortunaly no answer.
What I have is this following:

Code: Select all

\chapter*{preface}
\chapter*{summary}

\tableofcontents

\chapter{introduction}
\chapter{Literature}
The table of content gives this

Code: Select all

   Preface (inline with word introduction, 2 horizontal spaces at begin)
   Summary (inline with word introduction, 2 horizontal spaces at begin)
Table of contents
1  Introduction
2  Literature
But I would like to have it like this:

Preface
Summary
Table of contents
1 Introduction
2 Literature.

I have no idea how to horizontal space these two \chapter* (mayby with -spacing)??

Any suggestions?

Code: Select all

\documentclass[11pt, a4paper, twoside]{report}
\usepackage{graphicx}							%Importing figures
\usepackage{qtree}								%Importing tree structure
\usepackage{amsmath}							%Importing equations
\usepackage{geometry}							%Adjusting page margins
\usepackage{anysize}							%Creating custom page margins
\usepackage{xcolor,adjustbox}					%Creating colorbox,adjustbox
\usepackage{eso-pic}							%Creating backgroundpicture
\usepackage{fancyhdr}							%Creating customize Header
\marginsize {3.5 cm}{3.5 cm}{3 cm}{3 cm} 		%Margins {Left}{Right}{Top}{Bottom}

%----------------------------------------------------------------------------------------
%	BACKGROUNDPICTURE ON THE COVERPAGE
%----------------------------------------------------------------------------------------
\graphicspath{{./Coverpage/CoverpageFig/}}
\newcommand\BackgroundPic{
\put(-3.7,3.0){
\parbox[b][\paperheight]{\paperwidth}{%
\vfill
\centering
\includegraphics[width=\paperwidth,height=\paperheight,
keepaspectratio]{cover.png}%
}}}


\begin{document}
%----------------------------------------------------------------------------------------
%	COVERPAGE
%----------------------------------------------------------------------------------------
\AddToShipoutPicture*{\BackgroundPic}
\newgeometry{left=0cm, right=0cm, top=5.5cm,bottom=0cm}
\include{./coverpage/coverpage}
\restoregeometry
\newpage
\thispagestyle{empty}
\mbox{}

%----------------------------------------------------------------------------------------
%	TITLEPAGE
%----------------------------------------------------------------------------------------
\newgeometry{left=1cm, right=1cm}
\include{./Titlepage/titlepage}
\restoregeometry
\newpage
\thispagestyle{empty}
\mbox{}

%----------------------------------------------------------------------------------------
%	PREFACE
%----------------------------------------------------------------------------------------
\pagenumbering{roman}
\include{./Preface/preface}
\newpage
\thispagestyle{empty}
\mbox{}

%----------------------------------------------------------------------------------------
%	SUMMARY
%----------------------------------------------------------------------------------------
\include{./Summary/summary}
\newpage
\thispagestyle{empty}
\mbox{}

%----------------------------------------------------------------------------------------
%	TABLE OF CONTENT/LIST OF FIGURE/LIST OF TABLES
%----------------------------------------------------------------------------------------
\setcounter{tocdepth}{2}
\tableofcontents										%Creates a table of content
	\newpage
	\thispagestyle{empty}
	\mbox{}
\listoffigures											%Creates a list of figures
\addcontentsline{toc}{chapter}{\listfigurename}			%Add List of figures to TOC
	\newpage
	\thispagestyle{empty}
	\mbox{}
\listoftables											%Creates a list of tables
\addcontentsline{toc}{chapter}{\listtablename}			%Add List of tables to TOC
	\newpage
	\thispagestyle{empty}
	\mbox{}
\clearpage												%Clear page, start renumb. page

%----------------------------------------------------------------------------------------
%	INTRODUCTION
%----------------------------------------------------------------------------------------
\fancyhead{} % clear all header fields
\fancyhead[LE,RO]{\nouppercase {\leftmark}}

\pagestyle{fancy}
\pagenumbering{arabic}
\include{./Introduction/introduction}
\newpage
\thispagestyle{empty}
\mbox{}

%----------------------------------------------------------------------------------------
%	LITERATURE
%----------------------------------------------------------------------------------------
\include{./literature/literature}
\newpage
\thispagestyle{empty}
\mbox{}

%----------------------------------------------------------------------------------------
%	CONCLUSION
%----------------------------------------------------------------------------------------
\include{./Conclusion/conclusion}

%----------------------------------------------------------------------------------------
%	APPENDIXES
%----------------------------------------------------------------------------------------
\include{./appendix/appendixA}
\include{./appendix/appendixB}

\end{document}
Second question is that after creating for the first time the table of contents it now will not update. After adding \section in the text this won't show of in the table of content
Last edited by fruitfrisje on Wed Dec 05, 2012 1:52 pm, edited 4 times 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

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Entries for unnumbered Chapters in ToC

Post by Stefan Kottwitz »

Hi,

welcome to the board!

Take care of proper capitalization of commands. For example, the \chapter and \chapter* commands are completely written in lowercase.

Perhaps provide a Infominimal working example, so we can see your document class and the settings in your preamble.

Stefan
LaTeX.org admin
fruitfrisje
Posts: 10
Joined: Wed Dec 05, 2012 12:26 pm

Re: Entries for unnumbered Chapters in ToC

Post by fruitfrisje »

Hopefully this "minimum example"is OK
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Entries for unnumbered Chapters in ToC

Post by Stefan Kottwitz »

Thanks for editing and adding the example. However, it's not minimal: appendixes, literature, cover page and many more is not relevant here. And it's not compilable, since all included files are missing.

I suggest, take some time to post a compilable but reduced example, then you can expect that readers take some time to help to fix the problem.

Have a look here to learn why and how: There are pages and whole web sites about this issue, you see it's important to get help.

I simply cannot help you yet even if I would fix the long and not compilable example above: there are no preface and summary commands, no \chapter*{Preface} etc. It's in your included files which you did not post. Furthermore, \chapter* is not relevant, since it doesn't write anything to the table of contents file. \addcontentsline or \addtocontents in your file preface.tex is probably responsible.

Stefan
LaTeX.org admin
fruitfrisje
Posts: 10
Joined: Wed Dec 05, 2012 12:26 pm

Entries for unnumbered Chapters in ToC

Post by fruitfrisje »

Hope this code is a good working example. Just erased the unnecessary stuff

Code: Select all


\documentclass[11pt, a4paper, twoside]{report}
\usepackage{graphicx}							%Importing figures

\begin{document}
%----------------------------------------------------------------------------------------
%	PREFACE
%----------------------------------------------------------------------------------------
\chapter*{Preface}
\markboth{PREFACE}{preface}
\addcontentsline{toc}{chapter}{\protect\numberline{}Preface}
blablablablablabla\\
blablablablablabla\\
blablablablablabla\\

%----------------------------------------------------------------------------------------
%	SUMMARY
%----------------------------------------------------------------------------------------
\chapter*{Summary}
\markboth{SUMMARY}{Summary}
\addcontentsline{toc}{chapter}{\protect\numberline{}Summary}
blablablablablabla\\
blablablablablabla\\
blablablablablabla\\

%----------------------------------------------------------------------------------------
%	TABLE OF CONTENT/LIST OF FIGURE/LIST OF TABLES
%----------------------------------------------------------------------------------------
\setcounter{tocdepth}{2}
\tableofcontents										%Creates a table of content
\listoffigures											%Creates a list of figures
\addcontentsline{toc}{chapter}{\listfigurename}			%Add List of figures to TOC
\listoftables											%Creates a list of tables
\addcontentsline{toc}{chapter}{\listtablename}			%Add List of tables to TOC
\clearpage												%Clear page, start renumb. page

%----------------------------------------------------------------------------------------
%	INTRODUCTION
%----------------------------------------------------------------------------------------
\pagenumbering{arabic}
\chapter{Introduction}
blablablablablabla\\
blablablablablabla\\
blablablablablabla\\


%----------------------------------------------------------------------------------------
%	LITERATURE
%----------------------------------------------------------------------------------------
\chapter{Literature}
blablablablablabla\\
blablablablablabla\\
blablablablablabla\\


\end{document}

User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Entries for unnumbered Chapters in ToC

Post by Stefan Kottwitz »

That's better! Now it's easy to see and quickly to fix: remove \protect\numberline{} at each place, which is not necessary but causes the space, i.e. write

Code: Select all

\addcontentsline{toc}{chapter}{Preface}
...
\addcontentsline{toc}{chapter}{Summary}
Stefan
LaTeX.org admin
fruitfrisje
Posts: 10
Joined: Wed Dec 05, 2012 12:26 pm

Re: Entries for unnumbered Chapters in ToC

Post by fruitfrisje »

if everything would have been that easy....

:oops:

Thank you very much!!!!
Post Reply