Spacing within brackets of a matrix

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}


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.)

\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}  • Thank you, both this and Steven B. Segletes answers work great, although this seems to require less work. – Abbas Jaffary Jun 4 '15 at 22:01 I see the difficulty arising from two things: 1) the matrix columns are right aligned, which tends to weigh heavily on the right side of the matrix; and 2) the columns are free to assume unequal widths (the OP's MWE didn't stress this issue, but I believe that selecting terms that do so would show additional imbalance). So my solution was to force matrix columns to be of equal width (which I can achieve with the use of TABstacks) and also to pad the right hand of each entry with a 3pt \kern, and pad the left hand of column 1 with an identical \kern. In the MWE below, I give three examples: what the OP showed; an example with different width data in the columns; and an example without any negative numbers. \documentclass{article} \usepackage{tabstackengine} \def\crossmatrix#1{\crossmatrixentries(#1)} \def\crossmatrixentries(#1,#2,#3,#4,#5,#6){% \fixTABwidth{T}% FIXED COLUMN WIDTH \setstacktabbedgap{6pt}% INTERCOLUMN SPACING \setstackgap{L}{18pt}% INTERROW BASELINESKIP \def\>{\kern3pt}% EXTRA KERN APPLIED VARIOUSLY THROUGHOUT \vertMatrixstack[r]{ \>\vec i\> & \vec j\> & \vec k\> \\ \>#1\> & #2\> & #3\>\\ \>#4\> & #5\> & #6\> } = \vertMatrixstack[r]{ \>#2\> & #3\>\\ \>#5\> & #6\> } \vec i - \vertMatrixstack[r]{ \>#1\> & #3\>\\ \>#4\> & #6\> } \vec j + \vertMatrixstack[r]{ \>#1\> & #2\>\\ \>#4\> & #5\> } \vec j } \begin{document} The cross product \vec{PQ} \times \vec{PR} generates the normal vector \[ \vec n = \crossmatrixentries(-3,-6,9,2,-7,-4)
$\vec n = \crossmatrixentries(-3,-63,9,2,-7,-40)$
$\vec n = \crossmatrixentries(3,6,9,2,7,4)$
\end{document}