[Tex/LaTex] How to create vertical and horizontal dotted lines in a matrix

arraysmath-modematricesrulestabularx

Similar to this question, I am trying to output a similar matrix with dotted line instead of dashed line.

enter image description here

  1. Is there anyway to do this?

  2. I also try to use these three packages:

    \usepackage{tabularx}
    \usepackage{longtable}
    \usepackage{arydshln}
    
  3. I also like to learn how to implement this in \documentclass{revtex4}, in addition to using in \documentclass{article}. As far as we know that arydshln may not be compatible with revtex4 or revtex4-1 as far as I tried.

I encounter a problem like this post. And I add arydshln after the tabularx; but it cannot compile successfully, but only output errors. Could someone offer any hints or some resolutions?

The answer needs not to be complete. Thank you for your help!!!

Best Answer

Since revtex4 seems to be incompatible with the arydshln package, here's an option using TikZ:

\documentclass[aps,prl,twocolumn,nofootinbib,superscriptaddress,floatfix]{revtex4}
\usepackage{tikz}
\usetikzlibrary{matrix}

\begin{document}

\[
\Biggl(\mkern-5mu
\begin{tikzpicture}[baseline=-.65ex]
\matrix[
  matrix of math nodes,
  column sep=1ex,
] (m)
{
B & C \\
D & E \\
};
\draw[dotted]
  ([xshift=0.5ex]m-1-1.north east) -- ([xshift=0.5ex]m-2-1.south east);
\draw[dotted]
  (m-1-1.south west) -- (m-1-2.south east);
\node[above,text depth=1pt] at (m-1-1.north) {$\scriptstyle r$};  
\node[above,text depth=1pt] at (m-1-2.north) {$\scriptstyle n-r$};
\node[left,overlay] at ([xshift=-1.2ex]m-1-1.west) {$\scriptstyle r$};
\node[left,overlay] at ([xshift=-1.2ex]m-2-1.west) {$\scriptstyle n-r$};
\end{tikzpicture}\mkern-5mu
\Biggr)
\]

\end{document}

enter image description here