13

Can any one suggess me the code to write this equation in LaTeX.

enter image description here

Cactus
  • 1,107

2 Answers2

27

You can make use of mathtools and its cases* environment.

The environments cases* and dcases* handles the second column as text, so you wont have to manually "escape" mathmode to typeset the text correctly. The dcases* variant use displaystyle math in the first column, which will make no difference in your situation. See section 3.4.3 in the package documentation for more details.

If you want to remove the equation number (1), you can use \begin{equation*} ... \end{equation*} instead of \begin{equation} ... \end{equation}.

\documentclass{article}
\usepackage{mathtools}

\begin{document}
  \begin{equation}
    L =
    \begin{cases*}
      (0 + 1)^{*} & if $P = \mathit{NP}$ \\
      \phi        & otherwise
    \end{cases*}
  \end{equation}
\end{document}

Output

sodd
  • 5,771
  • 1
    I would suggest to use equation* instead of replacing equation by \[ \]. It is easier and much easier if you want to put numbers back. – Sigur Aug 19 '15 at 09:50
  • There are quite a few differences between this output and the question image: 1) The left part was originally centered and not left-aligned and 2) the otherwise wasn't aligned with if P = NP. It would be informative to provide a way to match the example output more closely. – Bakuriu Aug 19 '15 at 11:58
  • 4
    @Bakuriu The question is how to write the given equation in LaTeX, not how to achieve an identical output. Both equations are the same, which I consider to be the answer to the question. Also, the left part isn't centered; the last line is centered, with the space evenly distributed before, between and after the text. – sodd Aug 19 '15 at 12:30
18

For example:

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\[
  L =
  \begin{cases}
    (0 + 1)* & \text{if $P = \mathit{NP}$} \\
    \emptyset & \text{otherwise}
  \end{cases}
\]
\end{document}

Result

Heiko Oberdiek
  • 271,626