4

So I have an issue aligning two equations which I wish to label/number. I wish to place the equations adjacent to each other, with equidistant spacing in the horizontal (between the equations and the page maxima), and also aligned such that the equal-signs of both equations are in the same line of action horizontally. It may be easier to show you...

These are my three, inadequate, solutions thus far:

Solution 1):

\begin{minipage}[t]{.48\linewidth}
  \begin{equation}
    \vec{B}_{trap}(\vec{J}_c, \vec{r}) = k \mu_o \vec{J}_c \ \vec{\hat{r}}
  \end{equation}\break
\end{minipage}%
\begin{minipage}[t]{.48\linewidth}
  \begin{equation}
    k = \frac{t}{2a}{\rm{ln}}\left ( \frac{a}{t} + \sqrt{1 + \left ( \frac{a}{t}\right )^{2}} \right )
  \end{equation}
\end{minipage}

Solution 2):

\begin{align*}
    \vec{B}_{trap}(\vec{J}_c, \vec{r}) = k \mu_o \vec{J}_c \ \vec{\hat{r}} \label{eq:btrap}
   & & k = \frac{t}{2a}{\rm{ln}}\left ( \frac{a}{t} + \sqrt{1 + \left ( \frac{a}{t}\right )^{2}} \right ) \\
\end{align*}

Solution 3):

\begin{multicols}{2}
  \begin{equation}
    \vec{B}_{trap}(\vec{J}_c, \vec{r}) = k \mu_o \vec{J}_c \ \vec{\hat{r}}
  \end{equation}
  \begin{equation}
    k = \frac{t}{2a}{\rm{ln}}\left ( \frac{a}{t} + \sqrt{1 + \left ( \frac{a}{t}\right )^{2}} \right )
  \end{equation}
\end{multicols}

Which typesets as so:

Image denoting the three methods outlined above; first utilising <code>minipage</code>, second <code>align</code>, and third <code>multicols</code>.

As you can see, method 1 and 3 produce numbered and referenced equations, as I need, as they both support the equation environment, however they also are not aligned in the horizontal plane - the equals signs do not share the same line of action horizontally. Whilst the align method allows this horizontal alignment I have failed to reference more than one equation as it can only handle one \ref{eq1}. I need to stay away from using tabular or array as my thesis document would pick up these equations as a table and list them in the 'tables' section of my document. I think so far the best method is align* but I am unable to produce references and numbered equations with that method (which again, must be seen as equations or my 'equations' page will not list them)

Any ideas? Thanks!

  • 3
    your statement about avoiding tabular isn't correct, you may or may not want to use tabular (or array) but neither force the use of a float and the table environment or an entry in the list of tables. – David Carlisle Jan 25 at 10:01
  • 3
    Welcome to TeX.SE! – Mico Jan 25 at 10:39
2

What's messing up your first, minipage-based solution is an inappropriate choice of widths. Also, don't use the [t] location specifiers for the minipage environments -- you want both equations centered vertically on the = symbols, right?

Also, note that I replaced {\rm{ln}} with \ln.

enter image description here

\documentclass{article}
\renewcommand\vec[1]{\mathbf{#1}}
\usepackage{amsmath} % for "\numberwithin" macro
\numberwithin{equation}{section} % optional

\begin{document}
\setcounter{section}{2} % just for this example

\noindent % <-- new
\begin{minipage}{.4\linewidth} % <-- new
\begin{equation}
\vec{B}_{\mathrm{trap}}(\vec{J}_c, \vec{r}) = 
    k \mu_o \vec{J}_c \hat{\vec{r}}
\end{equation}
\end{minipage}\hfill
\begin{minipage}{.5\linewidth}
\begin{equation}
k = \frac{t}{2a}\ln\biggl( \frac{a}{t} + 
    \sqrt{1 + \Bigl( \frac{a}{t}\Bigr)^{\!2}}\, \biggr)
\end{equation}
\end{minipage}
\end{document}
1

It's not that easy to do this without adding unwanted spaces and having all the features of math displays.

Here's a quite general version. The optional argument to halfequation (default 0.5) is the fraction of the width reserved for the equation.

In this particular case it seems best to reserve more for the larger equation.

\documentclass{article}
\usepackage{amsmath,array}

\usepackage{lipsum} % for context

\newenvironment{halfequation}[1][0.5]
 {\vcenter\bgroup
  \hsize=#1\displaywidth
  \setlength{\abovedisplayskip}{0pt}
  \setlength{\abovedisplayshortskip}{0pt}
  \setlength{\belowdisplayskip}{0pt}
  \setlength{\belowdisplayshortskip}{0pt}
  \begin{equation}}
 {\end{equation}\egroup}

\begin{document}

\lipsum*[4]
\[
\begin{halfequation}[0.4]\label{a}
  \vec{B}_{\mathrm{trap}}(\vec{J}_c, \vec{r}) = k \mu_o \vec{J}_c \, \vec{\hat{r}}
\end{halfequation}
\begin{halfequation}[0.6]\label{b}
  k = \frac{t}{2a}\ln\left ( \frac{a}{t} + \sqrt{1 + \left ( \frac{a}{t}\right )^{2}} \right )
\end{halfequation}
\]
\lipsum*[5]

\clearpage

\lipsum*[4]
  \begin{equation}
    k = \frac{t}{2a}\ln\left ( \frac{a}{t} + \sqrt{1 + \left ( \frac{a}{t}\right )^{2}} \right )
  \end{equation}
\lipsum*[5]

\end{document}

I added another page to show that the vertical spacings are the same.

enter image description here

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.