
是否可以將自訂內容寫入目前頁面的標題中,例如像這樣的偽代碼
\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}
對我來說重要的是一切都在本地完成。我不想為每個手動標題文字全局定義不同的花俏標題樣式。
答案1
只要你願意將頁面定義為一個群組,就相對容易
\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}
目前尚不清楚您希望標頭在組外如何表現。也許像
\newcommand{\resetheaders}{\def\headerL{}\def\headerC{}\def\headerR{}}