[Tex/LaTex] How to properly typeset math intervals

math-modespacing

I have the code

\documentclass{amsart}

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

which produces

im

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

Best Answer

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}

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

\begin{equation}
x\in\interval[open]{-\pi}{0}
\end{equation}

\end{document}

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

See the documentation for interval to learn about other options.

enter image description here


Note about Werner's solution

Consider the following code and compile it to see what results:

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

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

(properly embed it in a standard document).

enter image description here

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