2

Please direct me on how to move the pages numbering of my work from the top right corners to the bottom center. Here is a sample of my work

page sample

Here's my main code

\documentclass[a4paper,12pt,oneside]{book}
\usepackage[margin=1.0in]{geometry} 
\usepackage[cmex10]{amsmath}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\newtheorem{mydef}{Definition}
\newtheorem{mytherm}{Theorem}
\usepackage{algorithm}
\usepackage{algpseudocode}
\renewcommand{\algorithmicrequire}{\textbf{Input:}}
\renewcommand{\algorithmicensure}{\textbf{Output:}}
\usepackage[utf8]{inputenc}
\usepackage{listings}
\usepackage{xcolor}
\definecolor{codegreen}{rgb}{0,0.6,0.1}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codeblue}{rgb}{0.10,0.00,1.00}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{1.0,1.0,1.0}
\lstdefinestyle{mystyle}{
    backgroundcolor=\color{backcolour},   
    commentstyle=\color{codegreen},
    keywordstyle=\color{codeblue},
    numberstyle=\tiny\color{codegray},
    stringstyle=\color{codepurple},
    basicstyle=\ttfamily\footnotesize,
    breakatwhitespace=false,         
    breaklines=true,                 
    captionpos=b,                        
    keepspaces=true,                 
    numbers=left,                    
    numbersep=5pt,                  
    showspaces=false,                
    showstringspaces=false,
    showtabs=false,                  
    tabsize=2,
    frame=none
}
\lstset{style=mystyle}

\usepackage{graphicx}
\usepackage{subfigure}
\usepackage{caption}
\usepackage{lipsum}

\usepackage{multirow}
\usepackage{rotating}
\usepackage{makecell}
\usepackage{booktabs}
\usepackage [autostyle, english = american]{csquotes}
\MakeOuterQuote{"}

\usepackage{enumitem}
\newlist{abbrv}{itemize}{1}
\setlist[abbrv,1]{label=,labelwidth=1in,align=parleft,itemsep=0.1\baselineskip,leftmargin=!}
\usepackage[hidelinks]{hyperref}
\usepackage[comma,authoryear]{natbib}
\renewcommand{\bibname}{References} 
\usepackage[toc]{appendix}

\usepackage{titlesec}
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries\centering}{\centering\chaptertitlename\ \thechapter}{20pt}{\Huge}
\titlespacing*{\chapter}
{0pt}{50pt}{40pt}

Thanks for the help in advance.

6
  • 1
    Please make your code complete, i.e. \begin{document} ... Some chapters text ... \end{document}. Commented Jan 6, 2023 at 16:31
  • What do you have in the headers on even pages? Commented Jan 6, 2023 at 16:32
  • Your "main code" is basically your preamble. Please add an MWE.
    – Latin-TeX
    Commented Jan 6, 2023 at 16:34
  • Do you know the package fancyhadr? That package allows you to define your own headers and footers. \fancyfoot[C]{\thepage} places the page number in de center of the footer.
    – alchemist
    Commented Jan 6, 2023 at 17:02
  • In your preamble you load the package amsmath twice. Once with an option [cmex10], the other one following the first one without option. That latter one will take precedence about the way the way amsmath is loaded: so without options!
    – alchemist
    Commented Jan 6, 2023 at 17:12

2 Answers 2

2

You should consider using the package fancyhdr. It would look like this:

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyfoot[C]{\thepage} % Centered pagenumber on the bottom. ("\cfoot{\thepage}" is deprecated.)
\fancyhead[RO,LE]{\leftmark} % This prints the chapter in the head. You might customize it, like "\textsc{\leftmark}".
\fancyhead[RE,LO]{} % Empty argument, so that only the chapter is in the title. With "\rightmark" there would be the section.
% "RE" = right on even pagenumbers
% "RO" = right on odd pagenumbers
% "LE" = left on even pagenumbers
% "LO" = left on odd pagenumbers

\begin{document}

The pagenumber is now centered on the bottom of the page.

\end{document}

You might customize your page even further with this package. But this should answer your question.

2
  • Thanks for the help. I've encountered another problem using your suggestion. The headers have titles of "sections" on the LHS and "Chapters" on the RHS. Lengthy texts in these titles make the headers overlap and look improper. I would prefer to have only Chapter titles on the header please. Any suggestion on how to do that? Thanks again. Commented Jan 6, 2023 at 17:22
  • I edited my example: Now there are the chaptertitles in the head, without the sections. I looked up "cfoot" because of the example from @miltos , who used "fancyhead[C]". The latter is correct, "cfoot" is deprecated (but still works fine in the document I work with).
    – Latin-TeX
    Commented Jan 7, 2023 at 7:02
1

You can do it using fancyhdr package:

\documentclass[a4paper,12pt,oneside]{book}
\usepackage[margin=1.0in]{geometry}
\usepackage{fancyhdr,blindtext}

\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\fancyfoot[C]{\thepage}%
\fancyhead[RO,LE]{\textsc{\nouppercase{{\leftmark}}}}

\begin{document}
    \blindtext[20]
\end{document}
2
  • Thanks for the help. I've encountered another problem using your suggestion. The headers have titles of "sections" on the LHS and "Chapters" on the RHS. Lengthy texts in these titles make the headers overlap and look improper. I would prefer to have only Chapter titles on the header please. Any suggestion on how to do that? Thanks again. Commented Jan 6, 2023 at 17:27
  • 1
    @Nathaniel Ekong. I modified the code so you have the Chapter title in header pages for even and odd pages. You can also have a look at this answer: tex.stackexchange.com/questions/310260/…
    – miltos
    Commented Jan 6, 2023 at 19:48

You must log in to answer this question.

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