Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
add comment

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

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

1 Answer

up vote 2 down vote accepted

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

share|improve this answer
    
Ah, I like this for the position arguments permitted by array and the vline specifications which I did not know about -- very awesome. –  crippledlambda Feb 15 '11 at 12:09
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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