2

I am using article, twosided environment with geometry package. I set my margins asymmetrically - one of them is 5cm to make marginnotes. The problem is that page numbers are not in the center of the page, but in the center of the \textwidth. How to tell latex to set page numbering in the middle of the page ?

  • If you are not going to print on both sides, use oneside option (it is the default one). – Sigur Jan 13 '15 at 18:16
  • What are you using to set your headers/footers to print the page number? Could you provide the community with a minimal working example (MWE) so we can replicate your current setup? – Werner Jan 13 '15 at 18:17
  • Can be easily done with scrlayer-scrpage -> textwithmarginpar – Johannes_B Jan 13 '15 at 18:20
4

Another possibility is the package scrlayer-scrpage with option footwidth=paper:<offset>. If the inner margin is 2cm the offset is -2cm.

\documentclass[
  twoside
]{article}
\usepackage{geometry}
\geometry{
  a4paper,
  inner=2cm,
  outer=5cm,
}

\usepackage[footwidth=paper:-2cm]{scrlayer-scrpage}
\clearpairofpagestyles
\cfoot*{\pagemark}% KOMA-Script version 3.14 or newer
%\cfoot[\pagemark]{pagemark}% alternatively

\usepackage{blindtext}

\begin{document}
\thispagestyle{plain}
\Blindtext[12]
\end{document}

enter image description here

This works with both oneside and twoside mode.


Or you can define a new layer even if you do not know the size of the inner margin.

\documentclass[
  twoside
]{article}
\usepackage{geometry}
\geometry{
  a4paper,
  hmarginratio=1:3
}

\usepackage{scrlayer-scrpage}
\clearpairofpagestyles
\DeclareNewLayer[
  foot,
  width=\paperwidth,
  hoffset=0pt,
  foreground,
  contents={\makebox[\layerwidth]{\pagemark}}
]{pagenumber.fg}
\AddLayersToPageStyle{scrheadings}{pagenumber.fg}
\AddLayersToPageStyle{plain.scrheadings}{pagenumber.fg}
%% or with one command to all pagestyles, including empty
%\AddLayersToPageStyle{@everystyle@}{pagenumber.fg}

\usepackage{blindtext}

\begin{document}
\Blindtext[12]
\end{document}
2

I suppose you're using geometry; if you also load fancyhdr, it's easy:

\documentclass{article}
\usepackage{geometry}
\geometry{
  a4paper,
  left=2cm,
  right=5cm,
}

\usepackage{fancyhdr}

\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\fancyhf{}
\fancyfoot[C]{\thepage}
\fancyfootoffset[R]{3cm}% 5cm - 2cm

\usepackage{kantlipsum}% just for the example

\begin{document}

\kant

\end{document}

enter image description here

1

Packages that write content in the header/footer are typically bound by the text block location on the page. If you wish to avoid this restriction and set page numbers based on the page, then eso-pic provides a simple solution:

enter image description here

\documentclass{article}
\usepackage{geometry,eso-pic}
\geometry{
  twoside,
  margin=2cm,
  inner=5cm,
  outer=2cm}
\usepackage{lipsum}
\AddToShipoutPictureFG{%
  \AtPageLowerLeft{%
    \raisebox{3\baselineskip}{%
      \makebox[\paperwidth]{\thepage}}
  }
}
\pagestyle{empty}
\begin{document}

\lipsum[1-50]

\end{document}

You'll set \thepage at shipout (the appropriate time to do so) using lower left part of the page as a start (\AtPageLowerLeft).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.