フロートページ用のファンシーヘッダーフッター

フロートページ用のファンシーヘッダーフッター

私は を使用してフロート ページ上のページ番号を保持しようとしています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。それ以外の場合EO役に立ちません。

関連情報