# Automated scaling of \baselineskip inside \raisebox

I recently asked a question that got a great answer, but the answer's effectiveness is fairly limited to the extent that it seems like I'd have to "eyeball" the proper vertical alignment each time I wanted to implement the solution. For example, consider this picture:

The code:

\documentclass{exam}
\usepackage{amsmath}
\usepackage{tabularx}

\begin{document}

\begin{figure}[ht]
\begin{tabularx}{\linewidth}{@{}l>{\hsize=0.6\hsize}X |
>{\hsize=0.3\hsize}X
@{} }
\hline
(a) &   \begin{aligned}[t] f(x) & = 6\biggl[1-\frac{x}{3} + \frac{x^2}{2!3^2}-\frac{x^3}{3!3^3}+ \cdots+\frac{(-1)^n x^n}{n!3^n}+\cdots\biggl] \\ &= 6-2x+\frac{x^2}{3}-\frac{x^3}{27}+\cdots+\frac{6(-1)^nx^n}{n!3^n}+\cdots \end{aligned}

&   \raisebox{-0.8\baselineskip}{$3:\begin{cases} 1 : & \text{two of}\ 6, -2x, \frac{x^2}{3}, -\frac{x^3}{27}\\ 1 : & \text{remaining terms}\\ 1 : & \text{general term} \end{cases}$}
\vspace{1ex}

$\langle -1\rangle$ missing factor of 6\\[2em]
\hline
(b) & $g(0)=0$ and $g'(x)=f(x)$, so\newline

\begin{aligned}[t] g(x) &= 6\biggl[x-\frac{x^2}{6}+\frac{x^3}{3!3^2}-\frac{x^4}{4!3^3}+ \cdots+\frac{(-1)^n x^{n+1}}{(n+1)!3^n}+\cdots\biggl]\\ &= 6x-x^2+\frac{x^3}{9}-\frac{x^4}{4(27)}+\cdots+ \frac{6(-1)^nx^{n+1}}{(n+1)!3^n}+\cdots \end{aligned}

&   \raisebox{-1.4\baselineskip}{$3:\begin{cases} 1 : & \text{two terms}\\ 1 : & \text{remaining terms}\\ 1 : & \text{general term} \end{cases}$}
\vspace{1ex}

$\langle -1\rangle$ missing factor of 6\\
\hline
(c) & $f'(x)=-2e^{-x/3}$, so $h(x)=-2ke^{-ax/3}$\newline
$h(x)=1+x+\frac{x^2}{2!}+\frac{x^3}{3!}+\cdots+\frac{x^n}{n!}+\cdots=e^x$\newline
$-2ke^{-ax/3}=e^x$\newline
$\frac{-a}{3}=1$ and $-2k=1$\newline
$a=-3$ and $k=-\frac{1}{2}$

\begin{center}OR\end{center}

$f'(x)=-2+\frac{2}{3}x+\cdots$, so\newline
$h(x)=kf'(ax)=-2k+\frac{2}{3}akx+\cdots$\newline
$h(x)=1+x+\cdots$\newline
$-2k=1$ and $\frac{2}{3}ak=1$\newline
$k=-\frac{1}{2}$ and $a=-3$

&   \raisebox{-2.3\baselineskip}{$3:\begin{cases} 1 : & \text{two terms}\\ 1 : & \parbox[t]{.3\columnwidth}{recognizes$h(x)=e^x$,\\\null\quad or\\equations 2 series for$h(x)$}\\ 1 : & \text{general term} \end{cases}$}

\end{tabularx}
\end{figure}

\end{document}


My question: Is there a way to have LaTeX automatically calculate the "proper value" C when using \raisebox{-C\baselineskip} to make sure vertical alignment is as it should be? I do not want to have add an hrule each time and adjust the cases based on an eyeballing approach. Any suggestions on how to approach this in a principled manner?

• Instead of raising one of the sides you could box both and align them to the top (or better top - 1\baselineskip). This can be done using \begin{adjustbox}{varwidth=<width>,valign=T} (adjustbox package). Dec 20 '17 at 7:53

\documentclass{exam}
\usepackage{amsmath}
\usepackage{tabularx}

\begin{document}

\begin{figure}[ht]
\begin{tabularx}{\linewidth}{@{}
>{\hsize=0.05\hsize\mbox{}\endgraf}X
>{\hsize=0.60\hsize\mbox{}\endgraf\vspace{-.5\baselineskip}}X |
>{\hsize=0.35\hsize\mbox{}\endgraf\vspace{-.5\baselineskip}}X
@{} }
\hline
(a) &   \begin{aligned}[t] f(x) & = 6\biggl[1-\frac{x}{3} + \frac{x^2}{2!3^2}-\frac{x^3}{3!3^3}+ \cdots+\frac{(-1)^n x^n}{n!3^n}+\cdots\biggl] \\ &= 6-2x+\frac{x^2}{3}-\frac{x^3}{27}+\cdots+\frac{6(-1)^nx^n}{n!3^n}+\cdots \end{aligned}

&   $3:\begin{cases} 1 : & \text{two of}\ 6, -2x, \frac{x^2}{3}, -\frac{x^3}{27}\\ 1 : & \text{remaining terms}\\ 1 : & \text{general term} \end{cases}$

\vspace{1ex}

$\langle -1\rangle$ missing factor of 6\\[2em]
\hline
(b) & $g(0)=0$ and $g'(x)=f(x)$, so\newline

\begin{aligned}[t] g(x) &= 6\biggl[x-\frac{x^2}{6}+\frac{x^3}{3!3^2}-\frac{x^4}{4!3^3}+ \cdots+\frac{(-1)^n x^{n+1}}{(n+1)!3^n}+\cdots\biggl]\\ &= 6x-x^2+\frac{x^3}{9}-\frac{x^4}{4(27)}+\cdots+ \frac{6(-1)^nx^{n+1}}{(n+1)!3^n}+\cdots \end{aligned}

&   $3:\begin{cases} 1 : & \text{two terms}\\ 1 : & \text{remaining terms}\\ 1 : & \text{general term} \end{cases}$

\vspace{1ex}

$\langle -1\rangle$ missing factor of 6\\
\hline
(c) & $f'(x)=-2e^{-x/3}$, so $h(x)=-2ke^{-ax/3}$\newline
$h(x)=1+x+\frac{x^2}{2!}+\frac{x^3}{3!}+\cdots+\frac{x^n}{n!}+\cdots=e^x$\newline
$-2ke^{-ax/3}=e^x$\newline
$\frac{-a}{3}=1$ and $-2k=1$\newline
$a=-3$ and $k=-\frac{1}{2}$

\begin{center}OR\end{center}

$f'(x)=-2+\frac{2}{3}x+\cdots$, so\newline
$h(x)=kf'(ax)=-2k+\frac{2}{3}akx+\cdots$\newline
$h(x)=1+x+\cdots$\newline
$-2k=1$ and $\frac{2}{3}ak=1$\newline
$k=-\frac{1}{2}$ and $a=-3$

&  $3:\begin{cases} 1 : & \text{two terms}\\ 1 : & \parbox[t]{.3\columnwidth}{recognizes$h(x)=e^x$,\\\null\quad or\\equations 2 series for$h(x)$}\\ 1 : & \text{general term} \end{cases}$

\end{tabularx}
\end{figure}

\end{document}