3

My equation is not left-aligned; see the attached image. I'd like it to be left-aligned.

\begin{equation} P(w_{i} | h) =   \left\{
      \begin{aligned}
        \frac{n(h, w_{i})}{n(h)}    Si n(h, w_{i}) > k\\
        d_{r} \frac{n(h, w_{i})}{n(h)}\\
        \alpha(h) P(w_{i} | h^{-1}\\
      \end{aligned}
    \right.
\end{equation}

enter image description here

1
  • 2
    The first column in an alignment is right aligned. You might want to have a look at the cases env, faster to use as the { is build in
    – daleif
    Oct 21 '15 at 19:38
3

While you can use an aligned environment, your use is better-suited for the cases environment:

enter image description here

\documentclass{article}

\usepackage{amsmath}
\DeclareMathOperator{\Sin}{Sin}

\begin{document}

\begin{equation}
  P(w_i \mid h) = \begin{cases}
    \dfrac{n(h, w_i)}{n(h)} \Sin(h, w_i) > k \\
    d_r \dfrac{n(h, w_{i})}{n(h)} \\
    \alpha(h) P(w_i \mid h^{-1})
  \end{cases}
\end{equation}

\end{document}
1

If you want to use aligned, you have to add an ampersand &:

\begin{equation} P(w_{i} | h) = \left{
  \begin{aligned}
    & \frac{n(h, w_{i})}{n(h)}    Si n(h, w_{i}) > k\\
    & d_{r} \frac{n(h, w_{i})}{n(h)}\\
    & \alpha(h) P(w_{i} | h^{-1}\\
  \end{aligned}
\right.
\end{equation}

The formula in each row of the aligned environment can be structured by putting & at the right places. The idea is that corresponding &s of different rows will be aligned on top of each other. In order to align arbitrary formulas at specific points, the parts before the first & is right aligned, the part after the second & is left aligned, and then it alternates.

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.