I'm trying to create a table with math that is properly aligned horizontally but can also be centred across multiple rows. I've tried two different methods (one using a solution from this answer) and both result in slight alignment errors, as shown.
I've previously tried using an aligned environment as in this example but as far as I can tell there is no way to align math across multiple such environments or insert a cmidrule into one.
Is there a way to modify either of these solutions to fix the errors shown? What's the best solution to align math in this way?
\documentclass{report}
\usepackage{amsmath,array,booktabs,multirow}
% From https://tex.stackexchange.com/questions/78788/align-equations-over-multiple-tabular-rows/78839#78839
\newcolumntype{A}{ >{$} r <{$} @{} >{${}} l <{$} } % A for "align"
\begin{document}
% FIXED COLUMN DIVIDER
\begin{table}[ht]
\centering
\caption{Fixed column divider}
\begin{tabular}{ l r@{ = } l r@{ $\leftarrow$ } l }
\toprule
\textbf{Name}
& \multicolumn{2}{l}{\textbf{Math}}
& \multicolumn{2}{l}{\textbf{More Math}} \\
\midrule
\multirow{2}{*}{Foo}
& $A$
& $x^2 + y^3$
& $x$
& $x(1 - \alpha)$ \\
& $BC$
& $x^3 - y^2$
& $y$
& $y(1 + \beta)$ \\
\cmidrule{4-5}
\multirow{2}{*}{Bar}
& $D$
& $xy + w_z$
& \multirow{2}{*}{$w_z$}
& \multirow{2}{*}{$w_z(1 + q)$} \\
& \multicolumn{2}{l}{Note: if $A > D \text{ then } D \leftarrow AB + C$}
& \multicolumn{2}{l}{} \\
\bottomrule
\end{tabular}
\end{table}
% NEW COLUMN TYPE
\begin{table}[ht]
\centering
\caption{New column type}
\begin{tabular}{ l A A }
\toprule
\textbf{Name}
& \multicolumn{2}{l}{\textbf{Math}}
& \multicolumn{2}{l}{\textbf{More Math}} \\
\midrule
\multirow{2}{*}{Foo}
& A &= x^2 + y^3
& x &\leftarrow x(1 - \alpha) \\
& BC &= x^3 - y^2
& y &\leftarrow y(1 + \beta) \\
\cmidrule{4-5}
\multirow{2}{*}{Bar}
& D &= xy + w_z
& \multirow{2}{*}{$w_z$}
& \multirow{2}{*}{$\leftarrow w_z(1 + q)$}\\
& \multicolumn{2}{l}{Note: if $A > D \text{ then } D \leftarrow AB + C$}
& \multicolumn{2}{l}{} \\
\bottomrule
\end{tabular}
\end{table}
\end{document}




leftarrows in the $w_z$ side of the table should be aligned. – TACD Apr 19 '18 at 09:22