答案1
代码的修改版本来自回答另一个问题\vfill\hfill Stuff in the bottom right corner
。请参阅那里的解释,了解如何确定框的高度,以便它们占据所有可用空间。然后,只需在每个框中将东西放在右下角即可:
编辑:解释修改后的问题:
\documentclass[a4paper]{scrartcl}
\makeatletter
\newif\ifresetboxes
% Remaining space on the current page.
\def\restofpage{\dimexpr\pagegoal-\pagetotal-\baselineskip\relax}
% Save available space of current group to the aux file.
\newlength\restofpage@lastrun
\newcounter{vfill@write@groups}
\newcommand{\saverestofpage}{
\stepcounter{vfill@write@groups}%
% Name of the macro the rest of the page is to be saved to.
\def\length@name{restofpage@\roman{vfill@write@groups}}%
% Rest of this page from last compilation. If undefined or if reset mode,
% set this to 0pt.
\expandafter\ifcsname\length@name\endcsname
\expandafter\expandafter\expandafter\restofpage@lastrun\expandafter\expandafter\expandafter=\expandafter\csname\length@name\endcsname
\else
\setlength{\restofpage@lastrun}{0pt}
\fi%
\ifresetboxes
\setlength{\restofpage@lastrun}{0pt}
\fi
% Save new rest of page = old rest of page + current rest of page.
\immediate\write\@auxout{%
\noexpand\global\noexpand\@namedef{\length@name}{%
\the\dimexpr
\restofpage / \thevfillboxes + \restofpage@lastrun
\relax
}
}
\typeout{Total space available: \the\restofpage}
\typeout{Boxes on this page: \thevfillboxes}
\setcounter{vfillboxes}{0}
\resetboxesfalse
}
% Read available space for the next group from the aux file.
\newlength\remainingspace@perbox
\newcounter{vfill@read@groups}
\newcommand{\getrestofpage}{
% Define macros for the names values for the current page are to be read from.
\stepcounter{vfill@read@groups}
\def\length@name{restofpage@\roman{vfill@read@groups}}
% Set \remainingspace to the value of the length named by \length@name
\ifresetboxes
\setlength{\remainingspace@perbox}{0pt}
\else
\setlength{\remainingspace@perbox}{
\expandafter\ifcsname\length@name\endcsname%
\expandafter\csname\length@name\endcsname
\else
0pt
\fi
}
\fi%
% Make setting global
\global\remainingspace@perbox=\remainingspace@perbox%
}
% Produce a box that consumes all available space,
% shared evenly among all boxes of this group.
\newcounter{vfillboxes}
\newcommand{\vfillbox}[2][\dimexpr\linewidth-2\fboxrule-2\fboxsep\relax]{%
\stepcounter{vfillboxes}%
\parbox[t][\remainingspace@perbox][t]{#1}{%
#2
}%
}
% Same as previous, with additional proportiality factor.
\newcommand{\Vfillbox}[3][\dimexpr\linewidth-2\fboxrule-2\fboxsep]{%
\addtocounter{vfillboxes}{2}%
\parbox[t][2\remainingspace@perbox][t]{#1}{%
#3
}%
}
\makeatother
\newcounter{problem}
\renewcommand{\theproblem}{\arabic{problem}. }
\begin{document}
%\resetboxestrue
\getrestofpage
\noindent Please justify all your answers to the following questions.
\begin{enumerate}
\item Is this = that?\hfill 2 points
\item Is this = that?\hfill 2 points
\item Is this = that?\hfill 2 points
\end{enumerate}
\noindent
\fbox{%
\Vfillbox{3}{%
\stepcounter{problem}\theproblem Solve $x+2=3$.
\vfill
\hfill $x=\rule{1in}{1pt}$
\hfill (3 marks)%
}%
}
\nointerlineskip
\noindent%
\fbox{%
\vfillbox{%
\stepcounter{problem}\theproblem Question
\vfill
\hfill
Solution%
}%
}
\saverestofpage
\end{document}
答案2
一种快速而肮脏的方法
\documentclass{exam}
\begin{document}
Calculate the values of
\begin{questions}
\question $1+2$
\vspace*{3cm}
\begin{flushright}
$1+2=$ \rule{1cm}{.1pt}
(2 points)
\end{flushright}
\vspace{5pt}
\hrule
\vspace{5pt}
\question $3+4$
\vspace*{3cm}
\begin{flushright}
$3+4=$ \rule{1cm}{.1pt}
(2 points)
\end{flushright}
\end{questions}
\end{document}
编辑
仍然很脏,但很简单。这需要很大的改进。
\documentclass{exam}
\usepackage{calc}
\begin{document}
\begin{questions}
\question Solve $x+2=3$. \hfill (2 marks)
\question Calculate the value of $1+2+3+4+\frac12$. \hfill (3 marks)
\question Ann had a banana. Her mother just gave her one more. How many bananas does Ann have? \hfill (1 mark)
\end{questions}
\noindent\fbox{
\parbox{\textwidth-2\fboxsep}{
1. Solve $x+2=3$.
\vspace*{1.5in}
\begin{flushright}
$x= \rule{1in}{1pt}$\\[2ex]
(2 marks)
\end{flushright}
}
}
\noindent\fbox{
\parbox{\textwidth-2\fboxsep}{
2. Calculate the value of $1+2+3+4+\frac12$.
\vspace*{2.5in}
\begin{flushright}
$1+2+3+4+\frac12= \rule{1in}{1pt}$\\[2ex]
(3 marks)
\end{flushright}
}
}
\noindent\fbox{
\parbox{\textwidth-2\fboxsep}{
3. Ann had a banana. Her mother just gave her one more. How many bananas does Ann have?
\vspace{1in}
\begin{flushright}
Ann have \rule{1in}{1pt} bananas\\[2ex]
(1 mark)
\end{flushright}
}
}
\end{document}
您可以将问题部分移动到任何您想要的位置,因为它与答案部分无关。