[Tex/LaTex] Center text between two lines of equation

alignequations

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.

    \begin{equation}
    \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}
    \end{equation}

which gives:

enter image description here

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: text centered between lines

Following the steps from the other thread I get:

\begin{equation}
\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}
\end{equation}

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

Best Answer

You can lower manually the clause:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{equation}
\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{equation}

\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.

enter image description here