[Tex/LaTex] Dashed line within matrix without using arydshln

matrices

I would like to create a partitioned matrix where the partitions will be delimited by dashed lines. The most obvious solution is the use of the arydshln package, but it seems to be absolutely incompatible with some of the numerous other packages I am using. I am aware that some incompatibilities are known (like with the colortab pacakge) and are supposed to be solved by calling arydshln after the other packages. In my case, it does not work, so I really have to find an alternative to arydshln.

This post proposes some alternatives, including the TikZ and stackengine packages. The Tikz package seems to create images that cannot be inserted in-line, and stackengine just produces really ugly outputs.

So my question is: is there a way, preferably reasonably simple, to create dashed lines within a matrix? I would like to use a code that looks like this:

\documentclass{article}
\usepackage{amsmath}
\usepackage{blkarray}


\begin{document}

$\begin{blockarray}{ccc}
\begin{block}{(cc)c}
x_1 & x_2 & r_1 \\
x_3 & x_4 & r_2 \\
\end{block}
c_1 & c_1 &
\end{blockarray}$

\end{document}

enter image description here

There would be a dashed line between the two rows and the two columns of the matrix. I am not especially attached to the blkarray package, but I need a way to write indices outside the matrix to indicate the dimension of the partitions.

Thanks a lot!

Best Answer

Here is how to do it with pst-node. Another possibility would to use a grey continuous line. I give a code for both:

\documentclass[svgnames, x11names, table]{article}
\usepackage{amsmath}
\usepackage{blkarray, booktabs}
\usepackage{xcolor}
\usepackage{pst-node}
% \usepackage{auto-pst-pdf} % for pdflatex compilation. Requires pdflatex --enable-write18 (MiKTeX) 
                                                 % or pdflatex -shell-escape (TeX Live, MacTeX)

\begin{document}

\begin{pspicture}$
\begin{blockarray}{ccc}
\begin{block}{(cc)c}
\rnode[l]{x1}{x_1}\pnode[1.4ex, 1.4ex]{T} & \rnode[r]{x2}{x_2} & r_1 \\
\rnode[l]{x3}{x_3}\pnode[1.4ex, -0.8ex]{B} & x_4 & r_2 \\
\end{block}
c_1 & c_2 &
\end{blockarray}$
\psset{linewidth=0.4pt, linestyle=dashed, dash=2pt 2pt}
\pcline[offset =-1.4ex]{-}(x1)(x2)
\ncline{T}{B}
\end{pspicture}

\vspace{1cm}

{\aboverulesep = 0pt\belowrulesep = 0pt
$\begin{blockarray}{ccc}
\begin{block}{(c!{\color{Snow3}\vrule}c)c}
\rnode[l]{x1}{x_1}\pnode[1.4ex, 1.4ex]{T} & \rnode[r]{x2}{x_2} & r_1 \\
\arrayrulecolor{Snow3}\cmidrule(lr){1-2}
\rnode[l]{x3}{x_3}\pnode[1.4ex, -0.8ex]{B} & x_4 & r_2 \\
\end{block}
c_1 & c_2 &
\end{blockarray}$}

\end{document} 

enter image description here