Text FormattingLaTeX toc numbering

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
nbl
Posts: 2
Joined: Fri Feb 06, 2015 12:04 am

LaTeX toc numbering

Post by nbl »

Hello everyone,

I would like to remove the part number in the ToC but while keeping the numerotation when the part appears in the document.

I mean that

\part*{My part}
\addcontentsline{toc}{part}{My part}

does not make it : I remove the number in the ToC but also in the document.

I looked a lot on the internet but I'm still without any solution !

Please help me :D
Last edited by Stefan Kottwitz on Sun Feb 08, 2015 1:54 pm, edited 2 times in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: LaTeX toc numbering

Post by Johannes_B »

Hi and welcome, will this be only for a single entry, or for all of them? Which document class are you using? Can you provide a minimal working example?

Why do you want to do that? The reader will be a bit confused.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
nbl
Posts: 2
Joined: Fri Feb 06, 2015 12:04 am

Re: LaTeX toc numbering

Post by nbl »

Hello,

I work with the class book and it would be better for everyone (but for one still work, I have only 3 part).

For exemple, in the ToC I would like

My Part

Here it is without the Number. And inside the document,

First Part
My Part


If I use the solution with part*, it removes the number in the ToC but also in the document, and I would like to keep the "First Part" written in the document but not the I in the ToC (it is "I My Part" instead of "My Part").

To sum up, I just want to remove the number of the parts in the ToC but to keep them in the document. The only solutions I found keep them all (to do nothing) or remove them all :cry:
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

LaTeX toc numbering

Post by Johannes_B »

Fairly simple redefining the internals that write the entry to the toc.

Code: Select all

\documentclass{book}
\usepackage{xpatch}
%\tracingpatches
\makeatletter
\xpatchcmd{\@part}{%
	\addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
}{%
	\addcontentsline{toc}{part}{#1}%
}{}{}
\makeatother
\begin{document}
\tableofcontents
\part{Ducks are great}
\part{Penguins are great, too}
\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply