在页脚环境末尾添加框

在页脚环境末尾添加框

这是我当前的环境:

\documentclass{report}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                              %
%                                Preamble Stuff                                %
%                                                                              %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{extramarks}
\usepackage{fancyhdr}

\pagestyle{fancy}

\author{\hmwkAuthorName}

\fancyhead[L]{\hmwkAuthorName}
\fancyhead[C]{\hmwkClass: \hmwkTitle: \hmwkClassInstructorShortName}
\fancyhead[R]{\firstxmark}
\fancyfoot[L]{\lastxmark}
\fancyfoot[C]{\thepage}

\renewcommand\headrulewidth{0.4pt}
\renewcommand\footrulewidth{0.4pt}

\renewcommand{\part}[1]{\textbf{\large Part \Alph{partCounter}}\stepcounter{partCounter}\\}

\newcounter{countitems}
\newcounter{nextitemizecount}
\newcommand{\setupcountitems}{%
  \stepcounter{nextitemizecount}%
  \setcounter{countitems}{0}%
  \preto\item{\stepcounter{countitems}}%
}

\makeatletter
\newcommand{\computecountitems}{%
  \edef\@currentlabel{\number\c@countitems}%
}
\newcommand{\nextitemizecount}{%
  \getrefnumber{countitems@\number\c@nextitemizecount}%
}
\newcommand{\previtemizecount}{%
  \getrefnumber{countitems@\number\numexpr\value{nextitemizecount}-1\relax}%
}
\makeatother

\newenvironment{AutoMultiColItemize}{%
  \ifnumcomp{\nextitemizecount}{>}{3}{\begin{multicols}{2}}{}%
    \setupcountitems\begin{itemize}}%
    {\end{itemize}%
  \unskip\computecountitems\ifnumcomp{\previtemizecount}{>}{3}{\end{multicols}}{}}

\setcounter{secnumdepth}{0}
\newcounter{partCounter}
\newcounter{homeworkProblemCounter}
\setcounter{homeworkProblemCounter}{1}
\newcounter{homeworkSolutionCounter}
\setcounter{homeworkSolutionCounter}{1}
\nobreak\extramarks{Problem \arabic{homeworkProblemCounter}}{}\nobreak{}

\newcommand{\enterProblemHeader}[1]{
  \nobreak\extramarks{}{
    Problem \arabic{#1} continued on next page \ldots
  }\nobreak{}
  \nobreak\extramarks{
    Problem \arabic{#1} (continued)
  }{
    Problem \arabic{#1} continued on next page \ldots
  }\nobreak{}
}

\newcommand{\exitProblemHeader}[1]{
  \nobreak\extramarks{
    Problem \arabic{#1} (continued)
  }{
    Problem \arabic{#1} continued on next page\ldots
  }\nobreak{}
  \stepcounter{#1}
  \nobreak\extramarks{
    Problem \arabic{#1}
  }{}\nobreak{}
}

\newenvironment{solution}[1][-1]{
  \ifnum#1>0
    \setcounter{homeworkSolutionCounter}{#1}
  \fi
  \section{Solution \arabic{homeworkSolutionCounter}}
  \setcounter{partCounter}{1}
  \enterProblemHeader{homeworkSolutionCounter}
}{
  \exitProblemHeader{homeworkSolutionCounter}
}

\newenvironment{problem}[1][-1]{
  \ifnum#1>0
    \setcounter{homeworkProblemCounter}{#1}
  \fi
  \section{Problem \arabic{homeworkProblemCounter}}
  \setcounter{partCounter}{1}
  \enterProblemHeader{homeworkProblemCounter}
}{
  \exitProblemHeader{homeworkProblemCounter}
}

\title{
  \vspace{2in}
  \textmd{\textmd{\textbf{\hmwkClass:\ \hmwkTitle}}}\\
  \normalsize\vspace{0.1in}\small{Due\ on\ \hmwkDueDate\ at \hmwkDueTime}\\
  \vspace{0.1in}\large{\textit{\hmwkClassInstructor\ \hmwkClassTime}}
  \vspace{3in}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                              %
%                                Main Document                                 %
%                                                                              %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\hmwkTitle}{Title}
\newcommand{\hmwkDueDate}{Date}

\newcommand{\hmwkDueTime}{Time}
\newcommand{\hmwkClass}{Course}
\newcommand{\hmwkClassTime}{Time}
\newcommand{\hmwkClassInstructor}{Professor}
\newcommand{\hmwkClassInstructorShortName}{Professor}
\newcommand{\hmwkAuthorName}{\textbf{Student}}

\begin{document}
  \pagestyle{empty}
  \maketitle

  \pagestyle{fancy}
  \setcounter{page}{1}

  \begin{problem}
    problem
  \end{problem}
  \begin{solution}
    solution
  \end{solution}

  \newpage

  \begin{problem}
    problem
  \end{problem}
  \begin{solution}
    solution
  \end{solution}
\end{document}

这创建了一个不错的作业模板。但是,当我完成解决方案环境时,我想在页脚中添加一个框。例如,有时我的解决方案可能超过 5 页,我只希望在最后一页(第 5 页)有一个框,让我的教授填写我获得了多少分(满分为多少)。

答案1

定义一个新的页面样式boxfooter,在页脚中放置一个框,并在末尾solution添加\thispagestyle{boxfooter}。在某些情况下,分页算法可能会将内容放在错误的页面上,然后需要使用标记的解决方案。但我会首先采用这种解决方案。

我只给出相关的代码部分。

\fancyhead[L]{\hmwkAuthorName}
\fancyhead[C]{\hmwkClass: \hmwkTitle: \hmwkClassInstructorShortName}
\fancyhead[R]{\firstxmark}
\fancyfoot[L]{\lastxmark}
\fancyfoot[C]{\thepage}
\fancyfoot[R]{} % <<<<<< default

\fancypagestyle{boxfooter}{
  \fancyfoot[R]{\setlength\unitlength{1cm}
    \begin{picture}(0,0)
      \put(-1,-0.7){\framebox(1,1)}
    \end{picture}}
}
\newenvironment{solution}[1][-1]{
  \ifnum#1>0
    \setcounter{homeworkSolutionCounter}{#1}
  \fi
  \section{Solution \arabic{homeworkSolutionCounter}}
  \setcounter{partCounter}{1}
  \enterProblemHeader{homeworkSolutionCounter}
}{
  \exitProblemHeader{homeworkSolutionCounter}
  \thispagestyle{boxfooter}% <<<<<< added
}

可以通过改变 来改变盒子的大小\unitlength

在此处输入图片描述

答案2

通过添加amsthm\qed您可以获得所需的输出,并且 MWE 为:

\documentclass{report}
\usepackage{amsthm}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                              %
%                                Preamble Stuff                                %
%                                                                              %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{extramarks}
\usepackage{fancyhdr}

\pagestyle{fancy}

\author{\hmwkAuthorName}

\fancyhead[L]{\hmwkAuthorName}
\fancyhead[C]{\hmwkClass: \hmwkTitle: \hmwkClassInstructorShortName}
\fancyhead[R]{\firstxmark}
\fancyfoot[L]{\lastxmark}
\fancyfoot[C]{\thepage}

\renewcommand\headrulewidth{0.4pt}
\renewcommand\footrulewidth{0.4pt}

\renewcommand{\part}[1]{\textbf{\large Part \Alph{partCounter}}\stepcounter{partCounter}\\}

\newcounter{countitems}
\newcounter{nextitemizecount}
\newcommand{\setupcountitems}{%
  \stepcounter{nextitemizecount}%
  \setcounter{countitems}{0}%
  \preto\item{\stepcounter{countitems}}%
}

\makeatletter
\newcommand{\computecountitems}{%
  \edef\@currentlabel{\number\c@countitems}%
}
\newcommand{\nextitemizecount}{%
  \getrefnumber{countitems@\number\c@nextitemizecount}%
}
\newcommand{\previtemizecount}{%
  \getrefnumber{countitems@\number\numexpr\value{nextitemizecount}-1\relax}%
}
\makeatother

\newenvironment{AutoMultiColItemize}{%
  \ifnumcomp{\nextitemizecount}{>}{3}{\begin{multicols}{2}}{}%
    \setupcountitems\begin{itemize}}%
    {\end{itemize}%
  \unskip\computecountitems\ifnumcomp{\previtemizecount}{>}{3}{\end{multicols}}{}}

\setcounter{secnumdepth}{0}
\newcounter{partCounter}
\newcounter{homeworkProblemCounter}
\setcounter{homeworkProblemCounter}{1}
\newcounter{homeworkSolutionCounter}
\setcounter{homeworkSolutionCounter}{1}
\nobreak\extramarks{Problem \arabic{homeworkProblemCounter}}{}\nobreak{}

\newcommand{\enterProblemHeader}[1]{
  \nobreak\extramarks{}{
    Problem \arabic{#1} continued on next page \ldots
  }\nobreak{}
  \nobreak\extramarks{
    Problem \arabic{#1} (continued)
  }{
    Problem \arabic{#1} continued on next page \ldots
  }\nobreak{}
}

\newcommand{\exitProblemHeader}[1]{
  \nobreak\extramarks{
    Problem \arabic{#1} (continued)
  }{
    Problem \arabic{#1} continued on next page\ldots
  }\nobreak{}
  \stepcounter{#1}
  \nobreak\extramarks{
    Problem \arabic{#1}
  }{}\nobreak{}
}

\newenvironment{solution}[1][-1]{
  \ifnum#1>0
    \setcounter{homeworkSolutionCounter}{#1}
  \fi
  \section{Solution \arabic{homeworkSolutionCounter}}
  \setcounter{partCounter}{1}
  \enterProblemHeader{homeworkSolutionCounter}
}{
\qed  \exitProblemHeader{homeworkSolutionCounter}
}

\newenvironment{problem}[1][-1]{
  \ifnum#1>0
    \setcounter{homeworkProblemCounter}{#1}
  \fi
  \section{Problem \arabic{homeworkProblemCounter}}
  \setcounter{partCounter}{1}
  \enterProblemHeader{homeworkProblemCounter}
}{
  \exitProblemHeader{homeworkProblemCounter}
}

\title{
  \vspace{2in}
  \textmd{\textmd{\textbf{\hmwkClass:\ \hmwkTitle}}}\\
  \normalsize\vspace{0.1in}\small{Due\ on\ \hmwkDueDate\ at \hmwkDueTime}\\
  \vspace{0.1in}\large{\textit{\hmwkClassInstructor\ \hmwkClassTime}}
  \vspace{3in}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                              %
%                                Main Document                                 %
%                                                                              %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\hmwkTitle}{Title}
\newcommand{\hmwkDueDate}{Date}

\newcommand{\hmwkDueTime}{Time}
\newcommand{\hmwkClass}{Course}
\newcommand{\hmwkClassTime}{Time}
\newcommand{\hmwkClassInstructor}{Professor}
\newcommand{\hmwkClassInstructorShortName}{Professor}
\newcommand{\hmwkAuthorName}{\textbf{Student}}

\begin{document}
  \pagestyle{empty}
  \maketitle

  \pagestyle{fancy}
  \setcounter{page}{1}

  \begin{problem}
    problem
  \end{problem}
  \begin{solution}
    solution
  \end{solution}

  \newpage

  \begin{problem}
    problem
  \end{problem}
  \begin{solution}
    solution
  \end{solution}
\end{document}

输出

在此处输入图片描述

相关内容