如何根据解决方案的大小自动在问题后提供空白?

如何根据解决方案的大小自动在问题后提供空白?

我想生成一本问题手册,在每个问题后提供更准确的空间。由于我总是让解决方案尽可能通用,我认为我可以使用解决方案的大小作为相关空白空间的大小。我不想使用\examspace如下的硬编码尺寸。如何实现我的想法?

\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}

在此处输入图片描述

答案1

cgnieder 在评论中提供了一个很好的想法,下面是实现它的代码:

\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}

相关内容