
예를 들어 다음 의사 코드와 같이 현재 페이지의 헤더에 사용자 정의 내용을 쓰는 것이 가능합니까?
\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{}}