1

I am trying to make an array or matrix to represent this matrix: enter image description here

But unfortunately, I don't manage to do it (I even don't know if I should do it with an array or a pmatrix). So, if someone can help me...

2
  • Just a clue, nicematrix have good features to achieve this...Please post the content your image in TeX format, as no one wants to keyin the content....
    – MadyYuvi
    Oct 23, 2021 at 7:42
  • Thank you. I will look at nicematrix. Sorry, but I didn’t understand the problem about my image. It is in jpeg, so how do I post in TeX?
    – Didier
    Oct 23, 2021 at 8:57

2 Answers 2

5

This is a fairly faithful reproduction of the matrix using the nicematrix package.

The solid lines were drawn using the package's ability to insert tikz commands (with \CodeAfter) between the nodes it creates in the cells.

Requires compiling twice.

b

\documentclass[12pt,a4paper]{article}   

\usepackage{tikz} % needed <<<<<<<  
\usepackage{nicematrix} %    needed <<<<<<<

\begin{document}
    \setcounter{MaxMatrixCols}{20}
\[\tilde{A'} = \begin{pNiceMatrix}[first-row, cell-space-limits=5pt]
    &   &   &j_{1}  &   &       &   &j_{2}  &   &\cdots &       &j_{r-1}&       &\cdots &   &j_{r}  &   &       &   &\\
0   &-  &0  &1      &*  &\Cdots &*  &0      &*  &\Cdots &*      &0      &*      &\Cdots &*          &0      &*      &\Cdots &*      &b'_{1} \\
    &   &   &       &   &       &   &       &   &       &\Vdots &\Vdots &\Vdots &       &\Vdots     &\Vdots &\Vdots &       &\Vdots &       \\[-10pt]
    &   &0  &       &   &       &0  &1      &*  &       &       &       &       &       &           &       &       &       &       &b'_{2} \\
    &   &   &       &   &       &   &       &   &       &       &       &       &       &           &       &       &       &       &       \\[-10pt]
    &   &   &       &   &       &0  &       &   &       &       &       &       &       &           &       &       &       &       &b'_{3} \\
    &   &   &       &   &       &   &       &   &       &*      &0      &       &       &           &       &       &       &       &\Vdots \\
    &   &   &       &   &       &   &       &   &       &0      &1      &*      &\Cdots &*          &0      &       &       &       &b'_{r-1}\\
    &   &   &       &   &       &   &       &   &       &       &       &       &       &           &       &       &       &       &       \\[-10pt]       
    &   &   &       &   &       &   &       &   &       &0      &       &       &       &0          &1      &*      &\Cdots &*      &b'_{r} \\
    &   &   &       &   &       &   &       &   &       &       &       &       &       &           &       &       &       &       &       \\[-10pt]
    &   &   &       &   &       &   &       &   &       &       &       &       &       &0          &       &       &       &0      &b'_{r+1}\\
    &   &   &       &   &       &   &       &   &       &       &       &       &       &           &       &       &       &       &\Vdots \\
0   &   &   &       &   &       &   &       &   &       &       &       &       &       &           &       &       &       &0      &b'_{n} \\
\CodeAfter 
\tikz \draw  (2-|1.5) -- (13-|1.5); 
\tikz \draw  (3-|4) -- (3-|7); 
\tikz \draw  (5-|8) -- (5-|9); 
\tikz \draw  (7.5-|10) -- (7.5-|11); 
\tikz \draw  (9-|12) -- (9-|15); 
\tikz \draw  (11-|16) -- (11-|19); 
\tikz \draw  (13.5-|2) -- (13.5-|19); 
\tikz \draw  (2-|3.5) -- (2.5-|3.5); 
\tikz \draw  (4-|7.5) -- (4.5-|7.5); 
\tikz \draw  (8-|11.5) -- (8.5-|11.5); 
\tikz \draw  (10-|15.5) -- (10.5-|15.5); 
\tikz \draw  (12-|19.5) -- (13-|19.5); 
\end{pNiceMatrix}\]

\end{document}
6
  • Waouh! Thank you very much, Simon. I really need to look at nicematrix
    – Didier
    Oct 24, 2021 at 6:39
  • I looked at nicematrix and I understand most of your code. But I don’t understand the horizontal lines. For instance, the line \tikz \draw (3-|4) -- (3-|7). Why isn’t it \tikz \draw (3.5-|4) -- (3.5-|7); like in the last horizontal line?
    – Didier
    Oct 24, 2021 at 17:47
  • @Didier Very good! You pinpointed a small anomaly. The second line (with the \Vdots) ended up taller than the the others blank lines so the third line is in a lower position. For the same reason, the second vertical line --one row high--, is longer than the next three. The improvement is left to the reader :-) Oct 24, 2021 at 21:19
  • Thank you for your answer. I will look at this closely
    – Didier
    Oct 25, 2021 at 18:59
  • In fact, the negative values of the command \` (eg \[-10pt]) are not compatible with nicematrix` and that's why there is a problem with the position of the Tikz nodes... Oct 26, 2021 at 9:01
3

Here is another solution with nicematrix.

\documentclass[a4paper,10pt]{article}
\usepackage{tikz}
\usepackage{nicematrix}

\begin{document}

\setcounter{MaxMatrixCols}{20}

\[
\renewcommand{\arraystretch}{1.4}
\widetilde{A'}=
\begin{pNiceMatrix}[nullify-dots,first-row]
 & &j_1& &      & &j_2& &\cdots       &      &j_{r-1}&      &\cdots&      &j_r   &      &      &      &\\ 
0&0&1  &*&\Cdots&*&0  &*&\hspace*{1cm}& *    &0     &*     &\Cdots&*     &0     &*     &\Cdots&*     &b_1' \\
 &0&   & &      &0&1  &*&             &\Vdots&\Vdots&\Vdots&      &\Vdots&\Vdots&\Vdots&      &\Vdots&b_2' \\
 & &   & &      &0&   & &             &      &      &      &      &      &      &      &      &      &b_3' \\
 & &   & &      & &   & &             &*     &0     &      &      &      &      &      &      &      &\Vdots \\
 & &   & &      & &   & &             &0     &1     &*     &\Cdots&*     &0     &      &      &      &b_{r-1}' \\
 & &   & &      & &   & &             &0     &      &      &      &0     &1     &*     &\Cdots&*     &b_r' \\
 & &   & &      & &   & &             &      &      &      &      &0     &      &      &      &0     &b_{r+1}' \\
 & &   & &      & &   & &             &      &      &      &      &      &      &      &      &      &\Vdots \\  
0& &   & &      & &   & &             &      &      &      &      &      &      &      &      &0     &b_n' 
\CodeAfter
  \begin{tikzpicture} [shorten < = 1mm, shorten > = 1mm]
  \draw (3-6) -- ++(1cm,0) ;
  \draw (2-6) -- (3-6) ;
  \draw (2-2) -- (2-6) ;
  \draw (1-2) -- (2-2) ;
  \draw (1-1) -- (1-2) ;
  \draw (1-1) -- (last-1) ;
  \draw (last-1) -- (last-18) ;
  \draw (last-18) -- (7-18) ;
  \draw (7-18) -- (7-14) ;
  \draw (7-14) -- (6-14) ;
  \draw (6-14) -- (6-10) ; 
  \draw (6-10) -- (5-10) ;
  \draw (5-10) -- ++(-1cm,0) ; 
  %
  \draw [dashed] (1-8) -- (1-10) ;
  \end{tikzpicture}
\end{pNiceMatrix}
\]

\end{document}

As usual with nicematrix, you need several compilations.

Output of the above code

You must log in to answer this question.

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