12

I am trying to write some kind of blockmatrix

enter image description here

\[A_n=
\left(
   \begin{array}{cc|cc}
    && 0 & 0 \\
    & A_{n-2}&n-2&0 \\
    \hline\\
    0&-n+2&1&n-1 \\
    0&0&-n+1&1
    \end{array}
\right)
\]

How can I achieve that the entry in the upper left corner is written in center? Or rephrased: How is it possible two combine the columns (1,1)(1,2)(2,1) and (2,2)?

1
  • 1
    Avoid using $$<math content>$$. Use instead \[<math content>\]
    – azetina
    Jan 9, 2014 at 19:46

2 Answers 2

16

You're probably after the second of the following two instances (the first is yours):

enter image description here

\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\begin{document}
\begin{align*}
  A_n &= \left(\begin{array}{cc|cc}
        &         &     0 &      0 \\
        & A_{n-2} & n - 2 &      0 \\
      \hline \\
      0 &  -n + 2 &      1 & n - 1 \\
      0 &       0 & -n + 1 &     1
    \end{array}\right) \\
  A_n &= \left(\begin{array}{cc|cc}
        &         &     0 &      0 \\
      \multicolumn{2}{c|}{\smash{\raisebox{.5\normalbaselineskip}{$A_{n-2}$}}}
                  & n - 2 &      0 \\
      \hline \\[-\normalbaselineskip]
      0 &  -n + 2 &      1 & n - 1 \\
      0 &       0 & -n + 1 &     1
    \end{array}\right)
\end{align*}
\end{document}

Horizontal centering is achieved via \multicolumn{2}{c}, while vertical centering is obtained via \raisebox{.5\normalbaselineskip}. \smash removes any vertical distortion (from raising the boxed content), while the negative skip after \hrule vertically aligns the vertical rules (top and bottom).

0

With {pNiceArray} of nicematrix.

\documentclass{article}
\usepackage{nicematrix}

\begin{document}

$\begin{pNiceArray}{cc|cc}[margin=2pt]
\Block{2-2}<\Large>{A_{n-2}} 
  &        & 0     & 0      \\
  &        & n - 2 &      0 \\
\hline 
0 &  -n + 2 &      1 & n - 1 \\
0 &       0 & -n + 1 &     1
\end{pNiceArray}$

\end{document}

Output of the above code

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .