# How to Position the Equation Number in begin{equation} environment for a parametric equation ( i.e. x = { a or b )

I have a parametric equation, which is numbered automatically by the begin{equation} environment. My issue is, the number appears on the next line down, below the equation. Since there is enough space on the second line of the split equation, I want the equation number to appear there instead. Does anyone know how I could do this?

This is similar to some previous questions, but I have tried their solutions of \notag for the top line, and using negative \hspace, neither of which work, I think because I use an array. My code is below:

\documentclass[a4paper,twoside,12pt]{article}
\usepackage{multicol}

\begin{document}

\begin{multicols*}{2}

Using Poisson's equation for gravity,

$$\label{eq: phi} \Phi(r) = \left\{ \begin{array}{lr} \frac{GM_{tot}}{Rvir}[\ln\left(\frac{r}{R_{vir}}\right) - 1] : r < R_{vir} \\ \\ \frac{-GM_{tot}}{r} : r > R_{vir} . \end{array} \right.$$

\end{multicols*}
\end{document}


EDIT: I can't use a different document format (e.g. [twocolumn]) since parts of my report are done in a single column. I do not wish to have my r < Rvir on a different line. I was thinking ideally that I could shift along the r > Rvir clause, so that the Equation number could be in line with the second equation, since there is room on that line. Can anybody do this?

• welcome to tex.sx. not knowing what document class you're using, it's impossible to answer this question. as the answer/comment given says, if article is used, there is enough space for the equation number (which should appear centered vertically, not on the last line). but if you're using a document class which requires two (narrow) columns, there probably won't be room. this is why a full compilable example is needed. – barbara beeton Apr 9 '16 at 12:34
• @barbarabeeton Sorry, this is my first post so wasn't quite sure what I needed to include. I am using article as you say, but with {multicols*}{2}, so that it's a two column document. This means the equation doesn't fit in one column with the equation number alongside. I have edited the post to reflect this – Ben Cooke Apr 10 '16 at 13:55
• Do you have any reason for using multicol instead of the standard twocolumn option to \documentclass? – egreg Apr 10 '16 at 14:42
• @egreg I was using multicol as some of my images need to span two columns, and my appendix section is in single column format, as it contains lots of long equations. It therefore seemed easier to just call in the two column format as I needed it – Ben Cooke Apr 10 '16 at 20:31

Use a single column array:

\documentclass[]{article}
\usepackage{amsmath}
\usepackage{multicol}

\newcommand{\tsub}[1]{_{\mathrm{#1}}}

\begin{document}

\begin{multicols*}{2}

Using Poisson's equation for gravity,
$$\label{eq: phi} \Phi(r) = \left\{ \begin{array}{@{}r@{}} \dfrac{GM\tsub{tot}}{R\tsub{vir}} \biggl[\ln\biggl(\frac{r}{R\tsub{vir}}\biggr) - 1\biggr] \\ r < R\tsub{vir} \\[2ex] \dfrac{-GM\tsub{tot}}{r} \hfill r > R\tsub{vir} . \end{array} \right.$$

\end{multicols*}

\end{document}


Textual subscripts should be in upright type and so I set them.

On the other hand, with the twocolumn option the text width is wider and you can use a better way.

\documentclass[twocolumn]{article}
\usepackage{amsmath,mathtools}

\newcommand{\tsub}[1]{_{\mathrm{#1}}}

\begin{document}

Using Poisson's equation for gravity,
$$\label{eq: phi} \Phi(r) = \begin{dcases} \dfrac{GM\tsub{tot}}{R\tsub{vir}} \biggl[\ln\biggl(\frac{r}{R\tsub{vir}}\biggr) - 1\biggr] & r < R\tsub{vir} \\ \dfrac{-GM\tsub{tot}}{r} & r > R\tsub{vir} . \end{dcases}$$

\end{document}


• I recall having read somewhere that is better to use \textup for text subscripts: do you prefer \mathrm instead? – Massimo Ortolano Apr 10 '16 at 22:33
• @MassimoOrtolano For simple words it's more efficient. – egreg Apr 10 '16 at 22:40
• @MassimoOrtolano: This is a highly-debated question. My personal preference for \mathrm essentially boils down to the fact that \textup is, if we want to be fussy, less efficient in terms of time and space. But I also use \text* in certain situations. – GuM Apr 10 '16 at 22:42
• Thank you both. Actually sometimes \mathrm is the only possible option because, e.g., IEEE removes \textup automatically from submitted papers, and then you have to put \mathrm. – Massimo Ortolano Apr 10 '16 at 22:46

I would suggest (a) using a cases environment and (b) placing the conditioning information (r<R_{vir}) on a line by itself. I also wouldn't autosize the parentheses.

\documentclass[a4paper,twoside,12pt]{article}
\usepackage{multicol,amsmath}

\begin{document}
\begin{multicols*}{2}

Using Poisson's equation for gravity,
$$\label{eq:phi} \Phi(r) = \begin{cases} \frac{\textit{GM}_{\textit{tot}}}{R_{\textit{vir}}}\bigl[ \ln\bigl(\frac{r}{R_{\textit{vir}}}\bigr) - 1\bigr],\\ \qquad\qquad r < R_{\textit{vir}} \\[2ex] \frac{-\textit{GM}_{\textit{tot}}}{r}, \quad r > R_{\textit{vir}} \end{cases}$$

\end{multicols*}
\end{document}


Addendum: If you can live without the equation number, it's not too difficult to make the conditioning information fit on the same line as the associated formula. (I simply don't see how one can fit the formula, the conditioning information, and the equation number all inside the width of the text block.)

(The code shown below, as compared to the one above, implements the correction proposed by @MassimoOrtolano, viz., that "G" and "M" represent separate variables...)

\documentclass[a4paper,twoside,12pt]{article}
\usepackage{multicol,amsmath}

\begin{document}
\begin{multicols*}{2}

Using Poisson's equation for gravity,
\begin{equation*} \label{eq:phi}
\Phi(r) {=} \!
\begin{cases}
\frac{GM_{\textit{tot}}}{R_{\textit{vir}}}
\bigl[\ln\bigl(\frac{r}{R_{\textit{vir}}}\bigr) - 1\bigr] :
r < R_{\textit{vir}} \\[2ex]
\frac{-GM_{\textit{tot}}}{r} :
r > R_{\textit{vir}}
\end{cases}
\end{equation*}

\end{multicols*}
\end{document}

• I'm not a big fan of the having the conditioning information on a separate line. This has made me wonder if it would be possible to place the equation number on that line though? If it was far enough to the right, I think I could get away with it. Would you know how to manually place the equation number in between the two equations? – Ben Cooke Apr 10 '16 at 20:34
• @BenCooke - Unless you're willing to switch to a minuscule font size (and give up on making the expressions be legible), I don't see how you can avoid having the conditioning term on a separate line and still have the equation number not be shifted out of the way. Question: Do you really need an equation number? If you can dispense with the equation number, it's not too much extra work to fit everything in nicely. – Mico Apr 10 '16 at 20:52
• Why have you used \textit{GM} for the product of the Newtonian constant G with the mass M? – Massimo Ortolano Apr 10 '16 at 22:28
• @MassimoOrtolano - That would be because I had no idea what "GM" stood for. :-( It's been more than 35 years since I took physics in high school! As a result, I had been surmising that it was an acronym for a single variable. Thanks for pointing out this gross misunderstanding. I'll edit the code in the addendum and post a new screenshot. – Mico Apr 10 '16 at 22:46

This is not an answer, because with the code you posted I cannot reproduce the problem that you report (I get the equation number vertically centered with respect to the equation), but simply a comment that doesn’t fit in the allowed number of characters. Consider rewriting your code as follows:

\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{mathtools}

\begin{document}

Using Poisson's equation for gravity,
%
$$\label{eq: phi} \Phi(r) = \begin{dcases*} \frac{GM_{\mathrm{tot}}}{R_{\mathrm{vir}}} \biggl[\ln\Bigl(\frac{r}{R_{\mathrm{vir}}}\Bigr) - 1\biggr] & if $$r < R_{\mathrm{vir}}$$, \\[2\jot] \frac{-GM_{\mathrm{tot}}}{r} & if $$r > R_{\mathrm{vir}}$$. \end{dcases*}$$

\end{document}


Here is the output I obtain:

• Hi, I've edited the post according to the suggestions made. Using your code doesn't fix the problem, since I am using a two column document. Now that I've actually given the relevant information, perhaps you could try again to see if you can find a solution? Thanks for your help, and sorry for the poor original post – Ben Cooke Apr 10 '16 at 14:06
• @BenCooke: …Mmh, I’ve thrown away the file, but I don’t see what else I could have done than copying the code you posted, and I don’t remember the typeset output being in two-column format… Anyway, egreg has already shown you what is probably the best possible solution, given the constraints. – GuM Apr 10 '16 at 22:34