如何删除不需要的垂直空间?

如何删除不需要的垂直空间?

我正在使用 Exam 类来创建解决方案,但 flaign* 环境没有将我的方程式与 \part 对齐。我该如何让它们对齐?

\documentclass[a4paper, twoside, 12pt]{exam}

\usepackage{amssymb,amsmath}
\usepackage{graphicx}
\marksnotpoints
\pointsinrightmargin 
\bracketedpoints
\printanswers

\begin{document}
\begin{questions}

\question  The functions $f$ and $g$ are defined by 
\begin{align*}
f : x &\mapsto 4-x^2, \ \ x \in \mathbb{R} \\ 
g : x &\mapsto \frac{1}{x-4}, \ \ x\in \mathbb{R}, \ x \not= 4.
\end{align*}
\begin{parts}
   \part[3] Define $f\circ g$ in a similar form.
\end{parts}

\begin{solution}
\begin{parts}
    \part 
        \begin{flalign*}
            fg(x) &= f(g(x)) &\\ 
            &=f(\frac{1}{x-4}) \\ 
            &= 4 - \frac{1}{(x-4)^2}
        \end{flalign*}
\end{parts}
\end{solution}

具体来说,我的问题就出现在这张图片中: 在此处输入图片描述

答案1

align对于 TABstacks 来说,这可能是一个很好的应用程序,与环境不同,它可以内联放置。

\documentclass[a4paper, twoside, 12pt]{exam}

\usepackage{amssymb,amsmath}
\usepackage{tabstackengine}
\stackMath
\setstackgap{S}{5pt}% GAP BETWEEN ADJACENT STACKED EQUATION ROWS
\usepackage{graphicx}
\marksnotpoints
\pointsinrightmargin 
\bracketedpoints
\printanswers

\begin{document}
\begin{questions}

\question  The functions $f$ and $g$ are defined by 
\begin{align*}
f : x &\mapsto 4-x^2, \ \ x \in \mathbb{R} \\ 
g : x &\mapsto \frac{1}{x-4}, \ \ x\in \mathbb{R}, \ x \not= 4.
\end{align*}
\begin{parts}
   \part[3] Define $f\circ g$ in a similar form.
\end{parts}

\begin{solution}
\begin{parts}
    \part 
        \alignShortunderstack{
            fg(x) =& f(g(x)) \\ 
            =&f(\dfrac{1}{x-4}) \\ 
            =& 4 - \dfrac{1}{(x-4)^2}
        }
\end{parts}
\end{solution}
\end{questions}
\end{document} 

在此处输入图片描述

如果总是想处理 TABstack 参数\displaystyle,可以将这个未记录的代码添加到序言中

\makeatletter
\renewcommand\TAB@delim[1]{\displaystyle#1}
\makeatother

答案2

您必须在此处使用内联数学。可能如下所示:

% arara: pdflatex

\documentclass[a4paper, twoside, 12pt]{exam}
\usepackage{amssymb,mathtools}
\marksnotpoints
\pointsinrightmargin 
\bracketedpoints
\printanswers

\begin{document}
    \begin{questions}       
        \question  The functions $f$ and $g$ are defined by 
        \begin{alignat*}{2}
        f : x &\mapsto 4-x^2,  &&\quad x\in \mathbb{R} \\ 
        g : x &\mapsto \frac{1}{x-4}, &&\quad x\in \mathbb{R} \vee x \not= 4.
        \end{alignat*}
        \begin{parts}
            \setcounter{partno}{2} % for demo only
            \part[3] Define $f\circ g$ in a similar form.
        \end{parts}
        \begin{solution}
            \begin{parts}
            \setcounter{partno}{2} % for demo only
                \part 
                $\!\begin{aligned}[t]
                f(x)\circ g(x) &= f(g(x)) &\\ 
                &= f\Bigl(\frac{1}{x-4}\Bigr) \\ 
                &= 4 - \frac{1}{(x-4)^2}
                \end{aligned}$
            \end{parts}
        \end{solution}  
\end{questions} 
\end{document}

在此处输入图片描述

相关内容