我正在写一份报告,我在序言中用了下面这句话
\rfoot{Page \thepage \hspace{1pt}/\hspace{1pt}$11$}
一切都很好,除了当我使用 \chapter 时,因为它会将其转换为普通的页数,而无需写页面 blabla/blabla
您能向我解释一下如何纠正这个问题,并让它在我使用章节时写入 Page blabla / blabla 吗?
根据要求的代码:
\documentclass[12pt, openany]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[a4paper,left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage[frenchb]{babel}
\usepackage{libertine}
\usepackage[pdftex]{graphicx}
\usepackage{amsfonts,amsmath,amssymb,amsxtra}
\usepackage{mathrsfs}
\usepackage[T1]{fontenc}
\usepackage{pst-all}
\usepackage{pstricks-add}
\usepackage{natbib}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{titlesec}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\rfoot{Page \thepage \hspace{1pt}/\hspace{1pt}$11$}
\begin{document}
text
\newpage
\chapter{text}
\end{document}
答案1
在标准类中,\chapter
将章节页面的页面样式设置为plain
,因此您必须重新定义它:
\documentclass[12pt, openany]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[a4paper,left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage[frenchb]{babel}
\usepackage{libertine}
\usepackage[pdftex]{graphicx}
\usepackage{amsfonts,amsmath,amssymb,amsxtra}
\usepackage{mathrsfs}
\usepackage[T1]{fontenc}
\usepackage{pst-all}
\usepackage{pstricks-add}
\usepackage{natbib}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{titlesec}
\usepackage{fancyhdr}
\usepackage{lipsum}
\fancypagestyle{plain}{%
\fancyhf{} %
\rfoot{Page \thepage \hspace{1pt}/\hspace{1pt}$11$}
\renewcommand{\headrulewidth}{0pt}}
\pagestyle{fancy}
\fancyhf{}
\rfoot{Page \thepage \hspace{1pt}/\hspace{1pt}$11$}
\begin{document}
text
\newpage
\chapter{text}
\lipsum
\end{document}
答案2
您可以使用页面样式fancyplain
。然后,使用页面样式,可以轻松地将相同的内容用于普通页面和其他页面fancyhdr
:
\documentclass[12pt, openany]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[a4paper,left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage[frenchb]{babel}
\usepackage{libertine}
\usepackage{graphicx}% option pdftex removed
\usepackage{amsfonts,amsmath,amssymb,amsxtra}
\usepackage{mathrsfs}
%\usepackage[T1]{fontenc}% do not load packages twice
\usepackage{pst-all}
\usepackage{pstricks-add}
\usepackage{natbib}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{titlesec}
\usepackage{fancyhdr}
\usepackage{lipsum}
\usepackage{lastpage}% <- added
\pagestyle{fancyplain}
\fancyhf{}
\fancyhead[C]{\fancyplain{plain page}{other page}}% different contents for plain and other pages
\fancyfoot[R]{\thepage \hspace{1pt}/\hspace{1pt}\pageref{LastPage}}
\begin{document}
text
\newpage
\chapter{text}
\lipsum
\end{document}
结果: