1

I would like to create a partial block matrix, with two blocks on the bottom row, separated by a vertical line between them, and separated from the rest of the matrix by a horizontal line.

My first attempt captured the idea, but the alignment was lacking

\documentclass{article}

\usepackage{amsmath}

\newcommand{\bigzero}{\mbox{\normalfont\Large\bfseries 0}}
\newcommand{\bigid}{\mbox{\normalfont\Large\bfseries I}}

\begin{document}
  \begin{equation*}
    \begin{pmatrix}
      \begin{matrix}
        1 & x_0 & x_0^2  & \dots & x_0^n \\
          &     & \vdots &       & \\
        1 & x_m & x_m^2  & \dots & x_m^n \\
      \end{matrix} \\
      \hline
      \begin{array}{c c | c c c}
        \bigzero & & & \bigid_{n-m} &
      \end{array}
    \end{pmatrix}
  \end{equation*}
\end{document}

Original matrix

Ideally, I would like a little more space between the horizontal line and the rows. Furthermore, the 0 should be centred between the first two columns, while the I should be centred between the last three columns.

I was able to obtain a much better spacing using the nicematrix package, however I have no idea how to produce the vertical line, which should join with the horizontal line but not spread into the first three rows.

\documentclass{article}

\usepackage{amsmath}
\usepackage{nicematrix}

\newcommand{\bigzero}{\mbox{\normalfont\Large\bfseries 0}}
\newcommand{\bigid}{\mbox{\normalfont\Large\bfseries I}}

\begin{document}
  \begin{equation*}
    \begin{pNiceArray}{CCCCC}
      1 & x_0 & x_0^2  & \cdots & x_0^n \\
        &     & \Vdots &       & \\
      1 & x_m & x_m^2  & \cdots & x_m^n \\
      \hline
      \Block{2-2}{\bigzero} & & \Block{2-3}{\bigid_{n-m}} &  \\
      & & & &
    \end{pNiceArray}
  \end{equation*}
\end{document}

enter image description here

5
  • There is a typo in your code: you wrote {\bigid_{n-m}) instead of {\bigid_{n-m}}. Apr 21, 2020 at 13:27
  • @F.Pantigny Thanks, fixed.
    – A.P.
    Apr 21, 2020 at 13:28
  • Possibly related: tex.stackexchange.com/questions/99238/compact-block-matrix
    – steve
    Apr 21, 2020 at 13:52
  • @ABlueChameleon I read that question while doing my due diligence, but not only it is not immediately clear how to adapt the answer to this particular case, it also seems a lot more convoluted than using nicematrix.
    – A.P.
    Apr 22, 2020 at 9:51
  • 1
    @A.P. I didn't mean to say that I thought this was a duplicate or anything, but rather that if someone was looking for ways to typeset block matrices, there were additional options over there.
    – steve
    Apr 22, 2020 at 9:54

2 Answers 2

3

You can draw the rule you want with a Tikz instruction:

\documentclass{article}

\usepackage{nicematrix}
\usepackage{tikz}

\newcommand{\bigzero}{\mbox{\normalfont\Large\bfseries 0}}
\newcommand{\bigid}{\mbox{\normalfont\Large\bfseries I}}

\begin{document}
  \begin{equation*}
    \begin{pNiceMatrix}
      1 & x_0 & x_0^2  & \Cdots & x_0^n \\
        &     & \Vdots &       & \\
      1 & x_m & x_m^2  & \Cdots & x_m^n \\
      \hline
      \Block{2-2}{\bigzero} & & \Block{2-3}{\bigid_{n-m}} &  \\
      & & & &
      \CodeAfter
      \tikz \draw (4-|3) -- (6-|3) ;
    \end{pNiceMatrix}
  \end{equation*}
\end{document}

Result of the above code

7
  • I miss similar example in package documentation. With some explanation, how vertical line is drawn. Also, is there a way to draw\hline˙ that it will not touch delimiter parenthesis (use option margin move vertical lines between block)?
    – Zarko
    Apr 21, 2020 at 14:58
  • 1
    @Zarko: You are right. It's not possible to understand how this answer works because the documentation of nicematrix is incomplete. I will complete that documentation soon. In a few words, the recent versions of nicematrix create new nodes, a node for each row and a node for each column corresponding to the position of the (potential) rules in the array. Apr 21, 2020 at 15:12
  • @Zarko: It's not possible to change the horizontal rule created by \hline. The command \hline has not been modified by nicematrix. However, it's possible to use \cmidrule of booktabs to have an horizontal rule a bit shorter. Apr 21, 2020 at 15:16
  • Thank you for explanation in the first comment. Solution proposed in second comments works (fine), but to my opinion is to rude. Use simple \hline in conjunction with margin option, if they will work properly, seems to be more consistent with existed solution (which not use new nodes for rows and columns). Anyway, +1 for answer!
    – Zarko
    Apr 21, 2020 at 15:35
  • Unfortunately, I cannot get this to run (I copied your code as-is). I get two errors: Undefined control sequence. \CodeAfter and Package pgf Error: No shape named col-3 is known (plus similar ones for row-4 and row-6. I tried upgrading nicematrix to the latest available revision (54758 according to my tllocalmgr), to no avail.
    – A.P.
    Apr 22, 2020 at 10:21
3

You can also use two instructions \multicolumn:

\documentclass{article}

\usepackage{amsmath}
\usepackage{nicematrix}

\newcommand{\bigzero}{\mbox{\normalfont\Large\bfseries 0}}
\newcommand{\bigid}{\mbox{\normalfont\Large\bfseries I}}

\begin{document}
  \begin{equation*}
    \begin{pNiceMatrix}
      1 & x_0 & x_0^2  & \Cdots & x_0^n \\
        &     & \Vdots &       & \\
      1 & x_m & x_m^2  & \Cdots & x_m^n \\
      \hline
      \Block{2-2}{\bigzero} & \multicolumn{1}{C|}{} & \Block{2-3}{\bigid_{n-m}} &  \\
      & \multicolumn{1}{C|}{} & & &
    \end{pNiceMatrix}
  \end{equation*}
\end{document}

Result of the above code

1
  • While I like this solution because it is in a sense simpler in not requiring tikz, I prefer the more centred alignment of the vertical bar in your other answer.
    – A.P.
    Apr 22, 2020 at 9:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.