Can any one suggess me the code to write this equation in LaTeX.
Asked
Active
Viewed 4.8k times
13
Cactus
- 1,107
Farhan Raza
- 139
2 Answers
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}
sodd
- 5,771
-
1I would suggest to use
equation*instead of replacingequationby\[ \]. 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
otherwisewasn't aligned withif 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}
Heiko Oberdiek
- 271,626



;-)– Romain Picot Aug 19 '15 at 06:38