hi,
I would like to center page numbers on the first page of a new section, and then for every page thereafter, put the page number in the upper-right hand corner.
I saw a similar post on here for a thesis, but the resolution used a class file that I could not understand, and I am already needing to customize my latex document, since this is also a thesis.
thanks.
Text Formatting ⇒ Center Page Numbers only on first Page of new Section
NEW: TikZ book now 40% off at Amazon.com for a short time.

-
- Posts: 126
- Joined: Sun Feb 13, 2011 8:36 pm
Center Page Numbers only on first Page of new Section
You would do this by selecting the appropriate pagestyle. For the following, I'll assume, that you want to use plain for pages on which a new section starts and headings for other pages. Feel free to define arbitrary page styles, conveniently by using a package like fancyhdr.
All you have to do is to declare headings as the default page style by putting
in your preamble and then switch the style for the section-opening-pages via
at the appropriate places.
To get your stuff working reliably, you should take care of page breaks. The simplest thing would be to add a \clearpage before each section. Since you want a different page style, you'll probably feel comfortably with each section beginning on a new page.
Using the \gpreto macro from the etoolbox package, you can set this up in your preamble and needn't insert the code at each \section by hand.
See the following code for a working example:
Alternatively, you may consider using the report document class and make your \sections \chapters.
Best
All you have to do is to declare headings as the default page style by putting
Code: Select all
\pagestyle{headings}
Code: Select all
\thispagestyle{plain}
To get your stuff working reliably, you should take care of page breaks. The simplest thing would be to add a \clearpage before each section. Since you want a different page style, you'll probably feel comfortably with each section beginning on a new page.
Using the \gpreto macro from the etoolbox package, you can set this up in your preamble and needn't insert the code at each \section by hand.
See the following code for a working example:
Code: Select all
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[latin]{babel} % just loaded to get the
\usepackage{blindtext} % ``lorem ipsum'' text...
\usepackage{etoolbox}
\makeatletter
\gpreto\section{\clearpage\thispagestyle{plain}}
\makeatother
\pagestyle{headings}
\begin{document}
\section{This is a Section}
\blindtext
\subsection{This is a Subsection}
\blindtext[10]
\subsection{This is Another Subsection}
\blindtext[15]
\section{This is a Section}
\blindtext
\subsection{This is a Subsection}
\blindtext[10]
\subsection{This is Another Subsection}
\blindtext[15]
\section{This is a Section}
\blindtext
\subsection{This is a Subsection}
\blindtext[10]
\subsection{This is Another Subsection}
\blindtext[15]
\end{document}
Best
I'm using pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian).