Page LayoutReport page numbering

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
CJFugate
Posts: 12
Joined: Thu Aug 23, 2012 11:47 pm

Report page numbering

Post by CJFugate »

I want to have my pag numbering start at page 2 with the page numbering in the top right corner. When I use this code

Code: Select all

\documentclass[11pt]{article}
\usepackage{fancyhdr}
\fancyhf{} % clear all header and footers
\renewcommand{\headrulewidth}{0pt} % remove the header rule
\rhead{\thepage}
\setcounter{page}{2}
\pagenumbering{arabic}
\pagestyle{fancy}
it works just the way I want it. However, when I change the document class from article to report so that I can have chapter titles, sections, etc., it doesn't work anymore.

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

CJFugate
Posts: 12
Joined: Thu Aug 23, 2012 11:47 pm

Re: Report page numbering

Post by CJFugate »

I found the solution, so I thought I'd post it in case someone else looks for it here. I found it on another forum. http://tex.stackexchange.com/questions/ ... r-position
Basically, the \chapter command defaults to a plain page style. To specify the page style you need, add the \thispagestyle command after the \chapter command.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Report page numbering

Post by Stefan Kottwitz »

Well, "it doesn't work anymore" is perhaps not the best problem description. ;)

A better solution than the one from TeX.SX, using \thispagestyle many times, would be using

Code: Select all

\fancypagestyle{plain}{\pagestyle{fancy}}
in the preamble, or with a similar argument, or redefine the plain page style, just once in the preamble:

Code: Select all

\makeatletter
\let\ps@plain\ps@fancy
\makeatother
Stefan
LaTeX.org admin
CJFugate
Posts: 12
Joined: Thu Aug 23, 2012 11:47 pm

Report page numbering

Post by CJFugate »

Sorry, I'm really bad at describing my problem on a forum without dumbing all of my code on there. Alright, I tried

Code: Select all

\fancypagestyle{plain}{\pagestyle{myheadings}}
. I put it just after

Code: Select all

\pagestyle{myheadings}
in the preamble. I then removed

Code: Select all

\thispagestyle{myheadings}
from my my pages in my document. I just get a header line and no page number like I do when I use

Code: Select all

\thispagestyle{myheadings}
. I trust that your solution works and that I am implementing it incorrectly.


Thanks
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Report page numbering

Post by cgnieder »

CJFugate wrote:Sorry, I'm really bad at describing my problem on a forum without dumbing all of my code on there.
Doesn't need to be all your code. In fact very much better and very helpful to give you precise advice would be a Infominimal working example instead.

Regards
site moderator & package author
Post Reply