解决方案环境顶部的额外垂直填充

解决方案环境顶部的额外垂直填充

我注意到我的解决方案环境顶部有额外的填充(使用exam类),特别是如果你multicols在解决方案环境内部使用:

![在此处输入图片描述

\documentclass[addpoints]{exam}
\usepackage[utf8]{inputenc}
\usepackage[margin=.75 in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amsfonts,amssymb,amsthm,color,srcltx,enumitem,bm,cancel}
\usepackage{multicol}

%Lengthens \fillin answer lines and raises text above the line so text isn't cut off by the answer line, see documentation http://mirror.utexas.edu/ctan/macros/latex/contrib/exam/examdoc.pdf and this question https://tex.stackexchange.com/questions/352246/vertical-spacing-between-fillin-in-exam 
\setlength\fillinlinelength{6.5cm}
\setlength\answerclearance{1.25ex}

%Answerline to right of question, see https://tex.stackexchange.com/questions/82152/answerline-to-the-right-of-a-question
\usepackage{letltxmacro}% http://ctan.org/pkg/letltxmacro
\usepackage{xpatch}% http://ctan.org/pkg/etoolbox
\xpatchcmd{\answerline}% <cmd>
  {\par\nobreak\vskip\answerskip}% <search>
  {\leaders\hbox{\hskip0.2em .\hskip0.2em}\hskip 0pt plus 1filll}% <replace>
  {}{}% <success><failure>
\xpatchcmd{\answerline}{\fi \par}{\fi}{}{}% Remove line break after \answerline
\makeatletter
\LetLtxMacro{\oldanswerline}{\answerline}
\RenewDocumentCommand{\answerline}{s o}{%
  \begingroup
  \IfBooleanTF{#1}
    {\def\@queslevel{\relax}}% \answerline*
    {}% \answerline
  \IfNoValueTF{#2}
    {\oldanswerline[{}]}% \answerline
    {\oldanswerline[#2]}% \answerline[..]
  \endgroup
}

\renewcommand{\baselinestretch}{1.5}
\printanswers

\begin{document}
\begin{questions}
\question Show that $f(x)=x+8$ and $g(y)=y-8$ are inverses.
\begin{solution}
\begin{multicols}{2}
\begin{align*}
f(g(y))&=(y-8)+8 \\
&= y
\end{align*}
\columnbreak
\begin{align*}
g(f(x)) &= (x+8)-8 \\
&=x
\end{align*}
\end{multicols}
\end{solution}
\end{questions}
\end{document}

一些说明:

  • 我认为\renewcommand{\baselinestretch}{1.5}这会使问题变得更糟,但我不想删除它,因为我喜欢整个文档其余部分的 1.5 间距。

  • 删除前后的空格/空行\columnbreak 有帮助,但这会导致右列高于左列(为什么?)

谢谢!


编辑:感谢 John Kormylo 提出的想法:

\begin{solution}
\abovedisplayskip=0pt
\belowdisplayskip=0pt
\multicolsep=0pt
...
\end{solution}

有没有办法在序言中全局解决这个问题,或者定义一个新的解决方案环境(如solution*?),所以我不必记住为每个解决方案环境编写它?

相关内容