3

since I'm missing the ability to pass some kind of "format"-string to the gmatrix environment of the gauss package, and I learnt that this is not possible with redefining some environemnts used by the gauss package (see gauss package set formatting (like the option for the array env)), I finally came to the point, when I decided to emulate some parts of the behaviour of the gauss package to be more flexible.

I just wanted to ask you if there is some way to attach tikz arrows onto elements of the array environment (and thus the pmatrix environment of the amsmath package) or if the only way to do something like this is by setting the whole array/matrix within tikz?

(If maybe someone has already done this (then I'd be glad if this one would share ;) ))

Bernard
  • 271,350
atticus
  • 557

1 Answers1

8

The package nicematrix provides environments {NiceArray}, {NiceMatrix}, {pNiceMatrix}, etc. similar to the environments of array and amsmath but with the creation of a PGF/Tikz nodes under the cells of the array.

It's possible to use these nodes with Tikz after the construction of the array.

\documentclass{article}    
\usepackage{nicematrix,tikz}    
\begin{document}
$\begin{bNiceMatrix}
1 & 2 & 3 \\
4 & 5 & 6 \\
7 & 8 & 9 
\CodeAfter
\tikz \draw (1-3.east)  -- ++ (3mm,0) node [anchor = west]{\tiny $-3$} |- (2-3.east) ; 
\end{bNiceMatrix}$    
\end{document}

Result of the above code

F. Pantigny
  • 40,250
  • 2
    Excuse me very much for this disturb. Into your code there is \tiny $-4$ in the picture I see -3 :-). My regards. – Sebastiano Jun 04 '20 at 11:41
  • 2
    @Sabastiano: You are right. I have modified my answer. – F. Pantigny Jun 04 '20 at 13:44
  • Oh, thanks for the suggestion, actually this looks pretty nice! – atticus Jun 04 '20 at 17:27
  • @F.Pantigny I like very much your package and I think that many users have appreciated it. – Sebastiano Jun 04 '20 at 21:56
  • Oh, didn't knew you are the author ^^, (until now) I think it is a very nice package (especially for users like me, who like to insert tikz drawings into arrays/matrices). Thanks for writing ;) – atticus Jun 04 '20 at 22:07
  • Sadly this is not working when I try this, see https://tex.stackexchange.com/questions/547932/nicematrix-codeafter-tikz-not-working – atticus Jun 05 '20 at 11:42