1

I'd like to have the TeX code of this matrix in the photo, please:

Study-Matrix

enter image description here I state that I know something of nicematrix and tikz-packages and I use stix.

I'd like to have the TeX code of the same matrix with the difference that pmatrix is contained in a box, this is, I'd like the TeX code of the photo with completed (closed) box and the TeX code of \diagbox{A_i}{A_j} only, too.

I hope have been clear.

I've started with this code:

\documentclass{article}
\usepackage{nicematrix}
\usepackage{stix}
\usepackage{mathtools}
\usepackage{amsmat}
\begin{document}
$$\begin{NiceMatrix}[columns-width=5mm]
\diagbox{\scriptstyle A_i}{\scriptstyle A^j} 
\Block[hvlines]{1-4}{}
\Block[hvlines]{4-1}{}
& A^1 & A^2 & A^3 \\
A_1 & 1 & 2 & 3 \\
A_2 & 4 & 5 & 6 \\
A_3 & 7 & 8 & 9 
\CodeAfter
\boxed{\SubMatrix({2-2}{4-4})[xshift=-0.85mm]
\begin{tikzpicture} [dashed,shorten > = 2mm, shorten < = 2mm]
  \draw (3-|2) -- (3-|5) ; 
  \draw (4-|2) -- (4-|5) ;
  \draw (2-|3) -- (5-|3) ;
  \draw (2-|4) -- (5-|4) ;
  \end{tikzpicture}}
\end{NiceMatrix}$$

\end{document}
2
  • 5
    What have you tried so far? Have you tried with nicematrix? Commented Jun 29, 2021 at 18:05
  • 5
    Welcome to TeX.SX! On this site, a question should typically revolve around an abstract issue (e.g. "How do I get a double horizontal line in a table?") rather than a concrete application (e.g. "How do I make this table?"). Questions that look like "Please do this complicated thing for me" tend to get closed because they are either "off topic", "too broad", or "unclear". Please try to make your question clear and simple by giving a minimal working example (MWE): you'll stand a greater chance of getting help.
    – Rmano
    Commented Jun 29, 2021 at 18:14

1 Answer 1

13

Here is a solution with nicematrix.

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

\begin{document}


\renewcommand{\arraystretch}{1.4}
$\begin{NiceMatrix}[columns-width=5mm]
\diagbox{\scriptstyle A_i}{\scriptstyle A^j} 
\Block[hvlines]{1-4}{}
\Block[hvlines]{4-1}{}
& A^1 & A^2 & A^3 \\
A_1 & 1 & 2 & 3 \\
A_2 & 4 & 5 & 6 \\
A_3 & 7 & 8 & 9 
\CodeAfter
  \SubMatrix({2-2}{4-4})[xshift=-0.85mm]
  \begin{tikzpicture} [dashed,shorten > = 2mm, shorten < = 2mm]
  \draw (3-|2) -- (3-|5) ; 
  \draw (4-|2) -- (4-|5) ;
  \draw (2-|3) -- (5-|3) ;
  \draw (2-|4) -- (5-|4) ;
  \end{tikzpicture}
\end{NiceMatrix}$

\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 .