页码位置未固定在中心

页码位置未固定在中心

我正在使用fancyhdr包,但页码在奇数页上向右移动,在偶数页上向左移动。

代码:

\documentclass[a4paper,12pt]{book}

\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage[shortlabels,inline]{enumitem}
\usepackage[top=2cm, bottom=2cm, outer=0cm, inner=0cm]{geometry}
\usepackage[pages=some]{background}
\usepackage{fancyhdr}
\pagestyle{fancy}
\cfoot{}
\fancyfoot[C]{\thepage} 
\renewcommand{\headrulewidth}{0pt} 
\usepackage{geometry}

% Set the page margins
\geometry{
    paperwidth=8in,
    paperheight=11in,
    left=0.75in,
    right=0.75in,
    top=0.75in,
    bottom=0.75in,
    headheight=0in,
    headsep=0in,
    footskip=0in,
    includeheadfoot,
}

\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
\end{document}

图像:

展示

我希望他们成为中心

如果有人想访问完整代码请参阅以下链接,您也可以编辑它 https://www.overleaf.com/3887911651rqbpgvqknhfr

答案1

请注意,您会收到多个警告

Package fancyhdr Warning: \headheight is too small (0.0pt): 
(fancyhdr)                Make it at least 14.49998pt, for example:
(fancyhdr)                \setlength{\headheight}{14.49998pt}.
(fancyhdr)                You might also make \topmargin smaller to compensate:

(fancyhdr)                \addtolength{\topmargin}{-14.49998pt}.


Package fancyhdr Warning: \footskip is too small (0.0pt): 
(fancyhdr)                Make it at least 14.49998pt, for example:
(fancyhdr)                \setlength{\footskip}{14.49998pt}.


但大多数情况下你需要设置页面头部您设置页面大小

在此处输入图片描述

\documentclass[a4paper,12pt]{book}

\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage[shortlabels,inline]{enumitem}


% Set the page margins
%\usepackage[top=2cm, bottom=2cm, outer=0cm, inner=0cm]{geometry}
\usepackage{geometry}
\geometry{
    paperwidth=8in,
    paperheight=11in,
    left=0.75in,
    right=0.75in,
    top=0.75in,
    bottom=0.75in,
    headheight=0in,
    headsep=0in,
    footskip=0in,
    includeheadfoot,
}

\usepackage[pages=some]{background}
\usepackage{fancyhdr}
\pagestyle{fancy}
\cfoot{}
\fancyfoot[C]{\thepage} 
\renewcommand{\headrulewidth}{0pt} 
\setlength{\headheight}{15pt}
\setlength{\footskip}{15pt}

\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
\end{document}

答案2

不确定你在做什么。(请不要回答这个解决方案,而是编辑并完善你的问题。)这样页码已经居中。

例子

\documentclass[10pt,a4paper]{article}
\usepackage{lipsum}

\usepackage{fancyhdr}
\pagestyle{fancy}
\cfoot{}
\fancyfoot[C]{\thepage} 

\begin{document}
\lipsum[1-15]
\end{document}

相关内容