1

I am using below equation in my document. By default, it is getting aligned at the center. I want to left-align the equation -- only this equation, not all equations in the document. Can anybody tell me how it can be done?

\begin{equation}
d_j =
  \begin{cases}
    newval_i,  & \quad i = j\\
    randval_k, & \quad k = j\\
    bestval_j, & \quad \text{otherwise}
  \end{cases}
\end{equation}
  • Should all equations be left-aligned, or just this one? – Mico Apr 29 '17 at 16:10
  • unrelated to alignment but that should be \mathit{newval}_i and similarly the other names, never use the default math italic for multi-letter words. – David Carlisle Apr 29 '17 at 16:19
  • @Mico only this one – Atinesh Apr 29 '17 at 16:37
  • 1
    @Atinesh - The fact that you only wish to left-align a single equation is very important, and unfortunately it's something that wasn't mentioned in your posting. It's not too late, though, to edit your posting and to clarify what it is you're trying to achieve. Go ahead. – Mico Apr 29 '17 at 16:47
  • 1
    @Bobyandbob I have already gone through that post, It didn't solve my problem. – Atinesh Apr 29 '17 at 17:00
3

You can do that nesting your equations in a fleqn environment (from nccmath). This environment accepts an optional argument for the distance from the left margin ( 0 pt by default):

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[showframe]{geometry}
\usepackage{mathtools, nccmath}

\begin{document}

\begin{equation}
d_j =
  \begin{cases}
    \text{newval}_i, & \quad i = j\\
    \text{randval}_k, & \quad k = j\\
    \text{bestval}_j, & \quad \text{otherwise}
  \end{cases}
\end{equation}

\begin{fleqn}
\noindent\texttt{With fleqn: }
\begin{equation}
d_j =
  \begin{cases}
    \text{newval}_i, & \quad i = j\\
    \text{randval}_k, & \quad k = j\\
    \text{bestval}_j, & \quad \text{otherwise}
  \end{cases}
\end{equation}
\end{fleqn}

\begin{fleqn}[3em]
\noindent\texttt{With fleqn and optional argument [3em]: }
\begin{equation}
d_j =
  \begin{cases}
    \text{newval}_i, & \quad i = j\\
    \text{randval}_k, & \quad k = j\\
    \text{bestval}_j, & \quad \text{otherwise}
  \end{cases}
\end{equation}
\end{fleqn}

    \end{document} 

enter image description here

  • +1. Nice use of the nccmath package! – Mico Apr 29 '17 at 20:04
  • 1
    Thanks, @Mico. The package has many useful little things – the main point for me being medium-sized maths, intermediate between display style and text style for fractions, integrals, matrices and so on. – Bernard Apr 29 '17 at 20:16

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.