Page LayoutFancy page number going wrong

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
Barakaty
Posts: 12
Joined: Sun Nov 30, 2008 2:43 am

Fancy page number going wrong

Post by Barakaty »

hi guys
I use book document class with fancy page numbers. it should disply the page number on the right in even pages and on the left in odd pages. It does through the document :D but not on the first page in each chapter ;) . An example is attached and here is the preamble I used.

Code: Select all

\usepackage{fancyhdr}
%% first reset the headers and footers
\fancyhead{}
\fancyfoot{}
%% make the odd pages have the section name on the top right
\fancyhead[LE]{\sffamily\bfseries \rightmark}
%% make the even pages have the chapter name on the top left
\fancyhead[RO]{\sffamily\bfseries \leftmark}

%% page nums on the bottom in a nice box
%% even side pages
\fancyfoot[RO]{\psboxit{box 0.8 setgray fill}
{\framebox[10mm][c]{\rule{0cm}{4mm}\color{black}{\bfseries \thepage}}}}
%% odd side pages
\fancyfoot[LE]{\psboxit{box 1 setgray fill}
{\hspace{\textwidth}\psboxit{box 0.8 setgray fill}
{\framebox[10mm][c]{\rule{0cm}{4mm}\color{black}{\bfseries \thepage}}}}}

%% make the bottom line above the page number box
\renewcommand{\footrulewidth}{0.6pt}
\renewcommand{\footruleskip}{0mm}

%% bring the style into effect
%% (must come after all the fancyhead and fancyfoot stuff)
\pagestyle{fancy}

%% now redefine the plain style pages (chapter pages, contents pages)
%% to have the same page number stuff on the bottom
\fancypagestyle{plain}{
\fancyhf{}
\fancyfoot[RO]{\psboxit{box 1 setgray fill}
{\hspace{\textwidth}\psboxit{box 0.8 setgray fill}
{\framebox[10mm][c]{\rule{0cm}{4mm}\color{black}{\bfseries \thepage}}}}}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0.5pt}
}

%% this next section (till \makeatother) makes sure that blank pages
%% are actually completely blank, cause they're not usually
\makeatletter
\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
	\hbox{}
	\vspace*{\fill}
	\thispagestyle{empty}
	\newpage
	\if@twocolumn\hbox{}\newpage\fi\fi\fi}
\makeatother
Attachments
latex page numbers.JPG
latex page numbers.JPG (92.94 KiB) Viewed 4507 times

Recommended reading 2024:

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

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

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

Fancy page number going wrong

Post by localghost »

The devil is in the detail. I think your redefinition of the fancy page style plain has a small mistake.

Code: Select all

%% now redefine the plain style pages (chapter pages, contents pages)
%% to have the same page number stuff on the bottom
\fancypagestyle{plain}{
\fancyhf{}
\fancyfoot[LO]{\psboxit{box 1 setgray fill}          % <<<<<<<<< here was [RO] before
{\hspace{\textwidth}\psboxit{box 0.8 setgray fill}
{\framebox[10mm][c]{\rule{0cm}{4mm}\color{black}{\bfseries \thepage}}}}}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0.5pt}
}
I marked the critical line with a comment.


Best regards
Thorsten¹
Barakaty
Posts: 12
Joined: Sun Nov 30, 2008 2:43 am

Re: Fancy page number going wrong

Post by Barakaty »

Hi
It tried but no change happened
Post Reply