2

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} 
  • 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 Jan 3 '16 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 Jan 3 '16 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 Jan 3 '16 at 19:01
3

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.