5

I want to generate a problem booklet that provides a more accurate space after each question. As I always make the solution as general as possible, I think I can use the size of my solution for the size of the associated blank space. I don't want to use \examspace with hard-coded dimension as follows. How to implement my idea?

\documentclass[preview,border=12pt,varwidth]{standalone}

\usepackage{mathtools}
\usepackage{exsheets}

\SetupExSheets
{
    question/name=Question,
    solution/name=Answer,
    solution/print=true,
}

\begin{document}

\begin{question}
Solve $2(x-1) - \frac{2}{3}(3-2x) = 1 - 2(2-3x)$.
\examspace{10\baselineskip}
\end{question}

\begin{solution}
\begin{gather*}
2(x-1) - \frac{2}{3}(3-2x) = 1 - 2(2-3x) \\
\intertext{multiply both sides by 3}
3\times\left(2(x-1) - \frac{2}{3}(3-2x)\right) = 3\times\left(1 - 2(2-3x)\right) \\
6(x-1) - 2(3-2x) = 3 - 6(2-3x) \\
6x - 6 -6 +4x = 3 -12 +18x \\
10x -12 = -9 + 18x\\
10x -18x = -9 +12\\
-8x = 3\\
x = \frac{3}{-8}\\
x = -\frac{3}{8}
\end{gather*}
\end{solution}

\end{document}

enter image description here

Moriambar
  • 11,466

1 Answers1

3

cgnieder has provided a good idea in comment, here is a code that implemented it:

\documentclass[preview,border=12pt,varwidth]{standalone}

\usepackage{mathtools}
\usepackage{exsheets}

\SetupExSheets
{
    question/name=Question,
    solution/name=Answer,
    solution/print=true,
}

\begin{document}

\newbox\solboxone
\setbox\solboxone\vbox{
\begin{gather*}
2(x-1) - \frac{2}{3}(3-2x) = 1 - 2(2-3x) \\
\intertext{multiply both sides by 3}
3\times\left(2(x-1) - \frac{2}{3}(3-2x)\right) = 3\times\left(1 - 2(2-3x)\right) \\
6(x-1) - 2(3-2x) = 3 - 6(2-3x) \\
6x - 6 -6 +4x = 3 -12 +18x \\
10x -12 = -9 + 18x\\
10x -18x = -9 +12\\
-8x = 3\\
x = \frac{3}{-8}\\
x = -\frac{3}{8}
\end{gather*}
}

\begin{question}
Solve $2(x-1) - \frac{2}{3}(3-2x) = 1 - 2(2-3x)$a.
\vspace{\ht\solboxone}
\end{question}

\begin{solution}
\usebox\solboxone
\end{solution}

\end{document}
ShreevatsaR
  • 45,428
  • 10
  • 117
  • 149
Francis
  • 6,183
  • +1 : But the user interface is not so friendly. :-) – kiss my armpit Sep 12 '13 at 08:46
  • 3
    You will also want to consider adding a multiplication factor (>1) for the box height when the answers are handwritten and will take more space than printed ones. – Masroor Sep 12 '13 at 09:08
  • I would like to use "vtop" instead of "vbox", but it seems that the variable "\ht\solboxone" is taken as zero when I replace "vbox" with "vtop" in the code above.

    Any workaround?

    – Leonardo Castro Dec 12 '15 at 18:03
  • 1
    @LeonardoCastro: try \dp\solboxone instead of \ht\solboxone. – Francis Dec 12 '15 at 19:16
  • @Francis Ah, now I understand. Boxes have height and depth. – Leonardo Castro Dec 12 '15 at 19:52
  • Apparently, I can't use this same variable "solboxone" for multiple solutions, writing \setbox\solboxone again and again. I guess that's because solboxone will always refer to the same object instance. It's boring to create a new box name for each question. – Leonardo Castro Dec 13 '15 at 20:49
  • @LeonardoCastro: I am pretty sure you can, just make sure \setbox after each instance of \usebox – Francis Dec 14 '15 at 03:52
  • @Francis Are you sure that works even if I choose to print all solutions only at the end of the chapter? – Leonardo Castro Dec 14 '15 at 11:27
  • @LeonardoCastro: oh, I guess that won't work. Old solboxone will be replaced by newly defined one. – Francis Dec 14 '15 at 14:45