5

I have a number of short equations and I want to show them in two columns. Essentially:

A = B (1) || C = D (2)

E = F (3) || G = H (4)

I first tried the flalign environment (I would prefer this over align, but its not necessary) but I couldn't number the equations the way I want to. The align environment treats every row as one equation.

Example:

\documentclass{article}
\usepackage{mathtools}
\usepackage{amsmath}

\begin{document}
\begin{flalign}
A = & B & C = & D \\
E = & F & G = & H
\end{flalign}
\end{document}

Another approach was a simple multicolumn environment, with a forced columnbreak:

\documentclass{article}
\usepackage{mathtools}
\usepackage{amsmath}
\usepackage{multicol}

\begin{document}
\begin{multicols}{2}
\begin{align}
A = & B \\
E = & F
\end{align}
\columnbreak
\begin{align}
C = & D \\
G = & H
\end{align}
\end{multicols}

\end{document}

However there are multiple problems:

  1. The equations seem to be vertically misplaced
  2. The numbering runs vertically and not horizontally (this would be acceptable for me)

I would appreciate any help on this.

Andrew Swann
  • 95,762
ffrank
  • 53

2 Answers2

10

I think that you should only number equations if you intend to refer to them later so, inline with this philosophy, why not define a macro that both inserts the equation number and also makes the label:

\newcommand\Label[1]{&\refstepcounter{equation}(\theequation)\ltx@label{#1}&}

This first increments the equation counter, prints it and then there is some trickery to make the label (the amsmath environments print error messages when multiple labels appear on one line and we need to sidestep this). Because of the @'s this needs to be wrapped inside \makeatletter...\makeatother.

Possibly unwisely, I have included &'s inside the macro, and hence implicitly assumed that \Label will always be used inside something like an align* environment -- note the * since you don't want the environment to give additional labels. On the the other hand, it took a little extra effort to stop align* from giving an error (since align* suppresses equation numbers), so this macro will not work outside an ams alignment environment.

Using this macro gives:

enter image description here

Here is the full code:

\documentclass{article}
\usepackage{mathtools}
\usepackage{amsmath}
\makeatletter
\newcommand\Label[1]{&\refstepcounter{equation}(\theequation)\ltx@label{#1}&}
\makeatother
\begin{document}
\begin{align*}
  A &= B \Label{one}& C &= D \Label{two}\\
  E &= F \Label{three}& G &= H \Label{four}
\end{align*}
See equations \ref{one}, \ref{two}, \ref{three} and \ref{four}.
\end{document}

As I said above, it is probably unwise to put the two &'s inside the \Label macro as it hides some of the structure in the align* environment, which might confuse someone eventually.

Btw, this works equally well with flalign* environments.

  • To get the correct amount of spacing around the = symbols, one should write &=, not =&. – Mico Apr 21 '15 at 11:11
  • @TazDingo Simplified the macro slightly...was being slightly stupid before in the placement of the &'s which had a bad effect on the scope of the \refstepcounter{equation}. –  Apr 21 '15 at 14:54
  • @Andrew Wow... I really appreciate the effort you put into this. I do not understand what you're saying with the & stuff, but your macro works flawless for me ;) so.. Thanks a lot! – ffrank Apr 22 '15 at 15:50
0

I am unable to add a comment to the Answer, so I add it as an answer to anyone else who has a similar issue with the \Label only using the first letter.

I've added a dummy variable \tmpLabel using primitive \def so it can be properly expanded inside \ltx@label.

\makeatletter
\newcommand{\allignLabel}[1]{&\refstepcounter{equation}(\theequation)\def\tmplab{#1}\ltx@label\tmplab&}
\makeatother

I'm sure there is a more elegant solution to this, so please comment or edit this answer with a proper solution.