3

MWE

\documentclass{article}
\usepackage{lipsum}
\usepackage[showframe]{geometry}
\usepackage{fancyhdr}
\fancyhf{}
\cfoot{something centered in footer}
\lhead{\rule{\textwidth}{3pt}}
\pagestyle{fancy}
\begin{document}
A normal page.

\clearpage
\newgeometry{margin=.5in,includeheadfoot,hcentering}
\lipsum[1-2]

\noindent\rule{\textwidth}{3pt}

\end{document}

Problem

As is shown in the MWE, the footer is not centered on the second page, after the geometry has been changed. Is there a way to correct this?

3
  • 1
    I'd say it's perfectly normal. Why are you changing the page geometry after one page? If your aim is to have a different geometry for the title page, then change geometry for that and restore the normal one afterwards.
    – egreg
    Sep 13, 2014 at 22:12
  • @egreg: I want to fit a figure that is slightly too wide for a portray page and too long for a landscape page. The figure is already scaled and I don't want to scale it further for legibility concerns. So my solution was to decrease the left/right margins, which led to the above problem.
    – Herr K.
    Sep 13, 2014 at 23:28
  • 2
    \newgeometry is not the answer; you can simply insert the image in a \makebox[\textwidth]{...} possibly adding some space in the box to position the image as you wish.
    – egreg
    Sep 13, 2014 at 23:33

1 Answer 1

6

This will force it to the center:

\cfoot{\makebox[\textwidth][c]{something centered in footer}}

Code:

\documentclass[oneside]{article}
\usepackage{lipsum}
\usepackage[showframe]{geometry}
\usepackage{fancyhdr}
\fancyhf{}
\cfoot{\makebox[\textwidth][c]{something centered in footer}}
\lhead{\rule{\textwidth}{3pt}}
\pagestyle{fancy}
\begin{document}
A normal page.

\clearpage
\newgeometry{margin=.5in,includeheadfoot,hcentering}
\lipsum[1-2]

\noindent\rule{\textwidth}{3pt}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .