![浮動頁面的 Fancyheader 頁腳](https://rvso.com/image/286962/%E6%B5%AE%E5%8B%95%E9%A0%81%E9%9D%A2%E7%9A%84%20Fancyheader%20%E9%A0%81%E8%85%B3.png)
我正在嘗試使用 保留浮動頁面上的頁碼fancyhdr
。這是我目前的設定:
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{lastpage}
\usepackage{fancyhdr}
\pagestyle{fancy}
% with this we ensure that the chapter and section
% headings are in lowercase.
%\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{\iffloatpage{}{\thesection.\ #1}}}
\fancyhf{} % delete current setting for header and footer
\fancyhead[LE,RO]{\iffloatpage{}{\textbf{Page \thepage\ of \pageref{LastPage}}}}
\fancyhead[LO]{\iffloatpage{}{\textbf\rightmark}}
\fancyhead[RE]{\iffloatpage{}{\textbf\leftmark}}
\renewcommand{\headrulewidth}{\iffloatpage{0pt}{0.5pt}}
\renewcommand{\footrulewidth}{0pt}
\renewcommand{\headsep}{10pt}
\iffloatpage{\cfoot{\textbf{Page \thepage\ of \pageref{LastPage}}}}{}
\addtolength{\headheight}{\baselineskip} % make space for the rule
\fancypagestyle{plain}{%
\fancyhead{} % get rid of headers on plain pages
\renewcommand{\headrulewidth}{0pt} % and the line
}
\begin{document}
\begin{figure}
\includegraphics{demo}
\end{figure}
\end{document}
不幸的是,我認為可以做我想做的事情()的那一行\iffloatpage{\cfoot{\textbf{Page \thepage\ of \pageref{LastPage}}}}{}
什麼也沒做。我究竟做錯了什麼?
答案1
反過來你也需要它:
\fancyfoot[C]{\iffloatpage{\textbf{Page \thepage\ of \pageref{LastPage}}}{}}
代碼:
\documentclass[twoside]{article}
\usepackage[demo]{graphicx}
\usepackage{lastpage}
\usepackage{fancyhdr}
\pagestyle{fancy}
% with this we ensure that the chapter and section
% headings are in lowercase.
%\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{\iffloatpage{}{\thesection.\ #1}}}
\fancyhf{} % delete current setting for header and footer
\fancyhead[LE,RO]{\iffloatpage{}{\textbf{Page \thepage\ of \pageref{LastPage}}}}
\fancyhead[LO]{\iffloatpage{}{\textbf\rightmark}}
\fancyhead[RE]{\iffloatpage{}{\textbf\leftmark}}
\fancyfoot[C]{\iffloatpage{\textbf{Page \thepage\ of \pageref{LastPage}}}{}}
\renewcommand{\headrulewidth}{\iffloatpage{0pt}{0.5pt}}
\renewcommand{\footrulewidth}{0pt}
\renewcommand{\headsep}{10pt}
\addtolength{\headheight}{\baselineskip} % make space for the rule
\fancypagestyle{plain}{%
\fancyhead{} % get rid of headers on plain pages
\renewcommand{\headrulewidth}{0pt} % and the line
}
\begin{document}
\begin{figure}
\includegraphics{demo}
\end{figure}
\end{document}
我添加了twoside
班級選項;否則,E
沒有O
任何用處。