0

In my MWE below, I included an \mbox in my \align environment. I wanted the text line to be flush left, but when I inclued the text line as a separate line, all the equations got shifted to the right. How can I bascially include the \mbox in one line, then continue with the rest of the formula in the align environment?

Here is my code:

\documentclass{article}
\usepackage{amsmath,fourier,physics}

\begin{document}
\begin{align}
\mbox{Now ~} \dfrac{1}{z!}  = & (z!)^{-1} \\
\ln p(z)  = & z\ln\lambda - \lambda - \ln z! \nonumber \\
\mbox{Differentiating with respect to $\lambda$, we have}\nonumber \\
\pdv{\ln p(z)}{\lambda} = & \dfrac{z}{\lambda} - 1
\end{align}

\end{document}
2
  • Load mathtools rather than amsmath. Use \text{..} rather than \mbox{..} in usual places. And, in case you want one whole line (or paragraph) in between math use \intertext{..} or \shortintertext{..}.
    – Manuel
    Oct 9 '15 at 21:50
  • The & should be before the = sign.
    – Bernard
    Oct 9 '15 at 21:54
1
  • & goes before the relation so it gets the correct spacing
  • use \text rather than \mbox
  • load mathtools (which in turn loads amsmath) and use \intertext{..} to get a whole paragraph in between

photo

\documentclass{scrartcl}

\usepackage{mathtools,fourier,physics}

\begin{document}

\begin{align}
  \text{Now} \quad \frac{1}{z!}  &= (z!)^{-1} \\
  \ln p(z) &= z\ln\lambda - \lambda - \ln z! \nonumber \\
\intertext{Differentiating with respect to $\lambda$, we have}
  \pdv{\ln p(z)}{\lambda} &= \dfrac{z}{\lambda} - 1
\end{align}

\end{document}
1

\intertext seems to be a solution:

\documentclass{article}
\usepackage{amsmath,fourier,physics}

\begin{document}
\begin{align}
\mbox{Now ~} \dfrac{1}{z!}  = & (z!)^{-1} \\
\ln p(z)  = & z\ln\lambda - \lambda - \ln z! \nonumber \\
\intertext{Differentiating with respect to $\lambda$, we have}
\pdv{\ln p(z)}{\lambda} = & \dfrac{z}{\lambda} - 1
\end{align}

\end{document}

Not the answer you're looking for? Browse other questions tagged or ask your own question.