Page LayoutIncorrect page numbers position

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
Harmont
Posts: 13
Joined: Tue Aug 31, 2010 3:52 pm

Incorrect page numbers position

Post by Harmont »

I use book documentclass and fancyhdr package to put page numbers top centered like this:

Code: Select all

\documentclass[oneside]{book}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\fancyhead[C]{\fontsize{14}{0}\selectfont\thepage}

\begin{document}
\include{title}
\tableofcontents
\newpage
\listoffigures
\newpage
\listoftables
\newpage
\lstlistoflistings
\include{introduction}
\include{ch1}
\include{ch2}
\include{ch3}
\include{ch4}
\include{conclusion}
\include{bibliography}
\end{document}
But on the first pages of table of contents, list of figures, list of tables, list of listings and bibliography page number is at the bottom. It's not desired.

Can somebody help with fixing that?
Last edited by Harmont on Tue Sep 14, 2010 12:33 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

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Incorrect page numbers position

Post by localghost »

Harmont wrote:[…] Can somebody help with fixing that?
The fancyhdr manual (Section 7 — Redefining plain style, p. 7f) or the Forum Search.


Best regards
Thorsten
Harmont
Posts: 13
Joined: Tue Aug 31, 2010 3:52 pm

Incorrect page numbers position

Post by Harmont »

localghost, thank you for the tip. Am I understanding correctly that I should redefine plain style along with the default layout like this:

Code: Select all

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\fancyhead[C]{\fontsize{14}{0}\selectfont\thepage}

\fancypagestyle{plain}{%
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\fancyhead[C]{\fontsize{14}{0}\selectfont\thepage}}
I could use search but I didn't think of any meaningful search query.
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Incorrect page numbers position

Post by meho_r »

How about "redefine plain"? For example, check this and this.
Harmont
Posts: 13
Joined: Tue Aug 31, 2010 3:52 pm

Incorrect page numbers position

Post by Harmont »

Perfect. meho_r, thanks for the follow-up.

For those who are searching for the answer:

Code: Select all

\makeatletter
\let\ps@plain\ps@fancy
\makeatother
User avatar
mazetas
Posts: 2
Joined: Mon Sep 27, 2010 11:38 pm

Incorrect page numbers position

Post by mazetas »

I have a similar problem but my case is a bit more complicated. I want listoftables, listoffigures and tableofcontents all with roman numbers down and right, while the body of my work to be with arabic numbers up and right.
so i can redifine plain but I will be correct positioned only in one case. so any ideas about that?

here is also my code

Code: Select all

\fancypagestyle{plain}{%
\fancyhf{}
\rfoot{\thepage}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}}

\fancypagestyle{sxoli1}{%
\fancyhf{}
\pagenumbering{roman}
\rfoot{\thepage}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}}

\fancypagestyle{sxoli2}{%
\fancyhf{}
\pagenumbering{arabic}
\rhead{\thepage}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}}

\begin{document}




\maketitle
\newpage
\pagestyle{sxoli1}
\tableofcontents
\listoffigures
\listoftables

\newpage
\pagestyle{sxoli2}
%\setcounter{page}{1}

\include{intro}
\include{kefalaio1}
\include{kefalaio2}
%\include{}
 
\end{document}
once I've seen what latex does, I decided or by LaTeX or by hand
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Incorrect page numbers position

Post by meho_r »

Code: Select all

\documentclass{report}
\usepackage{fancyhdr}
\usepackage{blindtext}
\usepackage[english]{babel}

\fancypagestyle{sxoli1}{%
\fancyhf{}
\pagenumbering{roman}
\rfoot{\thepage}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
	\fancypagestyle{plain}{%
	\rfoot{\thepage}
	}
}

\fancypagestyle{sxoli2}{%
\fancyhf{}
\pagenumbering{arabic}
\rhead{\thepage}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
	\fancypagestyle{plain}{%
	\rhead{\thepage}
	}
}

\begin{document}

\newpage
\pagestyle{sxoli1}
\tableofcontents
\listoffigures
\listoftables

\clearpage
\pagestyle{sxoli2}

\Blinddocument

\end{document}
User avatar
mazetas
Posts: 2
Joined: Mon Sep 27, 2010 11:38 pm

Re: Incorrect page numbers position

Post by mazetas »

wow! that was fast and accurate. and i've been waisting 2 days of searching till now. if I could also get the source of my mistake it'd be more than great.

also something more. after tableofcontents and table of figures, it gives me an extra white page, that it's numbered though. could that be ommited somehow?

thanks a lot
once I've seen what latex does, I decided or by LaTeX or by hand
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Incorrect page numbers position

Post by meho_r »

You redefined plain style only once, putting page number in the footer, which means it will be applied throughout your document (i.e., since every first page of a chapter use plain style, page number will be placed in the footer). Instead of that, I set that plain style is automatically redefined when page styles sxoli1 and sxoli2 are called, putting page numbers in the footer for sxoli1, but in the header for sxoli2.

For empty page after TOC, LOF and LOT, what exactly do you want to do: remove page number or remove empty page completely? Also, you should tell us which document class you're using (or, even better, provide a full Minimal Working Example (MWE)).
Post Reply