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?

7

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

| improve this answer | |
9

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.

| improve this answer | |
  • 1
    Fine and useful explanation for beginners! (+1) – Bernard Dec 6 '19 at 0:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.