Page LayoutStopping page numbering

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
F!o
Posts: 4
Joined: Sat Apr 25, 2009 2:19 pm

Stopping page numbering

Post by F!o »

Hi everyone,

I am writing my thesis using LaTeX, and I need some help.

I have to conform to this order : Title Page > X > Table of contents > Introduction > ... > Conclusion > Bibliography>Abstract where X can be what I want (for instance : Thanks, Appendix, etc.). I must put the number of each page from the Introduction to the Conclusion.
So there must be no page numbering before and after.

I put each part of the thesis in different .tex files, using several \input{part_file_name} in my main .tex file.

I tried to use \thispagestyle{empty} inside the .tex files of the parts I don't want the page numbering, but as the content doesn't fit in one single page, it works only for the first one and all the following pages still have the number at the bottom.

using \pagestyle{empty} works but deletes headers and footers...

Any idea to fix the problem?

Thanks for your help! :D

Recommended reading 2024:

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

NEW: TikZ book now 40% off at Amazon.com for a short time.

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

Stopping page numbering

Post by meho_r »

You can define different page styles for different parts of document. Here's an example using fancyhdr:

Code: Select all

\documentclass{book}

\usepackage[english]{babel}
\usepackage{blindtext}% for dummy text

\usepackage{fancyhdr}


% Defining page style for “front matter” (”intro” page style):

\fancypagestyle{intro}{%
\fancyhf{}% clears all header and footer fields
\fancyhead[LE]{\leftmark}
\fancyhead[RO]{\rightmark}
\fancyfoot[C]{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
   \fancypagestyle{plain}{% Redefinition of “plain” page style
   \fancyhf{}
   \fancyhead[RO]{\rightmark}% remove for empty header
   \renewcommand{\headrulewidth}{0pt}
   \renewcommand{\footrulewidth}{0pt}}
}


% Defining page style for “main matter” (”main” page style):

\fancypagestyle{main}{%
\fancyhf{} 
\fancyhead[LE]{\leftmark}
\fancyhead[RO]{\rightmark}
\fancyfoot[C]{\thepage}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{1pt}
   \fancypagestyle{plain}{%
   \fancyhf{}
   \fancyhead[RO]{\rightmark}% remove for empty header
   \fancyfoot[C]{\thepage}
   \renewcommand{\headrulewidth}{0pt}
   \renewcommand{\footrulewidth}{1pt}}
}


% Defining page style for “back matter” (”outro” page style):

\fancypagestyle{outro}{%
\fancyhf{} 
\fancyhead[LE]{\leftmark}
\fancyhead[RO]{\rightmark}
\fancyfoot[C]{\thepage}
\renewcommand{\headrulewidth}{1pt}
\renewcommand{\footrulewidth}{0pt}
   \fancypagestyle{plain}{%
   \fancyhf{}
   \fancyhead[RO]{\rightmark}% remove for empty header
   \fancyfoot[C]{\thepage}
   \renewcommand{\headrulewidth}{1pt}
   \renewcommand{\footrulewidth}{0pt}}
}


% Removing headers and footers from empty pages after \cleardoublepage
\makeatletter
\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
  \hbox{}
  \vspace*{\fill}
  \begin{center}
    This page intentionally contains only this sentence.
  \end{center}
  \vspace{\fill}
  \thispagestyle{empty}
  \newpage
  \if@twocolumn\hbox{}\newpage\fi\fi\fi}
\makeatother


\begin{document}

% Front matter

\pagestyle{intro}

{\Large TITLE PAGE}\clearpage

\tableofcontents\clearpage


% Main matter

\pagestyle{main}

\Blinddocument% dummy text


% Back matter

\pagestyle{outro}

\Blinddocument% dummy text

\end{document}
NOTE: Redefinition of plain page style is necessary because it is automatically applied to the first page of every chapter, ignoring completely page style in effect. Redefinition of \cleardoublepage is the one proposed in fancyhdr documentation, you can change it as you see fit.
Post Reply