[Tex/LaTex] Spacing within brackets of a matrix

bracketscolumnsmatricesspacing

I am trying to add extra space after the left bracket and before the right bracket in a matrix. I've changed the column spacing with \arraycolsep, but I also want the entries right aligned.

I can make it work for the left bracket by using \ for the first column, but the right alignment overrides this in the last column:

\begin{vmatrix*}[r] 
    \vec{i} &   \vec{j} &   \vec{k} \ \\
    \ #1        &   #2      &   #3  \\  
    \ #4        &   #5      &   #6 
\end{vmatrix*}

I'm using the following command to input the entries of this matrix:

\def\crossmatrix#1{\crossmatrixentries(#1)}
\def\crossmatrixentries(#1,#2,#3,#4,#5,#6)

I've inserted

\renewcommand\arraystretch{1.5} \arraycolsep=5pt

to help with spacing. I then called the matrix below by

\crossmatrix{-3,-6,9,2,-7,-4}

matrix

Best Answer

Instead of trying to modify the inner workings of the vmatrix* environment, it may be more straightforward to start over with a basic array environment and simply fine-tune some of its settings.

I gather that your main concern is with the spacing between the vertical bars and the contents of the arrays. The following example shows how the spacing may be adjusted. The adjustments amounts used in the example -- 2mu on the left and 5mu on the right -- can, of course, be changed to suit your needs and tastes. (The spacing used internally by vmatrix is 0mu on both sides.)

enter image description here

\documentclass{article}
\usepackage{mathtools,array}
\begin{document}

\begin{tabular}{l>{$}l<{$}}
\texttt{vmatrix*[r]} &
\begin{vmatrix*}[r] 
    \vec{i} &   \vec{j} &   \vec{k} \\
    -3       &  -6      &  9  \\  
    2        &  -7     &   -4
\end{vmatrix*} \\[5ex]
\texttt{array} & 
\left\lvert\begin{array}{@{\mkern3mu} rrr @{\mkern5mu}}
    \vec{i} &   \vec{j} &   \vec{k} \\
    -3       &  -6      &  9  \\  
    2        &  -7     &   -4
\end{array}\right\rvert\\
\end{tabular}

\end{document}