与 header 相关的问题

与 header 相关的问题

我正在使用以下代码

\documentclass[12pt,a4paper]{report}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Useful Packages %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%---------------------math---------------------------------------
\usepackage{amssymb,amsmath,amsthm,latexsym,mathrsfs,amsfonts,dsfont}
\usepackage{mathtools, nccmath} % new extention de amsmath
%---------------------divers---------------------------------------
\usepackage{pifont} %ding
\usepackage{fancybox} %pour faire l'encadrement
\usepackage{graphicx}
\usepackage{color}
\usepackage[final]{pdfpages}
\usepackage{url}
%\usepackage[notref,notcite]{showkeys}
\usepackage{fancyvrb}
\VerbatimFootnotes % allows verbatim text in footnotes
%-------------------------hyperref------------------------------

\usepackage{setspace}
%\usepackage[colorlinks=true,pagebackref=true]{hyperref}
%\usepackage[colorlinks=true]{hyperref}
%\hypersetup{urlcolor=blue, citecolor=red , linkcolor= blue}

%------------
%--------------------------accent-------------------------
 \usepackage[utf8]{inputenc}
 \usepackage[T1]{fontenc}
%---------------------------------------------------------
%-------réduire le mot reference----------
\usepackage{etoolbox}
\patchcmd{\thebibliography}{\section}{\subsection}{}{}
%------
%------minimiser l'espace entre les reference----
\makeatletter
\g@addto@macro\@openbib@code{\setlength{\itemsep}{0pt}}
\makeatother
%-----------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Style des titres%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%-------------------------------------------
\usepackage{sectsty}
\allsectionsfont{\sffamily}
%---- Dimensions des marges --------------------
\usepackage{geometry}
\geometry{left=3cm,right=2cm,top=2.5cm,bottom=2cm}
\usepackage{setspace}
\onehalfspacing
%---------------------écriture foncé-----------
%\usepackage{mathptmx} % pour avoir une écriture bien foncée
%\usepackage{helvet}
%----------------------------------------------
%-----------------------------------------------------------
\newtheorem{theorem}{Theorem}[section]
\newtheorem{definition}{Definition}[section]
\newtheorem{definitions}{Definitions}[section]
\newtheorem{notation}{Notation}[section]
\newtheorem{corollary}{Corollary}[section]
\newtheorem{proposition}{Proposition}[section]
\newtheorem{lemma}{Lemma}[section]
\newtheorem{remark}{Remark}[section]
\newtheorem{example}{Example}[section]
\newtheorem{examples}{Examples}[section]
\numberwithin{equation}{section}
%-----------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand{\qedsymbol}{$\blacksquare$}
\let\origproofname\proofname
\renewcommand{\proofname}{\upshape\bfseries\origproofname}

\newenvironment{dem}{{\noindent {\bf Sketch of Proof.}}}{\hfill {\rule{2mm}{2mm}}}

