3

I wanted this:

enter image description here

Hence my solution was

Solution:
\begin{enumerate}[label=(\alph*)]
\item 
\leavevmode\\[-2.75\baselineskip]
\begin{flalign*}
\mbox{US}\$10 &= \mbox{S}\$10\times1.33&\\
&= \mbox{S}\$13.30&
\end{flalign*}
\item 
\leavevmode\\[-2.75\baselineskip]
\begin{flalign*}
\mbox{S}\$1 &= \mbox{US}\$1 \div1.33&\\
&= \mbox{US}\$0.75188&\\
\mbox{S}\$20 &= \mbox{US}\$20\times0.75188&\\
&= \mbox{US}\$15.04\mbox{ (2DP)}&
\end{flalign*}
\end{enumerate}

Is there a more elegant way of doing this? As I need to guess about the spacing to shift up the equation beside (a) using [-2.75\baselineskip].

Eugene
  • 928

2 Answers2

4

Here's one way using a regular array aligned at the [t]op. Using some \phantoms and overlapping you can also align across the enumeration:

enter image description here

\documentclass{article}

\usepackage{amsmath,enumitem,array}

\renewcommand{\arraystretch}{1.2}
\begin{document}

Solution:
\begin{enumerate}[label=(\alph*)]
  \item 
  $\begin{array}[t]{@{}r@{}>{{}}l@{}}
    \mbox{US}\$10 &= \mbox{S}\$10 \times 1.33 \\
                  &= \mbox{S}\$13.30
  \end{array}$

  \item 
  $\begin{array}[t]{@{}r@{}>{{}}l@{}}
     \phantom{\mbox{US}\$10}\llap{\mbox{S}\$1} &= \mbox{US}\$1 \div 1.33 \\
                  &= \mbox{US}\$0.75188 \\
     \mbox{S}\$20 &= \mbox{US}\$20 \times 0.75188 \\
                  &= \mbox{US}\$15.04 \mbox{ (2DP)}
  \end{array}$
\end{enumerate}

\end{document}
Werner
  • 603,163
2

Not sure whether this will qualify to be elegant but looks better for me.

\documentclass{article}
\usepackage{amsmath,enumitem}
\begin{document}
\noindent
Solution:
\begin{enumerate}[label=(\alph*)]
\item $
\begin{aligned}[t]
\text{US}\$10 &= \text{S}\$10\times1.33\\
&= \text{S}\$13.30
\end{aligned}
$
\item $
\begin{aligned}[t]
\text{S}\$1 &= \text{US}\$1 \div1.33\\
&= \text{US}\$0.75188\\
\text{S}\$20 &= \text{US}\$20\times0.75188&\\
&= \text{US}\$15.04\text{ (2DP)}
\end{aligned}
$
\end{enumerate}
\end{document}
user43963
  • 1,570
  • Thank you! I thought the \leavevmode\[-2.75\baselineskip] was quite ugly as I needed to guess how much spacing to shift up the equation to align to (a). – Eugene Jan 04 '15 at 07:39
  • Any particular reason why \text should be used instead of \mbox? – Eugene Jan 04 '15 at 07:44
  • 1
    @Eugene \text is capable of detecting fonts (properties) in the surroundings, \mbox is not. – user43963 Jan 04 '15 at 07:45
  • Just one more question, I was trying to search for more information about the aligned package but could not find any so far, most of the Google results gave align instead of aligned. – Eugene Jan 04 '15 at 07:49
  • 2
    @Eugene Search in this site or texdoc amsldoc from command prompt/terminal to get the amsmath manual. – user43963 Jan 04 '15 at 07:59
  • the = signs in the second item aren't aligned with those in the first. this can be done easily, if desired, taking advantage of the fact that the longest bit on the left-hand side is shorter by just the U. then, enter that as \phantom{U}\text{S}\$20 and all the = signs will line up. – barbara beeton Jan 04 '15 at 14:10