0

I would like to make this figure in LaTeX using tikz (the figure is from a book):

enter image description here

I really have no idea where to start and how to do it. Thank you for your help.

MS-SPO
  • 11,519
  • 1
    Looks like a tikz matrix with half of the entries empty. Add the arrows later. It is still a lot of work. – John Kormylo Jan 02 '24 at 16:35
  • 1
    I guess you can use tikz-cd, and put a A every two column/row. The documentation in CTAN is fairly complete, it explains how to add arrows etc. Should be fairly straightforward – tobiasBora Jan 02 '24 at 16:36
  • Something like https://tex.stackexchange.com/questions/387703/draw-arrows-between-elements-inside-math-matrix could be starting point – samcarter_is_at_topanswers.xyz Jan 02 '24 at 16:44
  • Have a look at the tutorials and the chapter about \foreach in https://tikz.dev/pgffor – MS-SPO Jan 02 '24 at 16:44
  • Have a look at tkz-graph, which unfortunately is documented in French. https://ctan.org/pkg/tkz-graph – MS-SPO Jan 02 '24 at 16:45

1 Answers1

6

As always with TikZ, there are many, many ways to construct such a diagram. Here are two just with basic TikZ functionalities.

Both use two PGFFor loops but the first one uses a rotates coordinate system where down-right is the nth row and down-left is the kth column (see at (\k, -\n) specification). Though, this means the first value of the index needs to be evaluated as k + n + 1 which can be done with \inteval or the count key from PGFFor (see count = \knp from \np which means \knp counts up from n + 1 for each k).

The second diagram constructs the diagram with an untransformed coordinate system where the rows are horizontally but the k columns remain in down-left direction which required a calculation for the x value of the node placement: 2kn.

The condition for when to draw an arrow from the previous row/column is now a bit more complicated as well as before.

The conditions are evaluated with the primitive TeX control sequence \ifnum…\fi which I don't like but they are the most straightforward tool in this case, especially in combination with \inteval since it allows integer calculation on-the-fly.

Code

\documentclass[tikz]{standalone}
\usetikzlibrary{arrows.meta, quotes}
\begin{document}
\tikzset{% settings common to both solutions
  anchor=base,        % nodes are aligned at their base
  auto=right,         % nodes along lines are placed to the right
                      % (all arrows are drawn reversed)
  >={Stealth[round]}, % shorthand arrow tip
  outer sep=+.1em,    % lines connecting nodes are further away
  every edge quotes/.append style={% quotes nodes are closer to the line
    inner sep=+.15em, outer sep=auto}}

\tikz[x=(-45:1.5cm), y=(45:1.5cm)] % rotate and scale the coordinate system \foreach[count/.list={\np from 1, \nm from -1}] \n in {0, ..., 5} \foreach[count/.list={\kp from 1, \km from -1, \knp from \np}] \k in {0, ..., \inteval{5-\n}} \node (\k-\n) at (\k, -\n) {$A_{\knp, \k}$} % \knp = \inteval{\k+\n+1} \ifnum\n=0 node[gray] at (\k, 1) {$k=\k$} \fi \ifnum\k=0 node[gray] at (-1, -\n-1) {$n=\np$} \fi \ifnum\inteval{\k*\n}>0 edge[<-, "$\cdot\kp$"] (\k -\nm) edge[<-, "$\cdot\np$"] (\km-\n ) \fi;

\tikz[scale=1.5/sqrt 2] % same scale as in the previous diagram \foreach[count/.list={\np from 2, \nm from 0}] \n in {1, ..., 6} \foreach[count/.list={\kp from 1, \km from -1}] \k in {0, ..., \inteval{\n-1}} \node (\k-\n) at (2\k-\n,-\n) {$A_{\n, \k}$} \ifnum\k=0 node[gray] at (-\n-2, -\n) {$n=\n$} \fi \ifnum\n=\inteval{\k+1} node[gray] at (2\k-\n+1, -\n+1) {$k=\k$} \fi \ifnum\n>2 \ifnum\k>0 \ifnum\k<\inteval{\n-1} edge[<-, "$\cdot\kp$"] (\k -\nm) edge[<-, "$\cdot\inteval{\n-\k}$"] (\km-\nm) \fi\fi\fi; \end{document}

Output

enter image description here

Qrrbrbirlbel
  • 119,821