# Changing the order of equation numbering in minipage

I am trying to typeset Maxwell's equations using a minipage, and can't think of a good way to structure the document so the numbering of equations proceeds across the rows.

\documentclass[]{article}
\begin{document}
\begin{minipage}{.35\linewidth}
$$E = -\nabla V + \frac{\partial \bm{A}}{\partial t}$$
$$\nabla^2V+\frac{\partial}{\partial t}\left(\nabla\cdot \bm{A}\right) = -\frac{\rho}{\epsilon_0}$$
\end{minipage}%
\begin{minipage}{.65\linewidth}
$$\mathbf{B}=\nabla\times \mathbf{A}$$
$$\left(\nabla^2\bm{A}-\mu_0\epsilon_0\frac{\partial\bm{A}^2}{\partial^2t}\right)-\nabla\left(\nabla\cdot \bm{A} + \mu_0\epsilon_0\frac{\partial V}{\partial t}\right)=-\mu_0 \bm{J}$$
\end{minipage}
\end{document}


I tried multicol, but didn't find a multicolumn solution as intuitive and flexible as the minipage. Because I'm creating two columns, I'm forced to type the second equation on the left side before the first on the right, and can't see any way around that. Can I manually change the order, or can I structure the columns differently? Thanks.

Edit: These aren't actually Maxwell's Equations. I had two sets of equations like this, and copied the second one by accident.

• The obvious solution here is to set each in their own minipage, then you can order the first row to be numbered (1), (2) followed by (3), (4), rather than (1), (3), (2), (4). – Werner Jul 13 '16 at 16:36
• Thanks. As you can probably tell, I'm fairly new to TeX, so these are probably obvious questions. I tried this, but now, likely because they're all separate entities, the spacing seems to be assymmetrical. The equations on the right side are thinner and are spaced closer together. imgur.com/OnQizYN – JAustin Jul 13 '16 at 16:53
• this might be helpful: Numbering a set of horizontally distributed equations – barbara beeton Jul 13 '16 at 17:14

A small amount of manual work. The two columns cannot be equal size, because of the general asymmetry.

\documentclass{article}
\usepackage[margin=3cm]{geometry}
\usepackage{array}

\newcommand{\vect}[1]{\mathbf{#1}}

\begin{document}

$\newcommand{\numbereq}{\refstepcounter{equation}(\theequation)} \renewcommand{\arraystretch}{2.5} \begin{tabular*}{\textwidth}{ @{} >{\displaystyle}c<{} @{\qquad} >{\numbereq}c @{\extracolsep{\fill}} >{\displaystyle}c<{} @{\extracolsep{0pt}\qquad} >{\numbereq}c @{} } E = -\nabla V + \frac{\partial \vect{A}}{\partial t} &\label{maxwell-one}& \vect{B}=\nabla\times \vect{A} &\label{maxwell-two} \\ \nabla^2V+\frac{\partial}{\partial t}(\nabla\cdot \vect{A}) = -\frac{\rho}{\epsilon_0} &\label{maxwell-three}& \left(\nabla^2\vect{A}-\mu_0\epsilon_0\frac{\partial\vect{A}^2}{\partial^2t}\right) -\nabla\left(\nabla\cdot \vect{A} + \mu_0\epsilon_0\frac{\partial V}{\partial t}\right)= -\mu_0 \vect{J} &\label{maxwell-four} \end{tabular*}$
\end{document}


You can manipulate the order in which the equations appear by using separate minipages for each.

Vertical alignment of equations can be achieved using a \vphantom{<stuff>}. This sets a zero-width box with the height of <stuff>.

\documentclass{article}

\usepackage[margin=1in]{geometry}% Just for this example
\usepackage{amsmath}

\begin{document}

\noindent
\begin{minipage}{.35\linewidth}
$$E = -\nabla V + \frac{\partial \boldsymbol{A}}{\partial t}$$
\end{minipage}%
\begin{minipage}{.65\linewidth}
$$\mathbf{B}=\nabla\times \mathbf{A} \vphantom{\frac{\partial \boldsymbol{A}}{\partial t}}$$
\end{minipage}

\noindent
\begin{minipage}{.35\linewidth}
$$\nabla^2V+\frac{\partial}{\partial t} \bigl( \nabla\cdot \boldsymbol{A} \bigr) = -\frac{\rho}{\epsilon_0}$$
\end{minipage}%
\begin{minipage}{.65\linewidth}
$$\biggl( \nabla^2\boldsymbol{A} - \mu_0\epsilon_0\frac{\partial\boldsymbol{A}^2}{\partial^2t} \biggr) -\nabla \biggl( \nabla\cdot \boldsymbol{A} + \mu_0\epsilon_0\frac{\partial V}{\partial t} \biggr) = -\mu_0 \boldsymbol{J}$$
\end{minipage}

\end{document}


I've used \boldmath from amsmath instead of \bm.

Here is a solution with tabularx. I define three new column types:

• Y, which is a simple X column with cells entering and leaving the equation environment.
• E{#1} is a >{\hsize=#1\hsize}X column with an equation environment.
• P{#1} is a p{#1\linewidth} column also with an equation environment.

I defined a tabequations environment, which requires specifiers, which can be given in two ways:

\begin{tabequations}{E{n1}E{n2} … E{nk}, with the condition (as for tabularx)

n1 + n2 + … + nk= k.

It's up to the user to define the values of the coefficients which will realise the widths proportions he/she wants.

The other way is probably simpler and more intuitive: predefine the widths of the first columns as fractions of \linewidthso that the last column, of type Y, will be approximately of the required fraction of \linewidth, and the environment will not overflow the right margin.

The code of both solutions:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} \usepackage{bm}
\usepackage{array, tabularx}
\usepackage{esdiff} \usepackage[showframe]{geometry}

\newcolumntype{E}[1]{>{\equation}>{\hsize=#1\hsize}X<{\endequation}}
\newcolumntype{Y}{>{\equation}X<{\endequation}}
\newcolumntype{P}[1]{>{\equation}p{#1\linewidth}<{\endequation}}

\newenvironment{tabequations}[1]{%
\vspace{\abovedisplayskip}\par\noindent\setlength\tabcolsep{2pt}\setlength\abovedisplayskip{0pt}
\tabularx{\linewidth}{#1}}%
{\endtabularx\par}

\begin{document}

Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text.
\begin{tabequations}{E{0.65}E{1.35}}
E = -∇ V + \diffp{\bm{A}}{t}%
& ∇²V+\diffp{}{t}\left(∇ · \bm{A}\right) = -\frac{ρ}{\epsilon₀}\\[-\abovedisplayskip]%
\mathbf{B}=∇ × \mathbf{A} %
& \smash{\left(∇²\bm{A}-\mu₀\epsilon₀\diffp{\bm{A}}{{t²}}\right)-∇\left(∇ · \bm{A} + \mu₀\epsilon₀\diffp{V}{t}\right)=-\mu₀ \bm{J}}
\end{tabequations}
Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text.

\begin{tabequations}{P{0.35}Y}
E = -∇ V + \diffp{\bm{A}}{t}%
& ∇²V+\diffp{}{t}\left(∇ · \bm{A}\right) = -\frac{ρ}{\epsilon₀}\\[-\abovedisplayskip]%
\mathbf{B}=∇ × \mathbf{A} %
& \smash{\left(∇²\bm{A}-\mu₀\epsilon₀\diffp{\bm{A}}{{t²}}\right)-∇\left(∇ · \bm{A} + \mu₀\epsilon₀\diffp{V}{t}\right)=-\mu₀ \bm{J}}
\end{tabequations}
Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text.

\end{document}
`