2

I would like to get a single line in the eqnarray environment flushed left. This is my code so far

\begin{eqnarray}
\delta_{j}      & = & \sum_{i = j+1}^{d} n_{i}  \\
and \nonumber\\
g^{\prime}(x)   & = &  \left\{
\begin{array}{ll}
    \cos (n_{p-1} \, \theta_{1})            &  \text{for~~} n_{p} = 0   \\
    \sin ( (n_{p-1} + 1) \, \theta_{1})     &  \text{for~~} n_{p} = 1   \\
\end{array}
\right.
\end{eqnarray}

I would like to make the line with the the and \nonumber\\ flush left.

Here is a picture of the current output along with a description of what I would like to happen

enter image description here

I have tried using combinations of \hspace, \hfill and \noindent without success. The reason for typing the code in this manner is because I really want to keep the equal signs aligned.

  • 1
    do not use eqnarray use align then you can use \intertext{and} – David Carlisle Apr 16 '18 at 16:08
  • See the answers to the posting eqnarray vs align for a thorough list or reasons why one shouldn't use eqnarray. – Mico Apr 16 '18 at 16:26
4

You shouldn't use eqnarray as it gives bad spacing around the alignment points. Use one of the amsmath environments, align or alignat, which furthermore are simpler to type, and \intertext. Here, I loaded mathtools, an extension of amsmath, for its \shortintertext command (better vertical spacing for a single word). Also I replaced the \left\{\begin{array}{ll} ... \end{array} with the simple cases* environment, which switches the second column in text mode. Note that you don't have to type g^{\prime} for the derivative: a simple g' will do:

\documentclass {book}

\usepackage {mathtools}

\begin {document}

\begin{align}
\delta_{j} & = \smashoperator{\sum_{i = j+1}^{d}} n_{i} \\
\shortintertext{and}
g'(x) & = \begin{cases*}
\cos (n_{p-1} \, \theta_{1}) & for $n_{p} = 0$, \\
\sin ( (n_{p-1} + 1) \, \theta_{1}) & for $n_{p} = 1$. \\
\end{cases*}
\end{align}

\end {document} 

enter image description here

  • 1
    You're right (as usual…). I'll even use the cases* environment,, which sets the second column in text mode. – Bernard Apr 16 '18 at 16:34

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.