Page LayoutGet rid of page numbers, header and footer where unwanted

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
ffarr
Posts: 28
Joined: Sat Apr 23, 2011 6:00 pm

Get rid of page numbers, header and footer where unwanted

Post by ffarr »

Hello, how can I get rid of page numbers where unwanted?

I tried some way with \pagestyle{empty} but I couldn't manage to do it.

Can you give me a clear, small example, for example for the table of contents page?

This is my code until the table of contents:

Code: Select all

\documentclass[11pt,a4paper,twoside,italian]{book}
\usepackage[T1]{fontenc}
\usepackage[italian]{babel}
\usepackage[latin1]{inputenc}
\usepackage[%
      papersize={110mm,195mm},
      headheight=14pt,
      includehead,
      nofoot
    ]{geometry}
\usepackage{babel}
\usepackage[raggedright,pagestyles]{titlesec}
\usepackage{blindtext}
\usepackage{color}
\newpagestyle{main}{%
  \sethead[\thepage][][\chaptertitle]{\chaptertitle}{}{\thepage}
  \headrule
}
\pagestyle{main}

\titleformat{\chapter}{\normalfont\huge\bfseries}{}{0pt}{\Huge}

\begin{document}
 
\tableofcontents 
\clearpage
Many thanks!
Last edited by ffarr on Wed May 11, 2011 9:02 pm, edited 1 time 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

meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Get rid of page numbers, header and footer where unwanted

Post by meho_r »

Basically, you can go with creating different page styles for different parts of the document and activate them where appropriate (including redefinition of plain page style, which is applied automatically in some places, e.g., for the first page of the TOC, and the first page of a chapter). Here's an example to start with:

Code: Select all

\documentclass[11pt,a4paper,twoside,italian]{book}
\usepackage[T1]{fontenc}
\usepackage[italian]{babel}
\usepackage[latin1]{inputenc}
\usepackage[%
      papersize={110mm,195mm},
      headheight=14pt,
      includehead,
      nofoot
    ]{geometry}
\usepackage{babel}
\usepackage[raggedright,pagestyles]{titlesec}% Add “clearempty” option if you need to get rid of headers/footers on empty pages
\usepackage{blindtext}
\usepackage{color}

\titleformat{\chapter}{\normalfont\huge\bfseries}{}{0pt}{\Huge}[\thispagestyle{plain}]

%%% Page styles

\makeatletter

\newpagestyle{toc}{% Create a page style for TOC
	\let\ps@plain\ps@empty% Redefine plain style which is automatically applied to the first page of TOC; put “empty”, or “main”, or any other page style you like
	\sethead[][][]{}{}{}
}

\newpagestyle{chapter}{% Create a page style for the first page of a chapter
	\setfoot[][\thepage][]{}{\thepage}{}
}

\newpagestyle{main}{%
	\let\ps@plain\ps@chapter% Activate page style for the first page of a chapter
	\sethead[\thepage][][\chaptertitle]{\chaptertitle}{}{\thepage}
	\headrule
}

\makeatother

\begin{document}

\pagestyle{toc}% Activate toc page style

\tableofcontents 

\clearpage

\pagestyle{main}% Activate main page style

\chapter{A chapter}

Test\clearpage
Test\clearpage
Test\clearpage

\end{document}
ffarr
Posts: 28
Joined: Sat Apr 23, 2011 6:00 pm

Re: Get rid of page numbers, header and footer where unwante

Post by ffarr »

Superb. Thank you!
Post Reply