5

I'm trying to line up multiple equations next to each other and have them all properly labeled. There is another question discussing this exact problem. Unfortunately, all the solutions proposed there produce output with the equations sitting on different baselines, which is extremely jarring.

Here's the document I'm working with:

\documentclass{article}
\usepackage{amsmath, amsfonts}
\begin{document}
\begin{equation}
  \mathbf{a} \cdot \mathbf{b} = \sum_{i=1}^n a_ib_i
  \qquad
  \mathbf{a} \cdot \mathbf{b} =
    \lVert \mathbf{a} \rVert
    \lVert \mathbf{b} \rVert \cos \theta
\end{equation}
\end{document}

When written this way, it appears that both left-hand sides use the same baseline and the output looks quite pleasing. Unfortunately I couldn't achieve the same effect using the suggestions from the linked question (which are tabularx, multicol or minipage).

Please help!

Update. I realize that the question is a bit poorly worded. What I really want here, is an ability to arrange equations on a grid, in a way similar to how various align environments work, but at the same time also labeling equations that end up on the same row. I hope that makes sense.

  • Can you show the code where you tried and failed to get them side-by-side? If I wrap each of the equations in a minipage without a blank line between the two minipages they line up correctly, as in the linked question. – Alan Munn Dec 08 '11 at 01:29

1 Answers1

6

The minipage solution from the question you linked to can actually be used here, provided that you supply the second minipage with an optional [b] argument (the argument can be t for top, c for center, b, see parboxes on tug and minipages on tug for more details).

screenshot

\documentclass{article}
\usepackage{amsmath, amsfonts}
\begin{document}


\noindent\begin{minipage}{.5\textwidth}
\begin{equation}
  \mathbf{a} \cdot \mathbf{b} = \sum_{i=1}^n a_ib_i
\end{equation}
\end{minipage}%
\begin{minipage}[b]{.5\textwidth}
 \begin{equation}
  \mathbf{a} \cdot \mathbf{b} =
    \lVert \mathbf{a} \rVert
    \lVert \mathbf{b} \rVert \cos \theta
\end{equation}
\end{minipage}
\end{document}

Following the updated question and the comments, here is an example of how you can use the above idea in a tabular* environment

screenshot2

\documentclass[draft]{article}
\usepackage{amsmath, amsfonts}

\newenvironment{minipeqn}[1][]{\begin{minipage}[#1]{.45\textwidth}\begin{equation}}{\end{equation}\end{minipage}}
\begin{document}

\noindent\begin{tabular*}{\textwidth}{ll}
 \begin{minipeqn}
  \mathbf{a} \cdot \mathbf{b} = \sum_{i=1}^n a_ib_i
\end{minipeqn}&
\begin{minipeqn}[b]
  \mathbf{a} \cdot \mathbf{b} =
    \lVert \mathbf{a} \rVert
    \lVert \mathbf{b} \rVert \cos \theta
\end{minipeqn}\\
\begin{minipeqn}
  \mathbf{a} \cdot \mathbf{b} = \sum_{i=1}^n a_ib_i
\end{minipeqn}&
 \begin{minipeqn}[b]
  \mathbf{a} \cdot \mathbf{b} =
    \lVert \mathbf{a} \rVert
    \lVert \mathbf{b} \rVert \cos \theta
\end{minipeqn}\\
\begin{minipeqn}
  \mathbf{a} \cdot \mathbf{b} = \sum_{i=1}^n a_ib_i
\end{minipeqn}&
 \begin{minipeqn}[b]
  \mathbf{a} \cdot \mathbf{b} =
    \lVert \mathbf{a} \rVert
    \lVert \mathbf{b} \rVert \cos \theta
\end{minipeqn}
\end{tabular*}

\end{document}
David Carlisle
  • 757,742
cmhughes
  • 100,947
  • You could add % after the first \end{minipage} to prevent a spurious blank space. – Gonzalo Medina Dec 08 '11 at 01:44
  • @GonzaloMedina Thanks, great suggestion! Done :) – cmhughes Dec 08 '11 at 01:45
  • Hi. Thank you. Is it possible to extend this approach to more equations? For example, if I copy each equation environment, ending up with two equations on each page, then only the bottom equations are aligned. – Anonymous Dec 08 '11 at 01:50
  • @Anonymous Could you clarify: are you putting more than one equation environment in each minipage? – cmhughes Dec 08 '11 at 02:09
  • Yes, I'm trying now to put multiple equation blocks in every minipage and the vertical alignment gets pretty strange. I updated the question too. Or should I just create two minipages for each row instead? – Anonymous Dec 08 '11 at 02:12
  • Just for the sake of completeness, the optional parameter in the minipage environment is a positional indicator. So, you can set it to t (top), b (bottom), or c (center). – adn Dec 08 '11 at 02:16
  • @Anonymous Rather than putting multiple equations in each minipage, have you tried using a tabular environment? You could use the above idea in each row. – cmhughes Dec 08 '11 at 02:22
  • @cmhughes Could you give an example of using tabular with these equations? Simply putting them inside a tabular block exhibits exactly the same problem with the baseline. – Anonymous Dec 08 '11 at 02:39
  • @Anonymous see my edit – cmhughes Dec 08 '11 at 03:10
  • As an aside, there isn't a way to just put multiple \tags into one equation, is there? It would make everything much simpler here. – Anonymous Dec 08 '11 at 03:31
  • @Anonymous not sure about multiple \tags but I have updated my answer to make the code more readable using a custom environment – cmhughes Dec 08 '11 at 03:42