![lhead和rhead内容的宏制作](https://linux22.com/image/358975/lhead%E5%92%8Crhead%E5%86%85%E5%AE%B9%E7%9A%84%E5%AE%8F%E5%88%B6%E4%BD%9C.png)
平均能量损失
\documentclass[11pt,a4paper]{exam}
\lhead{\fbox{\textbf{LEFT}}}
\newcommand[\macrol]{\lhead{\fbox{\textbf{LEFT}}}}
\rhead{\fbox{\textbf{RIGHT}}}
\newcommand[\macrol]{\lhead{\fbox{\textbf{RIGHT}}}}
\begin{document}
First Page
\newpage
The content of lhead is \macrol.
The content of rhead is \macror.
\end{document}
我的目的是使用宏从文本中的任何位置调用\lhead
或。\rhead
谢谢。
答案1
这是一个做你想做的事情的简单方法:
\documentclass[11pt,a4paper]{exam}
\newcommand\savelhead[1]{\gdef\savedlhead{#1}\lhead{\savedlhead}}
\newcommand\saverhead[1]{\gdef\savedrhead{#1}\rhead{\savedrhead}}
\savelhead{LeftHead}
\saverhead{RightHead}
\begin{document}
First Page
\newpage
Booklet Choice \savedlhead\ or \savedrhead.
\end{document}