3

I'm using Exam class to create solutions, but the flaign* environment does not align my equation with the \part. How do I make them align?

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

Specifically, my problem is here in this image: enter image description here

3

This might be a good application for TABstacks, which can be placed inline, unlike align environments.

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

enter image description here

If one always wants to process TABstack arguments in \displaystyle, this undocumented code can be added to the preamble

\makeatletter
\renewcommand\TAB@delim[1]{\displaystyle#1}
\makeatother
|improve this answer|||||
  • @jh4 Great! Glad I could help. Note that the default use of the & tab here =& is opposite the preferred way in amsmath approaches &=. See the tabstackengine docs at ctan.org. There are ways to set the processing mode of & tabs in the package, with macros such as \TABunaryLeft, \TABunaryRight, and \TABbinary. – Steven B. Segletes Jun 2 '15 at 12:32
1

You have to use inline math here. Maybe like the following:

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

enter image description here

|improve this answer|||||

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.