使用 fancyhdr 在页边空白处进行页码编号

使用 fancyhdr 在页边空白处进行页码编号

我正在使用 fancyhdr 来布局我的文档,但页码恰巧位于页边距中,我想避免这种情况。输出如下: 页边距中的页码

由于我的标题中有关 geometry 和 fancyhdr 的部分确实有效,因为当我仅将它们包含在另一个文档中时它确实有效,所以它应该是由于其他包和设置而发生的。你能帮我找到有问题的命令吗?

\documentclass[12pt, a4paper, twoside, openright]{book}

\title{}
\author{}
\date{}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[french, english]{babel}
\usepackage{amsfonts, amssymb, amsmath} 
\usepackage{color}
\usepackage{graphicx}
\usepackage[all, cmtip]{xy}
\usepackage{amsthm}
\usepackage{stmaryrd}
\usepackage{appendix}
\usepackage{scrextend}
\usepackage{lipsum}
\usepackage[linkcolor=blue, citecolor=green, colorlinks=true]{hyperref}
\usepackage{array}
\usepackage{makeidx}
\usepackage[Lenny]{fncychap}
\makeindex
\usepackage{minitoc}
\usepackage{enumitem}
\usepackage[intoc]{nomentbl}

\makenomenclature
\renewcommand{\nomname}{List of Abbreviations and Symbols}
\setlength{\nomitemsep}{-\parsep}
\usepackage{titlesec}
\newcolumntype{L}{>{$}c<{$}}
\numberwithin{equation}{section}    
\allowdisplaybreaks

\usepackage{newtxtext, newtxmath}
\usepackage{fullpage}

\setlength{\footskip}{1.95cm}
\setlength{\parindent}{1em}
\setlength{\parskip}{0em}

\newenvironment{myitemize}
{ \begin{itemize}
    \setlength{\itemsep}{0pt}
    \setlength{\parskip}{0pt}
    \setlength{\parsep}{0pt}     }
{ \end{itemize}                  } 

\newcommand{\nocontentsline}[3]{}
%\newcommand{\tocless}[2]{\bgroup\let\addcontentsline=\nocontentsline#1{#2}\egroup}

%environnements mathématiques
\theoremstyle{plain}
\newtheorem{thm}{Theorem}
\newtheorem{mythm}{Theorem}
\newtheorem{coro}[mythm]{Corollary}
\renewcommand*{\themythm}{\Alph{mythm}}
\newtheorem{mythmfr}{Théorème}
\renewcommand*{\themythmfr}{\Alph{mythmfr}}
\newtheorem{corofr}[mythmfr]{Corollaire}
\newtheorem{lem}{Lemma}
\newtheorem{prop}{Proposition}
\newtheorem{conj}{Conjecture}
\newtheorem{myconj}{Conjecture}
\renewcommand*{\theconj}{\Alph{myconj}}
\newtheorem{myconjfr}{Conjecture}
\renewcommand*{\themyconjfr}{\Alph{myconjfr}}
\newtheorem{pb}{\textbf{Problem}}
\theoremstyle{definition}
\newtheorem{defi}{Definition}
\theoremstyle{plain}
\newtheorem{thmfr}{Théorème}
\newtheorem{lemfr}{Lemme}
\newtheorem{propfr}{Proposition}
\newtheorem{conjfr}{Conjecture}
\newtheorem{pbfr}{\textbf{Problème}}
\theoremstyle{definition}
\newtheorem{defifr}{Définition}

\newenvironment{note}{\begin{minipage}{\dimexpr\linewidth - 1cm} \small \textsc{Note.}}{\end{minipage} \normalsize}
\newcommand{\didier}[1]{{\sf $\spadesuit\spadesuit\spadesuit$ Didier: [#1]}}
\newcommand{\ian}[1]{{\sf $ \clubsuit\clubsuit\clubsuit$ Ian: [#1]}}

\usepackage{fancyhdr}
\pagestyle{plain}

\renewenvironment{note}{\begin{minipage}{\dimexpr\linewidth - 1cm} \small \textsc{Note.}}{\end{minipage} \normalsize}

%\numberwithin{equation}{chapter}

\usepackage{chngcntr}
\counterwithout{equation}{section}
\renewcommand{\theequation}{\thechapter.\arabic{equation}}

\setcounter{minitocdepth}{1}

\usepackage{tocloft}
% 
\setlength\cftparskip{1pt}
\setlength\cftbeforechapskip{5pt}

\usepackage{fancyhdr}
\setlength{\headheight}{15.2pt}
\pagestyle{fancy}
\fancypagestyle{fancybook}{
    \fancyhf{}%
    \addtokomafont{pagehead}{\tiny}
    % Note the ## here. It's required because \fancypagestyle is making a macro (\ps@fancybook).
    % If we just wrote #1, TeX would think that it's the argument to \ps@fancybook, but
    % \ps@fancybook doesn't take any arguments, so TeX would complain with an error message.
    % You are not expected to understand this.
    \renewcommand*{\sectionmark}[1]{ \markright{\thesection\ ##1} }%
    \renewcommand*{\chaptermark}[1]{ \markboth{\chaptername\ \thechapter: ##1}{} }%
    % Increase the length of the header such that the folios 
    % (typography jargon for page numbers) move into the margin
    \fancyhfoffset[LE]{6mm}% slightly less than 0.25in
    \fancyhfoffset[RO]{6mm}%
    % Put some space and a vertical bar between the folio and the rest of the header
    }

    \renewcommand{\headrulewidth}{1.5pt}

\fancyhead[lo]{\slshape\nouppercase{\rightmark}}
\fancyhead[re]{\slshape\nouppercase{\leftmark}}
\fancyhead[ro, le]{\thepage}

\makeatletter
\let\@oddfoot\@empty
\let\@evenfoot\@empty
\makeatother

\usepackage{longtable}

\usepackage[headsep=.25in, textheight=675pt]{geometry}

\dominitoc
\titleformat*{\subsubsection}{\normalsize\itshape}
\usepackage{thmtools}
\renewcommand{\listtheoremname}{List of theorems}

\begin{document}

答案1

正如评论中所述,您可以通过geometry预先加载fancyhdr及其设置来解决此问题。

相关内容