Redefine \arraycolsep for particular environments
You can use the etoolbox package to make adjustments to environments.
\documentclass{article}
\usepackage{amsmath}
\usepackage{etoolbox}
\AtBeginEnvironment{bmatrix}{\setlength{\arraycolsep}{50pt}}
\begin{document}
\[
\begin{bmatrix}
1 & 2 \\
3 & 4
\end{bmatrix}
\quad
\begin{pmatrix}
1 & 2 \\
3 & 4
\end{pmatrix}
\]
\end{document}
The alteration takes place inside a group, so it will be undone when the environment ends.
Of course, as @Werner has pointed out, the solution to problems with eqnarray
is to use the align
environment from the amsmath package instead.
You can explicitly set the column separation for them. To keep the spacing uniform in the document, you could specify the dimension in the preamble and then just use \BigColSep
:
\documentclass{article}
\def\BigColSep{\setlength{\arraycolsep}{50pt}}
\begin{document}
\[
\begingroup\BigColSep
\begin{array}{cc}
a & b
\end{array}
\endgroup
\]
\end{document}
The \begingroup
and \endgroup
are only required if you mix some other arrays in this particular math display. If it consists only of bmatrix
, they aren't needed.
If you are trying to adjust the \arraycolsep
only to obtain the correct spacing around the =
sign (or other math operators), then you should consider an alternate approach: Use @{}
to eliminate the inter column spacing, and add and extra {}
before the equal sign. Compare the output of the two and you will see that the match.
Notes:
- As others have mentioned if you are using
array
just to align elements in formulas you should consider other options such asalign
, andalignat
.
Code:
\documentclass{article}
\begin{document}
\noindent
Spacing with array:
\[
\begin{array}{r@{}l}
a &{}= b
\end{array}
\]
And without array:
\[
a = b
\]
\end{document}