2

I want to include two sets of equations side-by-side in a table. Here is my example:

\documentclass{article}
\usepackage{amsmath}
\newcommand{\eqnbox}[2]{
  \begin{minipage}[c]{#1\linewidth}\begin{equation*}\begin{aligned}
        #2
      \end{aligned}\end{equation*}\end{minipage}
}
\begin{document}
\begin{center}
\begin{tabular}{c|c}
first set & second set\\
\hline
\eqnbox{.3}{
  x &= \frac{1}{2}\\
  y &= \frac{1}{3}\\
  z &= 3
} &
\eqnbox{.3}{
  x &= 2\\
  y &= 3\\
  z &= 3
}
\end{tabular}
\end{center}
\end{document}

I have tried

  1. aligning the rows but putting each equation in $$, but then I cannot align vertically by the = sign.
  2. laying out the entire table using align, but then cannot put a vertical line down the middle.
  3. adjusting the height of the box by using the height argument to minipage, e.g. \begin{minipage}[c][30pt]{#1\linewidth}, or enclosing the minipage environment within raisebox, e.g., \raisebox{0pt}[30pt][30pt]{}.

No luck so far -- any suggestions?

migrated from stackoverflow.com Feb 14 '11 at 19:42

This question came from our site for professional and enthusiast programmers.

2

Use an array instead of the tabular and put the single equations side by side, not the blocks.

\documentclass{article}
\usepackage{amsmath}
\usepackage{array}
\def\MCA#1{\multicolumn{2}{c!{\quad\vline\quad}}{\text{#1}}}
\def\MCB#1{\multicolumn{2}{c}{\text{#1}}}

\begin{document}
\begin{center}
\def\arraystretch{1.8}\arraycolsep=1.4pt
$\begin{array}{rl!{\quad\vline\quad}rl}
\MCA{first set} & \MCB{second set}\\\hline
  x &= \frac{1}{2} &   x &= 2\\
  y &= \frac{1}{3} &   y &= 3\\
  z &= 3           &   z &= 3
\end{array}$
\end{center}

\end{document}

enter image description here

  • Ah, I like this for the position arguments permitted by array and the vline specifications which I did not know about -- very awesome. – hatmatrix Feb 15 '11 at 12:09

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.