6

Is it possible to write something custom into the header of the current page for example like this pseudocode

\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}

It's important for me that everything is done locally. I don't want to define different fancy header styles globally for each manual header text.

4

As long as you are willing to define the pages in a group, it is relatively easy

\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}

It is not really clear how you want the headers to behave outside the groups. Maybe something like

\newcommand{\resetheaders}{\def\headerL{}\def\headerC{}\def\headerR{}}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.