21

I'm trying to TeX the following matrix, from Guillemin and Pollack (1.4 #13)

enter image description here

The best I've been able to do is get the dashed lines with

\[ \left( \begin{array}{c:c} B &  C \\ \hdashline
D & E \end{array} \right) \]


If you want to test this try

\documentclass[11pt]{article}
\usepackage{arydshln}
\begin{document}
\[ \left( \begin{array}{c:c} B &  C \\ \hdashline
D & E \end{array} \right) \]

\end{document}

Output looks like this:

enter image description here

F. Pantigny
  • 40,250
Frederick
  • 313
  • 1
    Welcome to TeX.SE. While code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. – Peter Grill Oct 26 '12 at 04:48

2 Answers2

12

Perhaps the following is more suitable:

enter image description here

\documentclass{article}

\usepackage{arydshln,leftidx,mathtools}

\begin{document}

[ \setlength{\dashlinegap}{2pt} \leftidx{_{m-r}^{\phantom{m-r}\llap{$\scriptstyle r$}}}{\left( \begin{array}{c:c} \smash{\overset{r}{B}} & \mathclap{\smash{\overset{n-r}{C}}} \ \hdashline D & E \end{array} \right)}{} ]

\end{document}

The gaps between the dashes of \hdashline has been shortened from 4pt down to 2pt. mathtools provides \mathclap (a zero-width box that is centred) and also loads amsmath, which provides \overset (a math accent-type macro). I've \smashed the elements in the first row to not let the array delimiters over the height of B or C.

leftidx is a super-small package that adds left indexing functionality. See Superscripts before a letter in math.

Werner
  • 603,163
  • Interesting packages. First time am seeing them :-) Just put the A= to finish it up. – azetina Oct 26 '12 at 05:05
  • That's exactly what I was looking for. Thanks! – Frederick Oct 26 '12 at 07:29
  • @Werner -- the spacing around the parens (both inside and out) looks too wide to me. i'd also be inclined to raise the "overscripts" a tiny bit to avoid crashing into the right-hand paren if it's tightened (ah, yes, \smash wouldn't work in that case). otherwise, very nice. – barbara beeton Oct 26 '12 at 12:37
2

The package nicematrix provides tools to add exterior rows and columns to a matrix. It has built-in commands to draw dotted lines (with real rounded dots).

For other styles of rules, it's possible to define letters (in the preamble of the array) and commands (for the horizontal rules) for any Tikz style of line.

You need at least version 6.6 of nicematrix (2022-02-16).

\documentclass{article}
\usepackage{nicematrix}
\usepackage{mathtools}
\usepackage{tikz}

\begin{document}

\NiceMatrixOptions{code-for-first-row = \scriptstyle,code-for-first-col = \scriptstyle }

$A = \begin{pNiceArray}{c:c}[first-row, first-col, columns-width=auto] & r & n-r \ r & B & C \ \hdottedline m-r & D & E \end{pNiceArray}$

\bigskip

\NiceMatrixOptions { custom-line = { letter = I , command = hdashedline , tikz = dashed , width = \pgflinewidth } }

$A = \begin{pNiceArray}{cIc}[first-row, first-col, columns-width=auto] & r & n-r \ r & B & C \ \hdashedline m-r & D & E \end{pNiceArray}$

\end{document}

You need several compilations (because nicematrix uses PGF/Tikz nodes).

Output of the above code

F. Pantigny
  • 40,250