Hi I trying to make an answer booklet for a mathematics exam which should look something similar as shown in the picture. I need space for writing answers as well as mark allocation for the question being answered.
-
1Can you please show us what you have tried so far?– MenschFeb 15, 2019 at 3:32
-
Probably this question is related to what you want to do; in case you want your boxes to take up the entire page.– BubayaFeb 15, 2019 at 8:50
-
I am totally new. I have just made a title page.– Sam BluezFeb 17, 2019 at 7:08
-
I am sorry, I wasnt quite clear before. I have uploaded part of the question paper and the sample answerbook which i need to make.– Sam BluezFeb 17, 2019 at 7:18
2 Answers
A modified version of the code from the answer to another question. See there for an explanation on how the heights of the boxes are determined such that they take up all available space. Then, putting things in the bottom right corner is simply done by \vfill\hfill Stuff in the bottom right corner
in each box:
Edit: To account for the modified question:
\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}
-
Will this work with exam class?? The question paper is separate from the Answer Booklet. Is it possible to have no spaces between the boxes and to have the points inside the box Feb 17, 2019 at 7:09
-
I am sorry, I wasnt quite clear before. I have uploaded part of the question paper and the sample answerbook which i need to make. Feb 17, 2019 at 7:19
-
@SamBluez: Do you mean, this way? Nothing prevents you from putting arbitrary stuff inside the boxes, nor from having them separate from the problem assignments. The
\nointerlinespace
is for having no space between the boxes.– BubayaFeb 17, 2019 at 13:47
A quick and dirty way
\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}
Edit
Still very dirty, but simple. This needs much improvement.
\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}
You can move the question part to anywhere you want, as it does not relate to the answer part.
-
I am trying to make an answer booklet. The question paper is separate. Is it possible to have a vertical border as well..? Feb 17, 2019 at 7:11
-
@SamBluez You can use a box instead of a pair of rules.– user156344Feb 17, 2019 at 7:14
-
I am sorry, I wasnt quite clear before. I have uploaded part of the question paper and the sample answerbook which i need to make. I honestly am very new. I know very little formattting and creating figures Feb 17, 2019 at 7:19
-
@SamBluez See my edited answer.– user156344Feb 17, 2019 at 7:46