1

In a latex book document, I use different layouts by using the command \newgeometry. My footers and margins (marginparwidth,marginparsep) "move" and if I use a standard page numbering, the page numbering move too and it's not beautiful.

I'd like to use a fixed "float" page numbering box in the bottom corner of all of my pages of my document, without consideration of the \newgeometry settings. I'd like specify a (X,Y) position for this box for all of my document, like that :

exemple of specified page numbering box I'd like

To complexify, I'd like that the command \thispagestyle{empty} can be understand too : if the \thispagestyle{empty} is specified into a page, the page numbering box is not displayed.

1

Here is a suggestion with package scrlayer-scrpage. It uses layers for header and footer. It is possible to define new layers and add them to page styles.

So you can use a two new layers for the page numbers: one for odd pages and one for even pages.

In the following example the center of the baseline is 1cm above the lower page border and 2cm left/right of the outer page margin on odd/even pages.

\documentclass{book}
\usepackage{geometry}
\geometry{top=2cm,bottom=3cm,left=2cm,right=4cm,marginparwidth=2.8cm,marginparsep=1cm}

\usepackage{xcolor}

\usepackage{scrlayer-scrpage}
\clearpairofpagestyles
\addtokomafont{pagenumber}{\LARGE\bfseries}
\renewcommand\pagemark{\fcolorbox{black}{yellow!30}{\usekomafont{pagenumber}\thepage}}

\DeclareNewLayer[
    oddpage,
    background,
    page,
    addheight=-1cm,
    addwidth=-2cm,
    mode=picture,
    contents=\putLR{\makebox[0pt][c]{\pagemark}}
]{pagenumber.odd}
\DeclareNewLayer[
    clone=pagenumber.odd,
    evenpage,
    hoffset=2cm,
    contents=\putLL{\makebox[0pt][c]{\pagemark}}
]{pagenumber.even}

\AddLayersToPageStyle{scrheadings}{pagenumber.odd,pagenumber.even}
\AddLayersToPageStyle{plain}{pagenumber.odd,pagenumber.even}

\usepackage{blindtext}
\usepackage{showframe}
\begin{document}
\chapter{A chapter}
\Blindtext[10]
\clearpage
\thispagestyle{empty}
{\Huge A page with empty page style.\par}
\clearpage
\Blindtext
\newgeometry{top=8cm,bottom=5cm,right=6cm,left=5cm,marginparwidth=2cm,marginparsep=3mm}
\Blindtext[10]
\end{document}

enter image description here

  • It works perfectly. I had a conflict with fancyhdr package, but I've deleted it and it is ok. – lucif Dec 17 '16 at 16:49

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.