7

I would like to use a notation for ranges of integers

$[a:b] = \{ a, a+1, \dots, b-1, b \}$.

However, the spacing of $[a:b]$ is often not quite satisfying. The colon : seems to push the glyphs a and b very much to the sides, and there is not much space between the square brackets and the numbers.

Which options do I have to type such an integer range? I am particular concerned about the spacing.

shuhalo
  • 2,545

1 Answers1

9

This is a bit tricky: a simple \,{:}\, might seem enough, but there would be problems if the right boundary is a negative number. Thus some precautions are needed.

\documentclass{article}
\usepackage{amsmath}

\newcommand{\rg}{\mathclose{}{\,{:}\,}\mathopen{}}

\begin{document}

$[a\rg b]$ $[2\rg 5]$ $[-4\rg -2]$

\end{document}

enter image description here

egreg
  • 1,121,712