6

Please consider the following:

$$ g(y) = \begin{cases}
y + 1, & \text{for } -1 \leq y \leq 0 \\
1 - y, & \text{for } 0 \leq y \leq 1 \\
0, & \text{otherwise }
\end{cases} $$

When it gets rendered, I am getting a fairly long minus sign before the 1 and a space between the minus sign and the 1. I do not like that. Any suggestions?

Bob
  • 255

2 Answers2

8

This is because the - acts like a binary operator within your context (\text{for } on the left and 1 on the right). You can either place everything in the conditional clause of cases inside \text and escape math as necessary, or make the operator unary (with braces; actually making it ordinary):

enter image description here

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\[
  g(y) = \begin{cases}
    y + 1, & \text{for $-1 \leq y \leq 0$} \\
    1 - y, & \text{for $0 \leq y \leq 1$} \\
    0, & \text{otherwise}
  \end{cases}
\]

\[
  g(y) = \begin{cases}
    y + 1, & \text{for } {-}1 \leq y \leq 0 \\
    1 - y, & \text{for } 0 \leq y \leq 1 \\
    0, & \text{otherwise}
  \end{cases}
\]

\end{document}

Using {-1} would also work, forcing - to be an ordinary symbol, similar to {-}1.

Werner
  • 603,163
6

Note you shouldn't use the plain TeX construct $$ ... $$. You can solve the problem with a pair of braces. I added an improvement for the inequalities:

  \[ g(y) = \begin{cases}
y + 1, & \text{for } {-1} \leq y \leq 0 \\
1 - y, & \text{for } {\phantom{-}0} \leq y \leq 1 \\
0, & \text{otherwise }
\end{cases} \]

enter image description here

Bernard
  • 271,350