# How to preserve spacing between array elements?

I have this code

$[-0.5 0 -1.5]$


but I get this result:

I want to respect the spaces, how do I fix it?

With array or a TABstack. With the latter, the intercolumn gap is specified by way of \setstacktabbedgap{6pt}.

You could also use a \bracketMatrixstack{} in lieu of [\Matrixstack{}], which would invoke the \left[...\right] mechanism, in case the matrix grew to several rows in height.

\documentclass{article}
\usepackage{tabstackengine}
\TABstackMath
\setstacktabbedgap{6pt}
\begin{document}
$[\begin{array}{@{}ccc@{}} -0.5 & 0 &-1.5 \end{array}]$
$[\Matrixstack{-0.5 & 0 &-1.5}]$
$\bracketMatrixstack[r]{-0.5 & .0 &-1.5\\ 11.0 & 2.0 & 3.0}$
\end{document}


Or you can simply use $[0.5\,0\,0.5]$. That will provide space between numbers.