我想将页码从页面右上角移到页面底部中央

我想将页码从页面右上角移到页面底部中央

请告诉我如何将我作品的页码从右上角移到底部中央。这是我的作品样本

页面样本

这是我的主要代码

\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}

我在这里先向您的帮助表示感谢。

答案1

您应该考虑使用包fancyhdr。它看起来像这样:

\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}

您可以使用这个包进一步自定义您的页面。但这应该可以回答您的问题。

答案2

您可以使用fancyhdr包来完成此操作:

\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}

相关内容