0

This question is a follow up to Denis Bitouzé's question

Here is his code:

\documentclass{article}
\usepackage{tikz}

\usetikzlibrary {matrix}

\begin{document} \begin{tikzpicture} \matrix (magic) [matrix of nodes] { 1-1 & 1-2 & 1-3 \ & & \ 3-1 & 3-2 & 3-3 \ }; \draw[red,->] (magic-1-1) |- (magic-2-2.center) -| (magic-3-3); \end{tikzpicture} \end{document}

I am particularly interesting in the following line of code:

\draw[red,->] (magic-1-1) |- (magic-2-2.center) -| (magic-3-3);

The second row in the matrix (mat) was created in order to draw a continuous double rotating line between the node (magic-1-1) and the node (magic-3-3). I do not want to do this since it seems like an unnecessary line of code. I also do not want to use the package that is called ext.paths.ortho. This is due to the following fact: I do not like to use too much packages in latex, since the syntax could confuse me.

I have the following clue on how to create the diagram using only original latex code:

  1. Use the calc package to calculate the right coordinates.

My question is:

What is the best way to create a double rotating continuous line between two nodes in a tikz matrix?

1 Answers1

1
\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{matrix, calc}
\begin{document}
\begin{tikzpicture}
\matrix (magic) [matrix of nodes, nodes in empty cells=true]
{
1-1 & 1-2 & 1-3 \\
&  &  \\
3-1 & 3-2 & 3-3 \\
};
\draw[red,->] (magic-1-1) |- ($(magic-1-1)!0.5!(magic-3-3)$) -| (magic-3-3);
\end{tikzpicture}
\end{document}

matrix with a red arrow

Edit:

\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{matrix, calc}
\begin{document}
\begin{tikzpicture}
\matrix (magic) [matrix of nodes]
{
1-1 & 1-2 & 1-3 \\
2-1 & 2-2 & 2-3 \\
};
\draw[red,->] ([yshift=-4]magic-1-1.center) |- ($(magic-1-1)!0.5!(magic-2-3)$) -| ([yshift=3]magic-2-3.center);
\end{tikzpicture}
\end{document}

Two line compressed matrix with red arrow