[Tex/LaTex] Aligning equations in tabular with aligned environment

alignamsmathtables

I am trying to align equations in a tabular environment. Having read that align and align* don't work in tabular, I found this thread: Aligned equations in tables
which suggests using the aligned environment.

It works, except that the equations are left aligned, where the answer provided states that the default is for them to be centered.

My MWE reproduces this result.

\documentclass[12pt]{report}
\usepackage{amsmath}
\usepackage{booktabs}

\begin{document}

  \begin{table}
      \centering
      \sffamily
  \begin{tabular}{l c c c c }
  \toprule
  &  \multicolumn{4}{c}{Set 1} \\
  & \textbf{Type A} & \textbf{Type B} & \textbf{Type C} & \textbf{Type D} \\        
  \midrule
  Row 1 & 1 & 2 & 3 & 4  \\ 
  Row 2 & 4 & 4 & 4 & 4   \\ 
  \midrule
  $\begin{aligned}
  Eqn1  &=  1 \\
  Eqn 2 &=  2 \\
  Eqn 3 &=  3 \\
  \end{aligned}$ \\
  \bottomrule
\end{tabular}
\end{table}

\end{document} 

Best Answer

Well your equation is indeed centred, but within the first column of your table.

You would need to put your equation inside a multicolumn to have it centred in the table:

\documentclass[12pt]{report}
\usepackage{amsmath}
\usepackage{booktabs}

\begin{document}

  \begin{table}
      \centering
      \sffamily
  \begin{tabular}{l c c c c }
  \toprule
  &  \multicolumn{4}{c}{Set 1} \\
  & \textbf{Type A} & \textbf{Type B} & \textbf{Type C} & \textbf{Type D} \\        
  \midrule
  Row 1 & 1 & 2 & 3 & 4  \\ 
  Row 2 & 4 & 4 & 4 & 4   \\ 
  \midrule
  \multicolumn{5}{c}{$\begin{aligned}
  Eqn1  &=  1 \\
  Eqn 2 &=  2 \\
  Eqn 3 &=  3 \\
  \end{aligned}$} \\
  \bottomrule
\end{tabular}
\end{table}

\end{document}

This code with place the equation in the center of a row that spans the whole table with the = all lined up vertically.

Related Question