\newenvironment{pr}{{\noindent {\bf Second Proof of}}}{\hfill {\rule{3mm}{3mm}}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%-----------------------------head and foot--------------------------------
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
\fancyhf{} % supprime les en-têtes et pieds pr\'ed\'efinis
\fancyhead[L,R]{\bfseries\thepage}% Left Even, Right Odd
\fancyhead[L]{\bfseries\rightmark} % Left Odd
\fancyhead[R]{\bfseries\leftmark} % Right Even
\fancyfoot[LE,RO]{\textbf{ }} %ici ecrire cooperate

\renewcommand{\headrulewidth}{1.pt}% filet en haut de page
\renewcommand{\footrulewidth}{0.pt}% filet en bas de page

\newcommand{\clearemptydoublepage}{%
\newpage{\pagestyle{plain}\cleardoublepage}}
\rhead{\textbf{\thepage}} %{\textsl{\rightmark}}
\lhead{\textsl{\nouppercase{\leftmark}}}%{\textbf{\thepage}}
\lfoot{\footnotesize{\textbf{}}}  % titre de la these
\setlength{\headheight}{14.5pt}
%-------------------------------------------------------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%-------Chapter style-------------------------------------------------
\usepackage{titlesec}
\usepackage{tabularx}
\titleformat{\chapter}[display]{\filcenter\Huge\scshape\bfseries}{\begin{tabularx}{\textwidth}{@{}XcX@{}}\titlerule[5pt]& \large\mdseries\raisebox{-1.05ex}{\chaptername\enspace\arabic{chapter}} & \titlerule[5pt]\end{tabularx}}{-1ex}{\hrule\vspace{1ex} }[\vspace{0.75ex}\endgraf\hrule]
\titlespacing*{\chapter}{0pt}{-8ex}{20ex}

\titleformat{name=\chapter, numberless}[display]{\filcenter\Huge\bfseries}%
{\titlerule[5pt]}{-2.2ex}{\hrule\vspace{1.5ex}}[\vspace{0.75ex}\endgraf\hrule]

%-----------This chapter contains--------------
\usepackage{etoc}
\usepackage{blindtext}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%-------------------------
%\pagestyle{plain} % les numérotations en pieds de page

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\begin{document}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
     \chapter{INTRODUCTION}
 \newpage
 Let us
 \newpage
 Let us

\end{document} 

编译后,我得到

在此处输入图片描述在此处输入图片描述

我想反转章节名称和第 3 页的数字之间的顺序。如下所示

在此处输入图片描述

答案1

您需要更改以下定义fancyhdr

\fancyhead[EL,OR]{\bfseries\thepage}% Left Even, Right Odd
\fancyhead[OL]{\bfseries\leftmark} % Left Odd rightmark
\fancyhead[ER]{\bfseries\leftmark} % Right Even

并注释掉错误的命令:

%\rhead{\textbf{\thepage}} %{\textsl{\rightmark}}
%\lhead{\textsl{\nouppercase{\leftmark}}}%{\textbf{\thepage}}
%\lfoot{\footnotesize{\textbf{}}}  % titre de la these

并且不要忘记添加类twoside选项report

使用以下 MWE

\documentclass[%
  12pt,a4paper,
  twoside
]{report}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Useful Packages %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%---------------------math---------------------------------------
\usepackage{amssymb,amsmath,amsthm,latexsym,mathrsfs,amsfonts,dsfont}
\usepackage{mathtools, nccmath} % new extention de amsmath
%---------------------divers---------------------------------------
\usepackage{pifont} %ding
\usepackage{fancybox} %pour faire l'encadrement
\usepackage{graphicx}
\usepackage{color}
\usepackage[final]{pdfpages}
\usepackage{url}
%\usepackage[notref,notcite]{showkeys}
\usepackage{fancyvrb}
\VerbatimFootnotes % allows verbatim text in footnotes
%-------------------------hyperref------------------------------

\usepackage{setspace}
%\usepackage[colorlinks=true,pagebackref=true]{hyperref}
%\usepackage[colorlinks=true]{hyperref}
%\hypersetup{urlcolor=blue, citecolor=red , linkcolor= blue}

%------------
%--------------------------accent-------------------------
 \usepackage[utf8]{inputenc}
 \usepackage[T1]{fontenc}
%---------------------------------------------------------
%-------réduire le mot reference----------
\usepackage{etoolbox}
\patchcmd{\thebibliography}{\section}{\subsection}{}{}
%------
%------minimiser l'espace entre les reference----
\makeatletter
\g@addto@macro\@openbib@code{\setlength{\itemsep}{0pt}}
\makeatother
%-----------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Style des titres%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%-------------------------------------------
\usepackage{sectsty}
\allsectionsfont{\sffamily}
%---- Dimensions des marges --------------------
\usepackage{geometry}
\geometry{left=3cm,right=2cm,top=2.5cm,bottom=2cm}
\usepackage{setspace}
\onehalfspacing
%---------------------écriture foncé-----------
%\usepackage{mathptmx} % pour avoir une écriture bien foncée
%\usepackage{helvet}
%----------------------------------------------
%-----------------------------------------------------------
\newtheorem{theorem}{Theorem}[section]
\newtheorem{definition}{Definition}[section]
\newtheorem{definitions}{Definitions}[section]
\newtheorem{notation}{Notation}[section]
\newtheorem{corollary}{Corollary}[section]
\newtheorem{proposition}{Proposition}[section]
\newtheorem{lemma}{Lemma}[section]
\newtheorem{remark}{Remark}[section]
\newtheorem{example}{Example}[section]
\newtheorem{examples}{Examples}[section]
\numberwithin{equation}{section}
%-----------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand{\qedsymbol}{$\blacksquare$}
\let\origproofname\proofname
\renewcommand{\proofname}{\upshape\bfseries\origproofname}

\newenvironment{dem}{{\noindent {\bf Sketch of Proof.}}}{\hfill {\rule{2mm}{2mm}}}

\newenvironment{pr}{{\noindent {\bf Second Proof of}}}{\hfill {\rule{3mm}{3mm}}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%-----------------------------head and foot--------------------------------
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
\fancyhf{} % supprime les en-têtes et pieds pr\'ed\'efinis
\fancyhead[EL,OR]{\bfseries\thepage}% Left Even, Right Odd
\fancyhead[OL]{\bfseries\leftmark} % Left Odd rightmark
\fancyhead[ER]{\bfseries\leftmark} % Right Even
\fancyfoot[LE,RO]{\textbf{ }} %ici ecrire cooperate

\renewcommand{\headrulewidth}{1.pt}% filet en haut de page
\renewcommand{\footrulewidth}{0.pt}% filet en bas de page

\newcommand{\clearemptydoublepage}{%
\newpage{\pagestyle{plain}\cleardoublepage}}
%\rhead{\textbf{\thepage}} %{\textsl{\rightmark}}
%\lhead{\textsl{\nouppercase{\leftmark}}}%{\textbf{\thepage}}
%\lfoot{\footnotesize{\textbf{}}}  % titre de la these
\setlength{\headheight}{14.5pt}
%-------------------------------------------------------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%-------Chapter style-------------------------------------------------
\usepackage{titlesec}
\usepackage{tabularx}
\titleformat{\chapter}[display]{\filcenter\Huge\scshape\bfseries}{\begin{tabularx}{\textwidth}{@{}XcX@{}}\titlerule[5pt]& \large\mdseries\raisebox{-1.05ex}{\chaptername\enspace\arabic{chapter}} & \titlerule[5pt]\end{tabularx}}{-1ex}{\hrule\vspace{1ex} }[\vspace{0.75ex}\endgraf\hrule]
\titlespacing*{\chapter}{0pt}{-8ex}{20ex}

\titleformat{name=\chapter, numberless}[display]{\filcenter\Huge\bfseries}%
{\titlerule[5pt]}{-2.2ex}{\hrule\vspace{1.5ex}}[\vspace{0.75ex}\endgraf\hrule]

%-----------This chapter contains--------------
\usepackage{etoc}
\usepackage{blindtext}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%-------------------------
%\pagestyle{plain} % les numérotations en pieds de page

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\begin{document}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
     \chapter{INTRODUCTION}
 \newpage
 Let us
 \newpage
 Let us

\end{document} 

你得到第 2 页

在此处输入图片描述

和第 3 页

在此处输入图片描述

请注意,通常页码在外侧,章节名称在内侧,例如:

odd side:  chapter name         page number
even side: page number          chaptername

相关内容