[Tex/LaTex] Spacing for homogeneous coordinates

math-modespacing

Homogeneous coordinates in projective geometry are usually denoted like this: $[x:y:z]$. However, I think that : plays the role of a comma, and should be surrounded by much smaller spaces than for other uses of :.

Is there a simple way in LaTeX to automatically adjust the spacing in homogeneous coordinates, without messing with the spacing of other uses of :?

Best Answer

Set it as a {:} or use \mathpunct{:}

\documentclass{article}
\usepackage[french]{babel}
\makeatletter
\def\Coor#1{\begingroup\mathcode`\:="603A[\Coor@i#1::\@nil}
\def\Coor@i#1:#2:#3\@nil{%
  #1\ifx\relax#2\relax ]\else\mathpunct{:}\Coor@i#2:#3\@nil\fi\endgroup}
\makeatother

\begin{document}

$\Coor{1}$
foo $\Coor{1:2}$ bar $\Coor{1:2:3}$ baz $[1:2:3]$

\end{document} 
Related Question