# Remove a page number from an entry in the ToC

After the preamble, I have this text:

\begin{document}

\frontmatter

\maketitle

\input{introduzione.tex}

\tableofcontents

\mainmatter
...

This is the result:

I don't want the "v" letter after "Introduzione". How can I hide that? I tried something using \addtocontents{toc}{\protect\setcounter{tocdepth}{-1}} but it doesn't work.

• the fact that the file is \input is not related to the issue, what matters is what is in that file, about which you have given no information. By default unnumbered section headings are not added to the table of contents – David Carlisle Oct 10 '16 at 21:13
• Welcome to TeX.SX! In order to answer this question we will need you to add a minimal working example (MWE) that illustrates your problem. This should be piece of code which begins \documentclass and ends \end{document} which when compiled produces Introduzione with the v. Try making a copy of your tex file and removing as much as possible such that the problem still occurs on compiling and then post that here. – Dai Bowen Oct 10 '16 at 21:23
• The “v” is the page number where the introduction starts off. Since it is in the front matter, pages are labeled with Roman numbers. Why would you remove it? – egreg Oct 10 '16 at 21:30

In the default document classes, each entry in the ToC is set via the macro \contentsline{<type>}{<title>}{<page>}. It takes three arguments, the first of which <type> makes the formatting decisions, while the second <title> and third <page> provide the content to be set.

When you compile the following minimal example (at least twice)

\documentclass{book}

\begin{document}

\frontmatter

\chapter{Introduction}% ...or \input{introduction}...

\tableofcontents

\mainmatter

\chapter{Main chapter}

\end{document}

you'll see the following in the .toc:

\contentsline {chapter}{Introduction}{i}
\contentsline {chapter}{\numberline {1}Main chapter}{1}

Your request would be to ignore the <page> for the first entry, but still keep it for subsequent entries. That is, instead of the regular \contentsline, we want something like \nopagecontentsline:

\let\oldcontentsline\contentsline
\newcommand{\nopagecontentsline}[3]{\oldcontentsline{#1}{#2}{}}

We would have to sleeve redefinitions cautiously as you're dealing with the ToC. So, within the main document, you'll use

\chapter{Introduction}% ...or \input{introduction}...

\let \contentsline \nopagecontentsline
\contentsline {chapter}{Introduction}{i}
\let \contentsline \oldcontentsline
\contentsline {chapter}{\numberline {1}Main chapter}{1}

where the update is inserted just before usage, and reverted just after usage.

Here is a complete minimal example:

\documentclass{book}

\let\oldcontentsline\contentsline
\newcommand{\nopagecontentsline}[3]{\oldcontentsline{#1}{#2}{}}

\begin{document}

\frontmatter

\chapter{Introduction}