2

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, the0 should be centred between the first two columns, while theI should be centred between the last three columns.

I was able to obtain a much better spacing using thenicematrix package, however I have no idea how to produce the vertical line, whichshould 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

F. Pantigny's user avatar
F. Pantigny
52.5k4 gold badges60 silver badges99 bronze badges
askedApr 21, 2020 at 12:57
A.P.'s user avatar
5
  • There is a typo in your code: you wrote{\bigid_{n-m}) instead of{\bigid_{n-m}}.CommentedApr 21, 2020 at 13:27
  • @F.Pantigny Thanks, fixed.CommentedApr 21, 2020 at 13:28
  • Possibly related:tex.stackexchange.com/questions/99238/compact-block-matrixCommentedApr 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 usingnicematrix.CommentedApr 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.CommentedApr 22, 2020 at 9:54

2 Answers2

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 first code


With recent versions ofnicematrix, you can merely use the keyborders of the command\Block:

\documentclass{article}\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[borders=right]{2-2}{\bigzero} & & \Block{2-3}{\bigid_{n-m}} &  \\      & & & &    \end{pNiceArray}  \end{equation*}\end{document}

Output of the second code

answeredApr 21, 2020 at 13:39
F. Pantigny's user avatar
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 optionmargin move vertical lines between block)?CommentedApr 21, 2020 at 14:58
  • 1
    @Zarko: You are right. It's not possible to understand how this answer works because the documentation ofnicematrix is incomplete. I will complete that documentation soon. In a few words, the recent versions ofnicematrix 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.CommentedApr 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 bynicematrix. However, it's possible to use\cmidrule ofbooktabs to have an horizontal rule a bit shorter.CommentedApr 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 withmargin 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!CommentedApr 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 andPackage pgf Error: No shape named col-3 is known (plus similar ones forrow-4 androw-6. I tried upgradingnicematrix to the latest available revision (54758 according to mytllocalmgr), to no avail.CommentedApr 22, 2020 at 10:21
4

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

answeredApr 21, 2020 at 13:47
F. Pantigny's user avatar
1
  • While I like this solution because it is in a sense simpler in not requiringtikz, I prefer the more centred alignment of the vertical bar in your other answer.CommentedApr 22, 2020 at 9:55

You mustlog in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.