2

This is my code:

\begin{document}
$$
\sigma(s,i) = \left\{
\begin{array}{ll}
    \tau_{si} & \mbox{si } \{s,i\} \in E \\
    \infty & \mbox{sinon.}
\end{array}
\right.
$$
\end{document}

I have the equation in the center. How can I modify the code to have the equation to the left ?

ShreevatsaR
  • 45,428
  • 10
  • 117
  • 149
researcher
  • 4,555

1 Answers1

3

You can use the fleqn option for amsmath:

\documentclass{article}
\usepackage[fleqn]{amsmath}

\begin{document}

\[
\sigma(s,i) = 
\begin{cases}
    \tau_{si},\quad &\text{si } \{s,i\} \in E \\
    \infty, & \text{sinon.}
\end{cases}
\]

\end{document}

The \quad command is optional (though recommended by some authors) and introduces some horizontal space between the expressions and the conditions.

Notice also the use of \[...\] instead of the $$....$$ TeX syntax and of the cases environment and the \text command (also from amsmath).

ShreevatsaR
  • 45,428
  • 10
  • 117
  • 149
Gonzalo Medina
  • 505,128
  • I think that the \quad should not be there, right? – jmc May 24 '13 at 18:53
  • 1
    @jmc why not? It's a common recommendation to leave a \quad space between the expression and the condition in a definition by cases. – Gonzalo Medina May 24 '13 at 18:53
  • I do not know why one would do that. Please enlighten me... – jmc May 24 '13 at 18:55
  • The necessity of such a \quad makes me think that cases was not designed well. I do not yet have a reason to think that. My experience so far has not caused me to think that such a \quad is needed. – jmc May 24 '13 at 19:01
  • @jmc in the end, it's just a matter of taste. Leaving a \quad space might increase readability in some cases. In any case, I'll add a note about the \quad being optional. – Gonzalo Medina May 24 '13 at 19:01
  • 1
    @jmc Take a look at http://tex.stackexchange.com/questions/25810/when-one-should-use-spacing-line-quad-or –  May 24 '13 at 19:02
  • 1
    @Papiro I was just trying to find that answer, but you were faster. Thanks! – Gonzalo Medina May 24 '13 at 19:03