3

I have the following piece of latex code

\begin{equation*}
    G(z,w) =
    \begin{cases*}
      \frac{\rho (g_{\bar{\lambda}}(z),g_{\bar{\lambda}}(w))}{\rho (z,w)} & for z \neq w \\
      |f'|_{\rho} & for z = w
    \end{cases*}
\end{equation*}

and i keep getting missing $ and missing } errors. From what I've read most commonly these are caused by putting $ inside the equation environment (which is redundant) or leaving an empty line inside mat mode. As far as I can tell I'm not doing either, and I can't figure out what is wrong with this formula. Thanks in advance.

Mico
  • 506,678

2 Answers2

7

I will assume that you're trying to uses the cases* environment that's provided by the mathtools package. If this assumption is not correct, please let me know.

The cases* environment, unlike the cases environment, assumes that the material in the second column, i.e., after the & character, is in text mode. Since there's is a \neq macro in the first line, LaTeX complains since \neq must occur in math mode.

The remedy: Replace the strings z \neq w and z = w with $z \neq w$ and $z = w$, respectively.

You may also want to replace the cases* environment with dcases* so that the fraction term in the first row is typeset in display-style math mode instead of in text-style math mode.

enter image description here

\documentclass{article}
\usepackage{mathtools} % for 'cases*' and 'dcases*' environments
\begin{document}
\begin{align*}
G(z,w)
 &= \begin{cases*}
      \frac{\rho (g_{\bar{\lambda}}(z),g_{\bar{\lambda}}(w))}{\rho (z,w)} & for $z \neq w$ \\
      |f'|_{\rho} & for $z = w$
    \end{cases*}\\[2ex]
 &= \begin{dcases*}
      \frac{\rho (g_{\bar{\lambda}}(z),g_{\bar{\lambda}}(w))}{\rho (z,w)} & for $z \neq w$ \\
      |f'|_{\rho} & for $z = w$
    \end{dcases*}
\end{align*}
\end{document}
Mico
  • 506,678
5

The second column of the cases* environment is set up to contain text, so you'll need to enclose the math contents in that column in $…$. (See the documentation of the mathtools package, which is where cases* is defined.)

The following works:

\documentclass{article}
\usepackage{amsmath,mathtools}
\begin{document}

\begin{equation*}
    G(z,w) =
    \begin{cases*}
      \frac{\rho (g_{\bar{\lambda}}(z),g_{\bar{\lambda}}(w))}{\rho (z,w)} & for $z \neq w$ \\
      \lvert f'\rvert_{\rho} & for $z = w$
    \end{cases*}
\end{equation*}

\end{document}

output


Note: In addition to inserting the aforementioned $…$ I also replaced |f'| by \lvert f'\rvert The difference is that \lvert and \rvert have the spacing of an opening/closing bracket respectively. See .e.g the answers to this question.

Circumscribe
  • 10,856