我需要使用 exam 类将一些文本插入页眉和页脚的边距中。我找到的所有解决方案都使用 fancyhdr 包,但它冲突与考试类中定义的\lhead
。\rhead
本质上我想复制 \fancyhfoffset[R]{0.4in}
但使用考试类。我尝试在 .sty 中查找 fancyhdr,但它远远超出了我的理解范围...
编辑:很抱歉,我以为没有 MWE 我的问题就足够清楚了。
我想将此页脚(和页眉)向右移动 0.4 英寸(如右箭头所示)。MWE 如下:
\documentclass[12pt]{exam}
\usepackage{amsmath}
\usepackage[a4paper]{geometry}
\geometry{verbose,tmargin=1in,bmargin=1in,lmargin=0.8in,rmargin=1.2in}
\setlength{\parskip}{\smallskipamount}
\setlength{\parindent}{0pt}
\usepackage{mathtools}
\usepackage{graphicx}
\usepackage{lipsum}
\geometry{showframe}
\addpoints
\runningfooter%
{}
{}
{\iflastpage{}{
\textbf{Question \thequestion }%
\ifcontinuation{ -- continued}{}\\%
\oddeven{\textbf{TURN OVER}}{}
}
}
%MOVE THIS FOOTER TO THE RIGHT BY 0.4in, same for the header, but I've left it out as the header is even longer which lots of if conditions.
\pagestyle{headandfoot}
\begin{document}
\begin{questions}
\question \lipsum[1]
\begin{parts}
\part[1] \lipsum[2]
\newpage
\part[1] \lipsum[3]
\newpage
\part[1] \lipsum[4]
\newpage
\part[1] \lipsum[5]
\end{parts}
\end{questions}
\end{document}
答案1
解决方案是修补页脚和页眉的命令。你可以尝试
\usepackage{xpatch}
\makeatletter
\patchcmd{\run@fullfoot}{\hbox to \textwidth}{\hbox to \dimexpr\textwidth+0.4in\relax}%
{}{\errmessage{Patching of \noexpand\run@fullfoot failed}}
\makeatother
对于标题来说\run@fullhead
答案2
不确定是否只有‘TURN OVER’才需要被推入边缘,但这里有一个解决方案:
\documentclass[12pt]{exam}
\usepackage{amsmath}
\usepackage[a4paper]{geometry}
\geometry{verbose,tmargin=1in,bmargin=1in,lmargin=0.8in,rmargin=1.2in}
\setlength{\parskip}{\smallskipamount}
\setlength{\parindent}{0pt}
\usepackage{mathtools}
\usepackage{graphicx}
\usepackage{lipsum}
\geometry{showframe}
\addpoints
\runningfooter%
{}
{}
{\iflastpage{}{
\textbf{Question \thequestion }%
\ifcontinuation{ -- continued}{}\\%
\oddeven{\mbox{\rlap{\makebox[0.46in][r]{\textbf{TURN OVER}}}}}{}
}
}
%MOVE THIS FOOTER TO THE RIGHT BY 0.4in, same for the header, but I've left it out as the header is even longer which lots of if conditions.
\pagestyle{headandfoot}
\begin{document}
\begin{questions}
\question \lipsum[1]
\begin{parts}
\part[1] \lipsum[2]
\newpage
\part[1] \lipsum[3]
\newpage
\part[1] \lipsum[4]
\newpage
\part[1] \lipsum[5]
\end{parts}
\end{questions}
\end{document}