How could I produce such an image in code?
I'd also like to draw vector arrows by the end of the lines, in order to see the order of the calculations. I saw a TikZ solution on other answer that didn't work for me. Not only the code gave me an error, it's not fully what I want (I want it to look like a parentheses matrix, and I'd also like to have a convenient macro to produce it with just some few inputs). Here's this partial solution (given by Andrew here) I'm talking about:
Here is a quick hack using a matrix of math nodes and tikz:
Code
\documentclass[border=5mm,tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}[auto]
\matrix (M)[matrix of math nodes,row sep=1cm,column sep=16mm]{
a & b & c & a & b\\ d & e & f & d & e\\ g & h & i & g & h\\&&[blue]adi&[red]-bfg&[blue]cdh\\
};
\draw[blue](M-1-1)--(M-2-2)--(M-3-3)--(M-4-3);
\draw[blue](M-1-2)--(M-2-3)--(M-3-4)--(M-4-4);
\draw[blue](M-1-3)--(M-2-4)--(M-3-5)--(M-4-5);
\end{tikzpicture}
\end{document}
Also, that little product he put just below the lines showing the multiplication results are pretty awesome. Any way to implement it with what I've asked?


