
¿Es posible escribir algo personalizado en el encabezado de la página actual, por ejemplo, como este pseudocódigo?
\documentclass{article}
\begin{document}
\thispageheader[R]{My Text} %Displays only this in the header
\newpage
\thispageheader[R]{Another Text} %Displays only this in the header
\newpage
\thispageheader[L]{Just another Text on the left} %Displays only this in the header
\end{document}
Para mí es importante que todo se haga localmente. No quiero definir diferentes estilos de encabezado sofisticados globalmente para cada texto de encabezado manual.
Respuesta1
Siempre que esté dispuesto a definir las páginas de un grupo, es relativamente fácil
\documentclass{article}
\usepackage{fancyhdr}
\usepackage{lipsum}
\lhead{\headerL}
\chead{\headerC}
\rhead{\headerR}
\def\headerL{}
\def\headerC{}
\def\headerR{}
\newcommand{\thispageheader}[2][R]{\expandafter\def\csname header#1\endcsname{#2}}
\pagestyle{fancy}
\begin{document}
{\thispageheader[R]{My Text} %Displays only this in the header
\lipsum[1]
\newpage}
{\thispageheader[R]{Another Text} %Displays only this in the header
\lipsum[1]
\newpage}
{\thispageheader[L]{Just another Text on the left} %Displays only this in the header
\lipsum[1]\newpage}
\end{document}
No está realmente claro cómo desea que se comporten los encabezados fuera de los grupos. Tal vez algo como
\newcommand{\resetheaders}{\def\headerL{}\def\headerC{}\def\headerR{}}