# pmatrix not rendering correctly -- possibly a wileySix problem

Original post below A couple of people asked for a whole document:

\documentclass{wileySix}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}

\begin{document}
$\mathbf{y}= \begin{pmatrix} y_1 \\ y_2 \end{pmatrix}\mbox{ and } \boldsymbol{\mu}=\begin{pmatrix} \mu_1 \\ \mu_2 \end{pmatrix}$

\end{document}

This problem goes away when the documentclass is changed from wileySix to article. I will investigate.

Original post Hi I would like to write the following expression in LaTeX using pmatrix

I can do this with standard older TeX:

\mathbf{y}=\left(\begin{array}{c} y_1 \\ y_2
\end{array} \right)  \mbox{ and }  \boldsymbol{\mu}=
\left(\begin{array}{c} \mu_1\\ \mu_2
\end{array} \right)

However, I think I should be able to do this much more neatly with using pmatrix from the amsmath package:

\mathbf{y}=
\begin{pmatrix}
y_1 \\ y_2
\end{pmatrix}\mbox{ and }
\boldsymbol{\mu}=\begin{pmatrix}
\mu_1 \\ \mu_2
\end{pmatrix}

What I end up with in the rendered document is this

which clearly has problems. I'm running on MacTeX, but that has never caused me problems elsewhere. Any advice would be appreciated

• please post a complete document that produces the image shown, so we can reproduce and debug. Nov 12, 2015 at 20:51
• this doesn't happen with \documentclass{article} \usepackage{mathtools} so you must be using some class or package that redefines what is provided by amsmath. we can't help if we don't know what you're using. Nov 12, 2015 at 21:03
• The wileysix class redefines \@array, which confuses amsmath. Nov 12, 2015 at 22:05
• @barbarabeeton it happens when I use \documentclass{wileySix} From my naive scan through the class file, I can find very little dealing with mathematics (there is a macro for making symbols bold and something for equation numbering). However, it does only happen with this class. Nov 12, 2015 at 22:07

The wileysix class redefines \@array in a small but decisive detail:

### LaTeX kernel definition

\def\@array[#1]#2{%
\if #1t\vtop \else \if#1b\vbox \else \vcenter \fi\fi
\bgroup
\setbox\@arstrutbox\hbox{%
\vrule \@height\arraystretch\ht\strutbox
\@depth\arraystretch \dp\strutbox
\@width\z@}%
\@mkpream{#2}%
\edef\@preamble{%
\ialign \noexpand\@halignto
\bgroup \@arstrut \@preamble \tabskip\z@skip \cr}%
\let\@startpbox\@@startpbox \let\@endpbox\@@endpbox
\let\tabularnewline\\%
\let\par\@empty
\let\@sharp##%
\set@typeset@protect
\lineskip\z@skip\baselineskip\z@skip
\ifhmode \@preamerr\z@ \@@par\fi
\@preamble}

### wileysix.cls definition

\def\@array[#1]#2{%
\if #1t\vtop \else \if#1b\vbox \else \vcenter \fi\fi
\bgroup
\setbox\@arstrutbox\hbox{%
\vrule \@height\arraystretch\ht\strutbox
\@depth\arraystretch \dp\strutbox
\@width\z@}%
\@mkpream{@{}#2@{}}%
\edef\@preamble{%
\ialign \noexpand\@halignto
\bgroup \@arstrut \@preamble \tabskip\z@skip \cr}%
\let\@startpbox\@@startpbox \let\@endpbox\@@endpbox
\let\tabularnewline\\%
\let\par\@empty
\let\@sharp##%
\set@typeset@protect
\lineskip\z@skip\baselineskip\z@skip
\ifhmode \@preamerr\z@ \@@par\fi
\@preamble}

The difference is in the line

\@mkpream{#2}%

that becomes

\@mkpream{@{}#2@{}}%

so that no padding is added at the left and right of an array. On the other hand, amsmath manually fixes the padding in matrices, by adding a negative space between the fences and the matrix:

\renewenvironment{matrix}{%
\matrix@check\matrix\env@matrix
}{%
\endarray \hskip -\arraycolsep
}
\def\env@matrix{\hskip -\arraycolsep
\let\@ifnextchar\new@ifnextchar
\array{*\c@MaxMatrixCols c}}
\renewenvironment{pmatrix}{%
\left(%
\matrix@check\pmatrix\env@matrix
}{
\endmatrix\right)%
}

The \hskip -\arraycolsep are exactly the negative spaces I was talking about. The one on the right has its effect, because the standard preamble of a matrix is specified and the last column is not reached until the matrix has \MaxMatrixCols columns.

I find the redefinition in the class very silly: it is done exactly for the same purpose of amsmath, that is, not having a gap between the fences and the coefficients of the matrix. But the cure is worse than the disease.

I see no real problem in fixing the meaning of \@array to be the kernel one. Just remember to manually add @{} at either side of an array column specification in cases you use the environment for special matrices with non standard center alignment.

\documentclass{wileysix}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{etoolbox}

\makeatletter
\patchcmd{\@array}{\@mkpream{@{}#2@{}}}{\@mkpream{#2}}{}{}
\makeatother

\begin{document}
$\mathbf{y}= \begin{pmatrix} y_1 \\ y_2 \end{pmatrix}\mbox{ and } \boldsymbol{\mu}=\begin{pmatrix} \mu_1 \\ \mu_2 \end{pmatrix}$
\end{document}

• @JamesCurran Another way could be removing \hskip -\arraycolsep from the definition of \env@matrix and setting \MaxMatrixCols to 30, so you don't risk hitting the upper limit. Nov 12, 2015 at 22:31