2

I'm trying to write a table with two columns which is filled with align*-equations. But on one row, I'd like to put a single align*-eq spanning the whole tabular. But somehow this won't work as intended.

Am minimal example would be something like this:

\begin{table}[H]
\centering
\begin{tabular}{p{7cm} | p{7cm} }
 Equation 1  & Equation 2\\ \hline
 \begin{align*}
     a^2+b^2 = c^2
 \end{align*}
 &
 \begin{align*}
     E=m\cdot c^2
 \end{align*}\\ \hline
 \multicolumn{2}{c}{
 \begin{align*}
    R=\dfrac{U}{I}
 \end{align*} }\\ \hline
\end{tabular}

\end{table}

If I comment out the multicolumn-part it compiles just fine. I'm thankful for any help.

Kind regards.

1
  • please, provide complete small document, which can be compiled ...
    – Zarko
    Jun 21, 2017 at 16:17

2 Answers 2

3

I would use short displayskips in a table. So I define a newcolumn type which incorporates them:

\documentclass{article}

\usepackage[margin=2.3cm, showframe]{geometry} %
\usepackage{amsmath}

\usepackage{enumitem, etoolbox, tabularx, makecell, booktabs, float, nccmath}
\newcolumntype{P}[1]{>{\abovedisplayskip=\abovedisplayshortskip \belowdisplayskip=\belowdisplayshortskip}p{#1}}

\begin{document}

\begin{table}[H]
  \centering
  \begin{tabular}{P{7cm} |P{7cm} }
    Equation 1 & Equation 2 \\ \hline
    \begin{align*}
      a²+b² = c²
    \end{align*}
               &
    \begin{align*}
      E=m · c²
    \end{align*} \\ \hline
    \multicolumn{2}{P{\dimexpr14cm + 2\tabcolsep}}{
      \begin{align*}
        R=\dfrac{U}{I}
      \end{align*} } \\ \hline
  \end{tabular}
\end{table}

\end{document} 

enter image description here

2

Displayed equations you can write only in p{...} type cells (or X, if you use \tabularx). Since your \multicolumn use `` cell type, you have error. As solution you can use p{\hsize} in \multicolumn too:

\documentclass{article}
\usepackage{mathtools}
%---------------------------------------------------------------%
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

    \begin{document}
\begin{table}
\centering
\begin{tabular}{p{7cm} | p{7cm} }
 Equation 1  & Equation 2\\ 
    \hline
 \begin{align*}
     a^2+b^2 = c^2
 \end{align*}
 &
 \begin{align*}
     E=m\cdot c^2
 \end{align*}\\ \hline
 \multicolumn{2}{p{\hsize}}{
 \begin{align*}
    R=\dfrac{U}{I}
 \end{align*} }\\ \hline
\end{tabular}
\end{table}
    \end{document}

however, result is not very promising:

enter image description here

Better is use tabularx:

\documentclass{article}
\usepackage{mathtools}
\usepackage{tabularx}
\newcolumntype{C}{>{\centering\arraybackslash}X}
%---------------------------------------------------------------%
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

    \begin{document}
\begin{table}
\centering
\begin{tabularx}{\linewidth}{C | C }
 Equation 1  & Equation 2\\ 
    \hline
 \begin{align*}
     a^2+b^2 = c^2
 \end{align*}
 &
 \begin{align*}
     E=m\cdot c^2
 \end{align*}\\ \hline
 \multicolumn{2}{>{\hsize=2\hsize}C}{
 \begin{align*}
    R=\dfrac{U}{I}
 \end{align*} }\\ 
    \hline
\end{tabularx}
\end{table}
    \end{document}

enter image description here

Red lines show page layout (from package showframe, in real use you should deleted this package in preamble).

Edit: I wonder, why you use align environment, if the equation in the cell has only one line ... so maybe it is worth to consider to use the following solution:

\documentclass{article}
\usepackage{mathtools}
\usepackage{makecell, tabularx}% added makecel for gaped cells
\newcolumntype{C}{>{\centering\arraybackslash}X}
\setcellgapes{5pt}% set vertical gapes above and below cells' contents

    \begin{document}
\begin{table}
    \centering
    \makegapedcells% use gaps in cells
\begin{tabularx}{\linewidth}{>{$\displaystyle}C<{$}|>$\displaystyle}C<{$}}% use in line math environment, but with \displaystyle
\text{Equation 1}   &   \text{Equation 2}   \\ 
    \hline
a^2+b^2 = c^2       &   E=m\cdot c^2        \\ 
    \hline
\multicolumn{2}{>{\hsize=2\hsize$\displaystyle}C<{$}}{
 \begin{aligned}% in case, that you really have multi line and aligned equations
    R & =\frac{U}{I} \\
    U & =I R
 \end{aligned} }\\ 
    \hline
\end{tabularx}
\end{table}
    \end{document}

enter image description here

You must log in to answer this question.

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