Page LayoutPage numbers disappeared after customizing margins

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
Nadia_ZA
Posts: 11
Joined: Fri Dec 05, 2014 4:28 am

Page numbers disappeared after customizing margins

Post by Nadia_ZA »

Hi! I'm writing a document using document class report.

Code: Select all

\documentclass[a4paper,12pt]{report}
I've used the geometry package to customize the margins:

Code: Select all

\usepackage[a4paper,lmargin=4.0cm,rmargin=2.0cm,tmargin=2.0cm,bmargin=2.0cm]{geometry} 
Also, I've used the fancyhdr package to put the page number on the right hand side of the footer:

Code: Select all

\usepackage{fancyhdr}
\pagestyle{fancy} 
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\fancyfoot[R]{\footnotesize\thepage}

\fancypagestyle{plain}{
    \fancyhf{}
    \fancyfoot[R]{\footnotesize\thepage}
}
Unfortunately, when I typeset the document source, the page numbers have disappeared. I also need the page numbers to be printed 1.0cm from the bottom edge of the page. What should I do to achieve that? 
Last edited by Nadia_ZA on Sun Dec 21, 2014 2:27 pm, edited 1 time in total.

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

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Page numbers disappeared after customizing margins

Post by Johannes_B »

Hi and welcome,

i added a documentclass and a document and i see the page numbers. Please test the example below. The problem seems to be somewhere else. You can find it by carefully hacking the document down.

Code: Select all

\documentclass[a4paper,12pt]{report}
\usepackage[a4paper,lmargin=4.0cm,rmargin=2.0cm,tmargin=2.0cm,bmargin=2.0cm]{geometry} 
\usepackage{blindtext}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\fancyfoot[R]{\footnotesize\thepage}

\fancypagestyle{plain}{
	\fancyhf{}
	\fancyfoot[R]{\footnotesize\thepage}
}
\begin{document}
\blinddocument
\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Nadia_ZA
Posts: 11
Joined: Fri Dec 05, 2014 4:28 am

Page numbers disappeared after customizing margins

Post by Nadia_ZA »

Thank you for the speedy reply. I've typeset the example you gave.

Code: Select all

\documentclass[a4paper,12pt]{report}
\usepackage[a4paper,lmargin=4.0cm,rmargin=2.0cm,tmargin=2.0cm,bmargin=2.0cm]{geometry} 
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\fancyfoot[R]{\footnotesize\thepage}

\fancypagestyle{plain}{
        \fancyhf{}
        \fancyfoot[R]{\footnotesize\thepage}
}
\begin{document}
\blinddocument
\end{document}
As I scrolled down the DVI file, the page numbers are sometimes there, sometimes not and when they are visible, they are at the top of the header on the next page.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Page numbers disappeared after customizing margins

Post by Johannes_B »

Ah -- DVI.

You can view dvi-files but they aren't meant to be viewed. You can transform the dvi to a pdf file (which is meant for viewing) by using the classical rout dvips filename -> ps2pdf filename or using dvipdfmx filename. Your editor should be able to convert them automatically.

The other and much more convenient alternative is to use pdflatex, which produces a pdf directly.
Advantage: You can use images in different formats, namely pdf, jpg and png.
Disadvantage: You cannot use eps graphics directly (well, the newest versions of the popular distributions can do this as well).

To sum it up, pdflatex is a little bit slower than latex (which, to be honest is pdflatex in dvi-mode) but you gain many advantages. Among them better support for hyperrefs and microtypographical features
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Nadia_ZA
Posts: 11
Joined: Fri Dec 05, 2014 4:28 am

Re: Page numbers disappeared after customizing margins

Post by Nadia_ZA »

Problem solved! The page numbers can be seen. Now I know that I need to choose pdf as my output type and not dvi. Thanks a lot for your help. I really appreaciate it. :D
Nadia_ZA
Posts: 11
Joined: Fri Dec 05, 2014 4:28 am

Page numbers disappeared after customizing margins

Post by Nadia_ZA »

Hi Johannes!

As I've mentioned, I have this code in my preamble.

Code: Select all

\documentclass[a4paper]{report}
In order to view the DVI output correctly, I figured out that I need to change the page size setting to A4. Because it was set to letter (by default), the page numbers did not appear at the bottom right in the DVI file.

These are the things that I like about DVI:
(1) Allows jumping between the source and typeset views - just click F8 to go to the corresponding position in either view.
(2) Is the preferred mode during the edit/format cycle, when you are continually moving between the source and typeset views.

Anyway, thank you so much for all the information and suggestions you have provided.
Post Reply