4

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} 
3
  • 1
    Equations are aligned around ampersand, as expected. For proof, set first equation as a+b+c+d= 1 and last one as 3=a+b+c. However, equation system is aligned in the cell as determined column type, in you case, the widest equation will start at left border of cell.
    – Zarko
    Commented Jan 3, 2016 at 18:49
  • @Zarko: I understand that the equations are aligning correctly around ampersand, it's the alignment at left of column that's unwanted. I have tried changing column 1 to {r} and the equations still appear on the left. To be clear: I want all the equations in the centre of the table, but between themselves, centred around ampersand (as they do).
    – Pwdr
    Commented Jan 3, 2016 at 18:54
  • You should mentioned in question, that you like to have equation in the middle of the last table rows. It seems that @ArTourter has crystal ball for correct guest what you like to achieve ...
    – Zarko
    Commented Jan 3, 2016 at 19:01

1 Answer 1

5

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.

1
  • Perfect. I had tried {\multicolumn} previously but was using it incorrectly, so simply returned errors.
    – Pwdr
    Commented Jan 3, 2016 at 18:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .