Quantcast
Channel: Active questions tagged mathtools - TeX - LaTeX Stack Exchange
Viewing all articles
Browse latest Browse all 90

Matrix with evenly spaced columns

$
0
0

Similar question: How can I make a similar matrix with even column spacing?


The following code is simple to write/read/maintain, but looks terrible.

\documentclass{article}\usepackage{amsmath}\usepackage{mathtools}\begin{document}\begin{equation*}    \begin{bmatrix*}[r]        1 &  0 & 0 \\        0 & -1 & 0 \\        0 &  0 & 1    \end{bmatrix*}  \end{equation*}\end{document}

enter image description here

This is because the negative sign adds extra space between the first and second columns, but not between the second and third.


One could naively put a \phantom{-} in each column, but this isn't right either.

\begin{equation*}    \begin{bmatrix*}[r]        \phantom{-}1 &  0 & 0 \\        0 & -1 & 0 \\        0 &  0 & \phantom{-}1    \end{bmatrix*}\end{equation*}

enter image description here

This is because we don't need extra space to the left of each column, but an even amount of space between each column.


\begin{gather*}    \begin{bmatrix*}[r]        1 &  0 & 0 \\        0 & -1 & 0 \\        0 &  0 & 1    \end{bmatrix*} \\    \begin{bmatrix*}[r]        1 &  0 & 0 \\        0 & -1 & 0 \\        0 &  0 & \phantom{-}1    \end{bmatrix*}  \end{gather*}

enter image description here

Much better. (The second one, compared to the original above it.)


However, in larger matrices, this can easily become hard to read and quite a hassle to maintain. Is there some simple way to tell it to put an equal amount of space (say, between the right hand sides) of columns 1&2, 2&3, 3&4, ... ?

Ideally, I'd like the body of my matrices to contain nothing other than the content:

1 &  0 & 0 \\0 & -1 & 0 \\0 &  0 & 1

Viewing all articles
Browse latest Browse all 90

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>