[Tex/LaTex] Conditional equations with with one curly bracket in LaTex

equationserrorsmath-mode

How would I code something like this

enter image description here

I've got the code

    \begin{equation}
       L = 
        \begin{cases}
            1 & \text{if $i = j$ and $deg_j \neq 0 $} \\
            stuff & \text{if $(i, j) \in E$} \\
            0 & \text{otherwise}
        \end{cases}
    \end{equation}

but where stuff is I want to use -\frac{1}{\sqrt{deg_ideg_j}} and where L is I want the Laplacian symbol \mathcal{L}. Whenever I try to put them in I get an error message that says "Missing $ inserted" and I'm not exactly sure what it means, or how to fix it.

Any help would be greatly appreciated.

Best Answer

This seems to work fine:

\documentclass{article}
\usepackage{amssymb,mathtools}
\begin{document}
\begin{equation}
  \mathcal{L} =
  \begin{cases}
    1 & \text{if $i = j$ and $deg_j \neq 0 $} \\
    -\frac{1}{\sqrt{deg_i deg_j}} & \text{if $(i, j) \in E$} \\
    0 & \text{otherwise}
  \end{cases}
\end{equation}
\end{document}

cases

Related Question