# is it possible to add dashed lines between rows/column of pmatrix from amsmath?

I wish these packages from amsmath have more options!

Is there a way to add a macro to add dashed lines between rows and columns for a matrix typeset using pmatrix? Similar to what is being asked here A Matrix with labels, dashed lines

But I can't use the solution given in the above, since I have to use pmatrix

I have to use pmatrix, since this is what Scientific Word supports/produces when I click on add a matrix from the GUI and I have no control over changing this. Here is a typical Latex file generated using one matrix

\documentclass{article}%
\usepackage{amsmath}%
\usepackage{amsfonts}%
\begin{document}
This is my matrix

$\begin{pmatrix} \sin x & \cos x\\ B & A \end{pmatrix}$
\end{document}


I can't modify the code generated and change pmatrix to say array or such in order to use the solution shown above, since then SW will not display the result on the screen when I open the file again to continue working on it. But what I can do is add a macro in the preamble to modify the definition of pmatrix since I use texlive 2013 to build the file and only use SW for entering the math since it is much easier for me to do so at this time.

So, I'd like to ask for help if there is a way to use some \renewcommad or such to replace pmatrix with array or some other solution in order to add these dashed lines between rows and columns when compiling the file?

thank you,

• I'm sure also SWP allows for inserting raw LaTeX code. – egreg Mar 4 '14 at 9:29
• @egreg Yes, ofcourse it does. But then why would I use the GUI in the first place? :) I am trying to typeset very complicated matrix with lots of math (aerodynamics have so many subscripts and superscripts) and it is much easier to do it using SWP at this time. I could not do it using raw Latex. Not good yet. I'll be late finishing the HW if I write all this using raw Latex. – Nasser Mar 4 '14 at 9:33

On a one-off basis, you can replace the pmatrix environment by a BMAT (from the easybmat package). However, BMAT requires more details about the columns, so this won't work if you have multiple matrices with different sizes.

\documentclass{article}
\usepackage{amsmath}
\usepackage{easybmat}
\renewenvironment{pmatrix}{\left(\begin{BMAT}(b){l.cr}{t.cb}}
{\end{BMAT}\right)}
\begin{document}
$\begin{pmatrix} 1_{j} & 1 & 1 \\ 1_{j} & 1 & \frac{111}{222} \\ 1 & 1_{j} & 1 \end{pmatrix}$
\end{document}


You could also do this on a case-by-case basis, by putting the redefinition in a group.

\documentclass{article}
\usepackage{amsmath}
\usepackage{easybmat}

\begin{document}
$\bgroup \renewenvironment{pmatrix}{\left(\begin{BMAT}(b){l.cr}{t.cb}} {\end{BMAT}\right)} \begin{pmatrix} 1_{j} & 1 & 1 \\ 1_{j} & 1 & \frac{111}{222} \\ 1 & 1_{j} & 1 \end{pmatrix} \egroup$
\end{document}


Ultimately, if a GUI means you have to resort to hacks like this, it is probably more trouble than it is worth.

\documentclass{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{arydshln}
\begin{document}
This is my matrix

$\left(\, \begin{array}{ : c : c : }\hdashline \sin x & \cos x\\\hdashline B & A \\\hdashline \end{array}\,\right)$
\end{document}


• Thanks for the answer.Unfortunately I can't use it with SWP now as I said, I can't change the code after \begin{document} as SWP does not understand array so the above will not display on the GUI. But please keep this answer, it is useful and I can use it when I graduate to using raw Latex one day. – Nasser Mar 4 '14 at 13:34