# [Tex/LaTex] How to properly typeset math intervals

math-modespacing

I have the code

\documentclass{amsart}

\begin{document}
$$]-\pi,0[ \qquad -\pi \qquad \int_{-\pi}^0 \qquad [-\pi,0]$$
\end{document}


which produces

Why is the minus sign on the left so far away from pi and how can this be avoided?

In the TeXbook, Knuth refers to people using “]a,b[” notation for open intervals as “perverse mathematicians” (page 171, exercise 18.14). I don't fully agree with the adjective, but I find the notation very awkward nonetheless.

There is already a package for this, which avoids reinventing the wheel:

\documentclass{amsart}
\usepackage{interval}

\begin{document}

$$\interval[open]{-\pi}{0} \qquad {-\pi} % this needs braces because it is between Ord atoms \qquad \int_{-\pi}^0 \qquad \interval{-\pi}{0}$$

$$x\in\interval[open]{-\pi}{0}$$

\end{document}


The middle -\pi needs braces, but it's a very different problem.

See the documentation for interval to learn about other options.

$x \in ]{-\pi},0[$
$x \in \mathopen]-\pi,0\mathclose[$

It should be clear that simply bracing -\pi is not sufficient.