6

enter image description here

I want to draw something similar to what is shown using tikz capabilities of nicematrix. Also, is it possible to control the spacing between comments and arrows tails?

\documentclass[11pt, a4paper]{article}

\usepackage{tikz}

\usepackage{nicematrix}
\NiceMatrixOptions{rules/color=[gray]{0.75}, hvlines}

\begin{document}

\begin{alignat*}{2}
    x
    & =
    \begin{bNiceMatrix}[r]
        1 & 4 & 7
        \\
        2 & 5 & 8
        \\
        3 & 6 & 9
        \\
    \end{bNiceMatrix}
\end{alignat*}

\end{document}

1 Answer 1

6
\documentclass[11pt, a4paper]{article}
\usepackage{tikz}

\usepackage{nicematrix}
\NiceMatrixOptions{rules/color=[gray]{0.75}, hvlines}

\begin{document}

\begin{alignat*}{2}
    x
    & =
    \begin{bNiceMatrix}[r]
        1 & 4 & 7
        \\
        2 & 5 & 8
        \\
        3 & 6 & 9
        \\
    \CodeAfter
       \begin{tikzpicture}
       \draw [->] (1-|2) -- (3-|4) ; 
       \node at ([yshift=1mm]1-|2) {\tiny\(k=+1\)} ;
       \draw [->] (2-|1) -- (4-|3) ; 
       \node at ([xshift=-0.7mm]2-|1) [rotate=90] {\tiny\(k=-1\)} ;
       \end{tikzpicture}
    \end{bNiceMatrix}
\end{alignat*}

\end{document} 

As usual with nicematrix, you need several compilations.

Output of the above code

2
  • Is is possible to get arrow heads as shown in the example image? Commented Feb 16, 2023 at 10:35
  • 1
    @Al-MotasemAldaoudeyeh you can search on pgfmanual ctan.org/pkg/pgf \documentclass[tikz,border=5mm]{standalone} \usetikzlibrary{arrows.meta} \begin{document} \begin{tikzpicture}[>={Triangle[length=3mm]}] \draw[->] (0,0)--(3,2); \end{tikzpicture} \end{document}
    – Black Mild
    Commented Feb 16, 2023 at 10:46

You must log in to answer this question.

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