# Center text between two lines of equation

I am currently trying to put a text between 2 lines of equations and align them with the equals sign. I have already read about this in another thread, but I cant get it to work the way I want it.

    \label{eq:distrib} \begin{aligned} n_c &= max\left[N \cdot z_{max} \cdot x, 2 \cdot n_{min}\right] \\ n_{co} &= min\left[ max\left[n_c \cdot x, n_{min} \right], n_c - n_{min} \right] \enskip \text{where} \enskip x \sim U \left(\left[0, 1\right] \right) \\ n_{cp} &= n_c - n_{co} \\ n_f &= N - n_c \end{aligned}


which gives:

Now i want to move that "where part" between n_c and n_co, while keeping everything else the way it is, i.e. all equations aligned at the equals sign and the equation number centered, so that it looks like this:

Following the steps from the other thread I get:

\label{eq:distrib} \begin{aligned} n_c &= max\left[N \cdot z_{max} \cdot x, 2 \cdot n_{min}\right] \\ n_{co} &= min\left[ max\left[n_c \cdot x, n_{min} \right], n_c - n_{min} \right] \end{aligned} \enskip \text{where} \enskip x \sim U \left(\left[0, 1\right] \right) \begin{aligned} n_{cp} &= n_c - n_{co} \\ n_f &= N - n_c \end{aligned}


However, I dont know how to move the last part into an extra line. Any help would be appreciated, thanks.

• (1) welcome, (2) not an answer to this question, but remember \max and \min – daleif Sep 12 '17 at 13:45
• I would like to suggest that you place the "where ..." clause in an \intertext{...} wrapper. Next, get rid of both aligned  environments and use a single split environment inside the equation environment. – Mico Sep 12 '17 at 14:03
• Thx for the suggestions to both of you. I will definitely use the \max \min functions, not sure why they got lost ^^ – schiseb Sep 12 '17 at 14:25

You can lower manually the clause:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\label{eq:distrib} \begin{alignedat}{2} n_c &= \max[N \cdot z_{\max} \cdot x, 2 \cdot n_{\min}] &\quad&\raisebox{-.5\normalbaselineskip}[0pt][0pt]{% where x\sim U([0,1])% } \\ n_{co} &= \min[\max[n_c \cdot x, n_{\min}], n_c - n_{\min}] \\ n_{cp} &= n_c - n_{co} \\ n_f &= N - n_c \end{alignedat}

\end{document}


I used \max and \min (you should, too). I also removed all \left and \right tokens, which only do evil here.

I'd also suppress all \cdot symbols, which are very seldom used to denote multiplication in professional math.

However, my feeling is that the clause about x should be moved in the text following the display.

• Thank you very much, this is exactly what I was looking for. I used \cdot in this equation because it looks strange to me otherwise. I dont want the reader to accidently skip parts of the formula because they think it is another variable. – schiseb Sep 12 '17 at 14:31

A TABstack alternative where the 1/2 line spacing is achieved by setting a 3-row stack adjacent to a 4-row TABstack.

\documentclass{article}
\usepackage{tabstackengine}
\begin{document}
\setstackgap{L}{1.3\baselineskip}
\label{eq:distrib} \ensureTABstackMath{\alignCenterstack{ n_c =& \max[N \cdot z_{\max} \cdot x, 2 \cdot n_{\min}]\\ n_{co} =& \min[\max[n_c \cdot x, n_{\min}], n_c - n_{\min}] \\ n_{cp} =& n_c - n_{co} \\ n_f =& N - n_c }} \quad \Centerstack{where x\sim U([0,1])\\ \\}
\end{document}


Something like this?

\documentclass{article}
\usepackage{mathtools}

\begin{document}

\label{eq:distrib} \begin{aligned} n_c &= max\left[N \cdot z_{max} \cdot x, 2 \cdot n_{min}\right] \\ n_{co} &= min\left[ max\left[n_c \cdot x, n_{min} \right], n_c - n_{min} \right] \\ % & \text{where }x \sim U \left(\left[0, 1\right] \right)\\ % n_{cp} &= n_c - n_{co} \\ n_f &= N - n_c \end{aligned}

\end{document}