I want page numbers to be centered at the head of page. How can I do this?
Thanks for your helps…
[Tex/LaTex] How to make page numbers centered at the head of page
header-footer
Related Solutions
In the standard document classes there are four predefined page styles; the following is a quote taken directly from the fancyhdr
package documentation:
The default behaviour for the standard article
, report
or book
document classes is to use the plain
page style, so simply using the twoside
class option won't give you the desired position for the page number.
If you want to change the default page style, you can use \pagestyle{headings}
, or \pagestyle{myheadings}
(and perhaps supply information for the header). Both options will give you, with the twoside
option, headers containing the page numbers to the right on odd-numbered pages, and to the left on even-numbered pages.
If further customization is required, use a package such as titleps or fancyhdr to define your own page style. In any case, you will have to "activate" the page style by using the \pagestyle
command.
A little example using titleps
to define a new page style:
\documentclass[a4paper,twoside,titlepage,12pt]{article}
\usepackage{titleps}
\newpagestyle{mystyle}{
\sethead[a][b][c]{left}{center}{right}
\setfoot[a][b][c]{left}{center}{right}
}
\pagestyle{mystyle}
\begin{document}
test\clearpage test
\end{document}
A more realistic example: no footer, header for even-numbered pages: page number to the left, section number and title to the right; header for odd-numbered pages: subsection title to the left, page number to the right; all information with \small
font size:
\documentclass[twoside]{article}
\usepackage{titleps}
\usepackage{lipsum}% just to generate filler text
\newpagestyle{mystyle}[\small]{
\sethead[\thepage][][\thesection~\sectiontitle]{\subsectiontitle}{}{\thepage}
}
\pagestyle{mystyle}
\begin{document}
\section{Test Section}
\lipsum[1]
\subsection{Test Subsection}
\lipsum[1-20]
\end{document}
Here is a very plain template to set all the headers and footer in memoir
. It's taken almost verbatim from the memoir
documentation (section 7.3 MAKING HEADERS AND FOOTERS):
\documentclass{memoir}
\usepackage{lipsum}
\makepagestyle{hurried}% Create hurried page style
\makeevenfoot{hurried}% Adjust even footer for hurried page style
{LEF}% Left even footer
{CEF}% Center even footer
{REF}% Right even footer
\makeevenhead{hurried}% Adjust even header for hurried page style
{LEH}% Left even header
{CEH}% Center even header
{REH}% Right even header
\makeoddfoot{hurried}% Adjust odd footer for hurried page style
{LOF}% Left odd footer
{COF}% Center odd footer
{ROF}% Right odd footer
\makeoddhead{hurried}% Adjust odd header for hurried page style
{LOH}% Left odd header
{COH}% Center odd header
{ROH}% Right odd header
\makeheadrule{hurried}{\textwidth}{.4pt}% Header rule width/thickness for hurried page style
\makefootrule{hurried}{\textwidth}{.4pt}{\footruleskip}% Footer rule width/thickness/skip for hurried page style
\pagestyle{hurried}% Set page style to hurried
\begin{document}
\frontmatter
\tableofcontents
\mainmatter
\chapter{A chapter}\lipsum[1-10]
\section{A section}\lipsum[1-10]
\subsection{A subsection}\lipsum[1-10]
\subsubsection{A subsubsection}\lipsum[1-10]
\end{document}
If you don't want to be as extravagant and set everything, you can \copypagestyle
from an existing one (like Ruled
, ruled
, plain
, ... any of the ones mentioned in section 7.2 PAGE STYLES).
Note that first pages of chapters in memoir
are set in the chapter
page style. chapter
is not a true page style, but rather an alias for plain
. If you wish to change that, first \copypagestyle{chapter}{plain}
, making chapter
a true page style, then use the above techniques. For example, to get the page number in the center of the first chapter page, use
\copypagestyle{chapter}{plain}% Copy plain page syle to chapter page style
\makeoddfoot{chapter}% Adjust odd footer for chapter page style
{}% Left odd footer
{\thepage}% Center odd footer
{}% Right odd footer
Best Answer
You should be able to do that with fancy package
Regards