如何在页眉中添加一个框?(考试文档类)

如何在页眉中添加一个框?(考试文档类)

我想将一个框包含在页眉中,而不是在每一页中手动重复它。我该如何实现?

\documentclass[addpoints, 12pt]{exam}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage[nameinlink]{cleveref}

\pagestyle{headandfoot}
\firstpageheader{\large\bfseries Astronomy Exam\\ \bigskip
\large\bfseries Last Name:\enspace\makebox[1.9in]{\hrulefill}}
{}
{\large\bfseries Univ ID: \makebox[2in]{\hrulefill} \\  \bigskip
 \large\bfseries First Name:\enspace\makebox[2in]{\hrulefill}}
\runningheader{\large\bfseries Last Name:\enspace\makebox[1.9in]{\hrulefill}}
{}
{\large\bfseries First Name:\enspace\makebox[2in]{\hrulefill}}
\firstpagefooter{}{}{}
\runningfooter{}{\thepage}{}

\begin{document}

\begin{center}
\fbox{\fbox{\parbox{5.5in}{\centering
Answer the questions in the spaces provided on the
answer sheets.}}}
\end{center}

\begin{questions}

\question

\newpage

\begin{center}
\fbox{\fbox{\parbox{5.5in}{\centering
Answer the questions in the spaces provided on the
answer sheets.}}}
\end{center}

\question
\end{questions}

\end{document}

答案1

我使用geometry-Package 来调整标题的高度和宽度,以便它能够真正适合页面的顶部。

然后我将左、中、右标题全部合并到左标题中,这样组织和间隔所有内容就容易多了。我尽量坚持你最初的布局。

以下是实际示例:

\documentclass[addpoints, 12pt]{exam}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage[nameinlink]{cleveref}

\usepackage[top=5.5cm,left=2.5cm,right=2.5cm]{geometry}


\pagestyle{headandfoot}
\firstpageheader{\large\bfseries Astronomy Exam  \hspace{4.3cm} Univ ID: \makebox[2in]{\hrulefill}\\ \bigskip
\large\bfseries Last Name:\enspace\makebox[1.9in]{\hrulefill} \large\bfseries
First Name:\enspace\makebox[2in]{\hrulefill}
\begin{center}
    \fbox{\fbox{\parbox{5.5in}{\centering\small
    Answer the questions in the space provided on the
    answer sheets.}}}
\end{center}
}
{}
{}


\runningheader{
    \large\bfseries Last Name:\enspace\makebox[1.9in]{\hrulefill} \large\bfseries
    First Name:\enspace\makebox[2in]{\hrulefill}
    \begin{center}
        \fbox{\fbox{\parbox{5.5in}{\centering\small
        Answer the questions in the space provided on the
        answer sheets.}}}
    \end{center}
}
{}
{}
\firstpagefooter{}{}{}
\runningfooter{}{\thepage}{}

\begin{document}


\begin{questions}

\question This is a question.

\newpage


\question This is another question.
\end{questions}

\end{document}

相关内容