I have a ten page LaTeX document in which only the first page number shows (i.e., 1). The rest of the page numbering does not show. How can I fix this?
[Tex/LaTex] Page numbering of LaTeX documents not showing
header-footerpage-numbering
Related Solutions
In the line after begin document, do the follows:
\begin{document}
\pagenumbering{gobble}
Do the title and author before this.
Then, on the actual first page, do:
\newpage
\pagenumbering{arabic}
You can define a new page style using \fancypagestyle{<name>}{<commands>}
to get rid of other headers/footers and leave the page number, and then use \thispagestyle{<name>}
at the desired locations:
\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{lipsum}
\usepackage{tocloft}
\usepackage{fancyhdr}
\fancypagestyle{myplain}
{
\fancyhf{}
\renewcommand\headrulewidth{0pt}
\renewcommand\footrulewidth{0pt}
\fancyfoot[C]{\thepage}
}
\fancyhf{}
\fancyhf{}
\fancyhead[CO]{\nouppercase\leftmark}
\fancyhead[CE]{\hdrtitle}
\fancyhead[LE,RO]{\thepage}
\pagestyle{fancy}
\renewcommand\sectionmark[1]{\markboth{#1}{}}%don't move this
\setcounter{section}{-1}
\title{The Title}
\author{The Author}
\makeatletter
\let\hdrtitle\@title
\makeatother
\begin{document}
\tableofcontents
\thispagestyle{empty}
\newpage
\section{Preface}
\thispagestyle{myplain}
\pagenumbering{roman}
\lipsum[1-3]
\newpage
\section{Start From Here}
\pagenumbering{arabic}
\lipsum[1-5]
\section{And So On...}
\lipsum[1-5]
\end{document}
The solution above will work if the preface is one page long; if the preface spans more than one page, you could define two styles: for example, myplain
(with only the page number (I assumed it should be centered in the footer, but you can easily change this)), and myfancy
(with your header/footer and rules); then you can use \pagestyle{<style>}
at appropriate locations to switch styles:
\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{lipsum}
\usepackage{tocloft}
\usepackage{fancyhdr}
\fancypagestyle{myplain}
{
\fancyhf{}
\renewcommand\headrulewidth{0pt}
\renewcommand\footrulewidth{0pt}
\fancyfoot[C]{\thepage}
}
\fancypagestyle{myfancy}{
\fancyhf{}
\fancyhead[CO]{\nouppercase\leftmark}
\fancyhead[CE]{\hdrtitle}
\fancyhead[LE,RO]{\thepage}
\renewcommand\headrulewidth{0.4pt}
\pagestyle{fancy}
\renewcommand\sectionmark[1]{\markboth{##1}{}}%don't move this
}
\setcounter{section}{-1}
\title{The Title}
\author{The Author}
\makeatletter
\let\hdrtitle\@title
\makeatother
\begin{document}
\tableofcontents
\thispagestyle{empty}
\newpage
\pagestyle{myplain}
\pagenumbering{roman}
\section{Preface}
\lipsum[1-10]
\newpage
\pagestyle{myfancy}
\pagenumbering{arabic}
\section{Start From Here}
\lipsum[1-5]
\section{And So On...}
\lipsum[1-5]
\end{document}
Perhaps you could be interested in using the book
document class and its \frontmatter
, \mainmatter
, \backmatter
commands? (using \chapter as the high level sectional unit, of course).
Best Answer
Most likely you have
\pagestyle{empty}
in your document. Remove that line and by default you will get page numbers on every page.