Page numbering on the R/L corners?

2,245

Here is a very simple solution, loading titleps via the pagestyles option of titlesec, instead of fancyhdr:

\documentclass[openany]{book}
\usepackage[a4paper]{geometry}
\usepackage{multicol}
\usepackage{parskip}
\usepackage{graphicx}
\usepackage{changepage}
\usepackage{lipsum}
\pagestyle{plain}


 %CHAPTER FORMAT
\usepackage[pagestyles]{titlesec}
\titleformat{\chapter}[display]
{\centering\Huge\bfseries}
{\chaptername\ \thechapter}{0pt}{\Huge}
\titleformat{\section}
{\Huge\bfseries}
{}{1em}{}
\titleformat{\subsection}
{\LARGE}
{}{1em}{}

%TABLE OF CONTENTS
\usepackage[titles]{tocloft}
\usepackage[toc]{multitoc}
\renewcommand\cftchapfont{}
\renewcommand\cftsecfont{}
\renewcommand\cftchappagefont{\normalsize}
\renewcommand\cftsecpagefont{\small}
\renewcommand\cftchapafterpnum{\par\addvspace{3pt}}
\renewcommand\cftsecafterpnum{\par\addvspace{3pt}}
\renewcommand{\contentsname}{\centering Contents}

%PAGE NUM (RIGHT/LEFT)
\pagestyle{plain}
\renewpagestyle{plain}{
\widenhead[2.5cm][0cm]{0cm}{1.5cm}
\sethead{}{}{}%
\setfoot[\LARGE\bfseries\thepage][][]{}{}{\LARGE\bfseries\thepage}
}
%BEGIN DOC
\title{Pax Romana}
\begin{document}
\maketitle
\tableofcontents
\thispagestyle{empty}
\clearpage\pagestyle{plain}
\chapter{Introduction}
\begin{multicols}{2}
\lipsum
\end{multicols}
\chapter{Chp1}
\begin{multicols}{2}
\lipsum
\end{multicols}
\end{document} 

Odd page:

enter image description here

enter image description here

Share:
2,245
Jean Mentz
Author by

Jean Mentz

Updated on August 01, 2022

Comments

  • Jean Mentz
    Jean Mentz over 1 year

    I am writing a book-style document for children stories etc. I 've found a nice border for the page background of each paper, with a special place near the corner for each page-number.

    What I need now is to put the page-numbering of each page, on the bottom Left or Right side (but near the corners of each page) depending on even-odd logic of a book.

    So far I've just managed to put with fancyhdr the even-odd page numbering correctly and suppress the 'Body' margins with a naive way to push the numbering at the sides. But I can't suppress the 'Body' borders, for both Odd and Even pages with the simple\hspace method.

    I've tried \checkoddpage (if-then logic) and stuff but they did not work out well. The Right-Odd (RO) footer simply does not want to be pushed!!!

    Any ideas pushing that remaining Odd-numbering to the side? A sample of the code follows. It's a little long sorry! (I can't include the borders-backgrounds...but I hope you can imagine-understand what is needed to be implemented here.) Thanks in advance for your time.

    \documentclass[openany]{book}
    \usepackage[a4paper]{geometry}
    \usepackage{multicol}
    \usepackage{parskip}
    \usepackage{graphicx}
    \usepackage{changepage}
    \usepackage{fancyhdr}
    \usepackage{lipsum}
    \pagestyle{plain}
    
    
     %CHAPTER FORMAT
    \usepackage{titlesec}
    \titleformat{\chapter}[display]
    {\centering\Huge\bfseries}
    {\chaptername\ \thechapter}{0pt}{\Huge}
    \titleformat{\section}
    {\Huge\bfseries}
    {}{1em}{}
    \titleformat{\subsection}
    {\LARGE}
    {}{1em}{}
    
    %TABLE OF CONTENTS 
    \usepackage[titles]{tocloft}
    \usepackage[toc]{multitoc}
    \renewcommand\cftchapfont{}
    \renewcommand\cftsecfont{}
    \renewcommand\cftchappagefont{\normalsize}
    \renewcommand\cftsecpagefont{\small}
    \renewcommand\cftchapafterpnum{\par\addvspace{3pt}}
    \renewcommand\cftsecafterpnum{\par\addvspace{3pt}}
    \renewcommand{\contentsname}{\centering Contents}
    
    %PAGE NUM (RIGHT/LEFT)
    \pagestyle{plain}
    \fancypagestyle{plain}{
    \fancyhf{} % clear all header and footer fields
    \fancyfoot[LE]{\hspace*{-2.5cm}\LARGE{\textbf{\thepage}}}
    \fancyfoot[RO]{\hspace*{1.5cm}\LARGE{\textbf{\thepage}}} 
    \renewcommand{\headrulewidth}{0pt}
    \renewcommand{\footrulewidth}{0pt}
    \renewcommand{\footskip}{110pt}
    \hoffset =0pt
    }
    
    %BEGIN DOC
    \title{Pax Romana}
    \begin{document}
    \maketitle
    \tableofcontents
    \thispagestyle{empty}
    \clearpage\pagestyle{plain}
    \chapter{Introduction}
    \begin{multicols}{2}
    \lipsum
    \end{multicols}
    \chapter{Chp1}
    \begin{multicols}{2}
    \lipsum
    \end{multicols}
    \end{document}
    
    • cfr
      cfr over 8 years
      Rather than trying to force it, use geometry to alter the dimensions of the page layout. You could also look at the page style package which complements titlesec, but I think the key thing here is geometry. You ought not be changing \footskip as part of the page style. geometry won't know what is going on that way.
  • Jean Mentz
    Jean Mentz over 8 years
    Thank you very much, indeed a fine solution. Just wondering, is there also a way to adjust the \widenheadsomehow along the way? ;increase-decrease it let's say after the 99th page? I've tried the \ifnum\value{page}>99...but it does not work. Once the widenhead is set...done the pagestyle{plain} stays as is right?
  • Bernard
    Bernard over 8 years
    Perhaps define another style with different values and change style at the right place, if you want to change parameters at the beginning of a chapter?