37

Today I failed using an align-environment inside of a tabular-environment.

Consider the following example:

\documentclass[12pt]{scrbook}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}

\begin{document}

\begin{tabular}{ll}
      A & B \\%
      & %
\begin{align}
    A &= B \\
    C &= D
\end{align}%
      \\%
    \end{tabular}%

\end{document}

When I try this I'll get an error claiming: "Argument of \align has an extra }." and "Paragraph ended before \align was complete." and much more.

When I enclose everything in paraphrases (like {\begin{align}.....\end{align}}) I'll get some other errors: "Missing \endgroup inserted." and multiple "Missing } inserted."

How can I use the align-environment properly inside of a table?

2
  • It should look like: A | B \\ (blank) | (equation) \\
    – MrD
    Commented Jun 27, 2013 at 16:30
  • 3
    You should use the aligned environment here. Commented Jun 27, 2013 at 16:32

2 Answers 2

35

When I enclose everything in paraphrases (like {\begin{align}.....\end{align}}) I'll get some other errors: "Missing \endgroup inserted." and multiple "Missing } inserted."

It works alright in the following examples.

Code

\documentclass[12pt,parskip=full]{scrbook}
\usepackage{amsmath}
\usepackage{tabularx}
\usepackage[pass,showframe]{geometry}
\begin{document}
\begin{tabular}{l|l|}
      A & B \\
        & {$\!\begin{aligned} % http://tex.stackexchange.com/q/98482/16595 
               A &= B \\    % http://tex.stackexchange.com/q/78788/16595
               C &= D \end{aligned}$}
\end{tabular}

\hrulefill

\begin{tabular}{l|p{5cm}|}
      A & B \\
        & {\begin{align}
               A &= B \\
               C &= D \end{align}}
\end{tabular}

\hrulefill 

\begin{tabularx}{\linewidth}{l|X|}
      A & B \\
        & {\begin{align}
               A &= B \\
               C &= D \end{align}}
\end{tabularx}
\end{document}

Output

enter image description here

6
  • tug.org/pipermail/texhax/2009-April/012236.html
    – ted
    Commented Jun 27, 2013 at 16:50
  • 2
    @DL6ER The align environment does need a line width (it stretches). So you’ll want to use a p column or something with the X column of tabularx. Commented Jun 27, 2013 at 17:58
  • 6
    So what was the solution here? Just to use tabularx instead of tabular? Commented Jun 30, 2014 at 11:46
  • 3
    I get errors while running your code! :( Commented Feb 26, 2017 at 16:08
  • 1
    @H.R. Someone ate my backslashes. It should work now. Commented Mar 7, 2017 at 23:55
2

An alternative to tabular is cals tables: enter image description here

\documentclass[12pt]{scrbook}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{cals}
\begin{document}

\begin{calstable}
\colwidths{{10mm}{40mm}}
\brow
\cell{A}
\cell{B}
\erow
\brow
\cell{}
\cell{
  \begin{align}
      A &= B \\
      C &= D
  \end{align}%
}
\erow
\end{calstable}
\end{document}

You must log in to answer this question.

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