3

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.

  • (1) welcome, (2) not an answer to this question, but remember \max and \min – daleif Sep 12 '17 at 13:45
  • 1
    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
1

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

  • 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
1

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

enter image description here

0

Something like this?

\documentclass{article}
\usepackage{mathtools}

\begin{document}

\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] \\
%
    & \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{equation}

\end{document}

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.