11

I'm a professor and I use the exam class very often in LaTeX.

  • \begin{solutionorlines}[4cm] creates 4cm of space for students to answer. When I type \printanswers it shows the answers but it doesn't keep the same space as when the answers are not printed. How can I keep the same space for the question and solution environment?

  • I want the answers to be printed on the same solution lines. There is \fillin[fill this in][12cm] but this doesn't linebreak. Tried also the censor package (\xblackout) but this doesn't make the last line hfill and it's not really the same solutionlines that are provided for the students.

  • Can the characters of the solution be counted and leave proportional more space for handwriting (i.o.w. convert number of characters of the solution to number of lines for the students to answer)?

Here is an example.

\documentclass[11pt,a4paper,addpoints]{exam}
\unframedsolutions
%\printanswers
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{geometry}
\usepackage{calc}
\newgeometry{left=2cm,top=2cm,right=2cm,bottom=2cm}


%----------blanks----------------------
\usepackage{censor}
\censorruledepth=-.2ex
\censorruleheight=.1ex
%\StopCensoring   %text xblackout comes visible or not
%--------------------------------------


\begin{document}
\begin{questions}



\begin{figure*}[h]
\begin{tikzpicture}[rounded corners=5mm]
\path node[rectangle,draw=green,fill=green!8,inner sep=.70cm] {\parbox{\textwidth-1.4cm-\fboxrule}{

\question[2] What is the first question?
\begin{solutionorlines}[4cm]
This box is smaller than when the solutions are not printed. How do I make this the same dimension as when answers are not printed?
\end{solutionorlines}
}};



\end{tikzpicture}
\end{figure*}

\xblackout{This solutionline doesn't fill untill the right margin = bad}

\end{questions}
\end{document}
4
  • It seems that your first and last request are contradictory – Ludenticus Dec 22 '14 at 15:56
  • Also, @bert -- Use the same account for all your StackExchange stuff (TeX.SX being part of StackExchange). It will make your life much easier, trust me :) – Sean Allred Dec 22 '14 at 16:44
  • I'm not sure I understand all the nuances of the question, but as to the \xblackout issue, if you define \censorruledepth=-.1ex you can then do the following: \xblackout{This solutionline doesn't fill untill the right margin = bad}\hrulefill – Steven B. Segletes Dec 22 '14 at 16:55
  • BTW: Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – karlkoeller Dec 22 '14 at 17:40
10

You can specify the height of the parbox so to have it fixed, that is something like

\parbox[t][4.5cm]{\textwidth-1.4cm-\fboxrule}{...}

instead of simply

\parbox{\textwidth-1.4cm-\fboxrule}{...}

In this way you have always the same space, both when the answer is printed and when it's not.

MWE:

\documentclass[11pt,a4paper,addpoints]{exam}
\unframedsolutions
%\printanswers
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{geometry}
\usepackage{calc}
\newgeometry{left=2cm,top=2cm,right=2cm,bottom=2cm}


\begin{document}
\begin{questions}

\begin{figure*}[h]
\begin{tikzpicture}[rounded corners=5mm]
\path node[rectangle,draw=green,fill=green!8,inner sep=.70cm] {\parbox[t][4.5cm]{\textwidth-1.4cm-\fboxrule}{

\question[2] What is the first question?
\begin{solutionorlines}[4cm]
This box is smaller than when the solutions are not printed. How do I make this the same dimension as when answers are not printed?
\end{solutionorlines}
}};

\end{tikzpicture}
\end{figure*}

\end{questions}
\end{document} 

Output (on the left with \printanswersfalse and on the right with \printanswerstrue for comparison):

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.