![Rodapé Fancyheader para páginas flutuantes](https://rvso.com/image/286962/Rodap%C3%A9%20Fancyheader%20para%20p%C3%A1ginas%20flutuantes.png)
Estou tentando manter o número da página nas páginas flutuantes usando fancyhdr
. Aqui está minha configuração atual:
\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}
Infelizmente a linha que pensei que faria o que eu queria ( \iffloatpage{\cfoot{\textbf{Page \thepage\ of \pageref{LastPage}}}}{}
) não está fazendo nada. O que estou fazendo de errado?
Responder1
Você precisa do contrário:
\fancyfoot[C]{\iffloatpage{\textbf{Page \thepage\ of \pageref{LastPage}}}{}}
O código:
\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}
Adicionei a twoside
opção de classe; caso contrário, E
e O
não tem utilidade.