2

I have the following MWE:

\documentclass[class=article,border=0pt,svgnames]{standalone}

\usepackage{tikz}
\usetikzlibrary{arrows,arrows.meta,matrix,backgrounds}

\begin{document}

\tikzset{%
transition/.style={
    -{Triangle Cap[cap angle=100]},
    line width=1pt,
    black,
    line join=round,
    line cap=round,
    opacity=1,
    double=Crimson!25,
    double distance=10mm},
tableau proportionnalite/.style={
    draw,
    matrix of math nodes,
    row sep=2cm,
    column sep=2cm,
    nodes={
        font=\Huge,
        minimum width=2cm,
        minimum height=2cm,
    }
    }
}

\begin{tikzpicture}
\matrix (tableau) [tableau proportionnalite]{
    3 & 4\\
    5 & A\\
};
\begin{scope}[on background layer]
\draw[transition] (tableau-2-2.center)
    -- (tableau-1-1.center)
    -- (tableau-1-2.center)
    -- (tableau-2-1.center);
\end{scope}
\end{tikzpicture}
\end{document}

that produces the following picture :

enter image description here

I would like the reader understands that to find the value of A, he has to use 3, 4 and 5 in that order. Hence the arrow along the line which do not fulfill its goal at all!

However I cannot figure out a simple solution that brings more clarity to the path order. I try to put some color gradient along the line (to kind of visually identify the start and end of the line) but I found out that it is not a simple thing to do with TikZ.

Than I thought about a solution which I cannot achieve : if this line has borders, it would make the line overlapping itself. Therefore, the line's start and end would be completly obvious. But as you can see, it doesn't work because the line does not overlap itself and the borders of the first part of the line does not seem at all to be underneath the last part of the line. In addition, the arrow's end of the line is not concerned by the border which is not acceptable.

Maybe some of you guys will have a nice idea, as always ?

Thanks in advance for your answers. Sylvain

EDIT

I've consider the proposition of using the knots library as suggested in the Schrödinger's Cat answer, which should lead to more reproductible way to do the job. It worked fine except for the crossing which is made with a circle instead of a quadrilateral... and look weird. I've try the clip width factor with no effect... And if I decrease the clip radius, the crossing is not visible anymore...

Any idea ?

\documentclass[class=article,border=0pt,svgnames]{standalone}

\usepackage{tikz}
\usetikzlibrary{arrows,arrows.meta,matrix,backgrounds,knots,positioning}

\begin{document}

\tikzset{%
transition/.style={
    -{Triangle Cap[cap angle=100]},
    line width=10mm,
    Crimson!50,
    line join=round,
    line cap=round,
    opacity=1,},
tableau proportionnalite/.style={
    draw,
    matrix of math nodes,
    row sep=2cm,
    column sep=2cm,
    nodes={
        font=\Huge,
        minimum width=2cm,
        minimum height=2cm,
    }
    },
couleur/.store in=\couleur,
couleur=NavyBlue}

\begin{tikzpicture}
\matrix[tableau proportionnalite] (tableau) {
    3 & 4\\
    5 & A\\
};

\begin{scope}[on background layer]
\begin{knot}[
    line width=10mm,
    clip radius=8mm,
    background color=white,
    consider self intersections,
    ignore endpoint intersections=false,
    only when rendering/.style={
        transition
    }
    ]

\strand (tableau-2-2.center)
-- (tableau-1-1.center)
-- (tableau-1-2.center)
-- (tableau-2-1.center);
\flipcrossings{1}
\end{knot}
\end{scope}
\end{tikzpicture}
\end{document}

enter image description here

Sylcha
  • 33
  • 3

2 Answers2

1

I think one can interrupt the transition and make it look clearer. For this, I've increased the length of the matrix and split the transition into two parts. I had to use \phantom for the additional nodes in matrix.

\documentclass[class=article,border=0pt,svgnames,preview]{standalone}

\usepackage{tikz}
\usetikzlibrary{arrows,arrows.meta,matrix,backgrounds}

\begin{document}

\tikzset{%
    transition/.style={
        -{Triangle Cap[cap angle=100]},
        line width=1pt,
        black,
        line join=round,
        line cap=round,
        opacity=1,
        double=Crimson!25,
        double distance=10mm},
    capless/.style={
        %-{Triangle Cap[cap angle=100]},
        line width=1pt,
        black,
        line join=round,
        line cap=round,
        opacity=1,
        double=Crimson!25,
        double distance=10mm},
    tableau proportionnalite/.style={
        draw,
        matrix of math nodes,
        row sep=2cm,
        column sep=2cm,
        nodes={
            font=\Huge,
            minimum width=2cm,
            minimum height=2cm,
        }
    }
    }

    \begin{tikzpicture}
        \matrix (tableau) [tableau proportionnalite]{
            3 &  &  &  &  &4\\
             &  &  &  &  &\\
             &  &  & \phantom{1pt} &  &\\
             &  & \phantom{1pt} &  &  &\\
             &  &  &  &  &\\
            5 &  &  &  &  &A\\
        };
        \begin{scope}[on background layer]
            \draw[capless] (tableau-6-6.center)
            -- (tableau-1-1.center)
            -- (tableau-1-6.center)
            -- (tableau-3-4.center);

            \draw[transition] (tableau-4-3.center)
            -- (tableau-6-1.center);
        \end{scope}
    \end{tikzpicture}
\end{document}

enter image description here

oneofvalts
  • 67
  • 8
0

The problem is that double works in two steps: first draw a somewhat thicker line in one color and then a somewhat thinner line in another color. In order have the path crossing over itself you can add a short stretch in a second step.

\documentclass[class=article,border=0pt,svgnames]{standalone}

\usepackage{tikz}
\usetikzlibrary{arrows,arrows.meta,matrix,backgrounds}

\begin{document}

\tikzset{%
transition line/.style={line width=1pt,
    black,
    double=Crimson!25,
    double distance=10mm},
transition/.style={
    transition line,
    line join=round,
    line cap=round,
    opacity=1,
    -{Triangle Cap[cap angle=100]}},
tableau proportionnalite/.style={
    draw,
    matrix of math nodes,
    row sep=2cm,
    column sep=2cm,
    nodes={
        font=\Huge,
        minimum width=2cm,
        minimum height=2cm,
    }
    }
}

\begin{tikzpicture}
\matrix (tableau) [tableau proportionnalite]{
    3 & 4\\
    5 & A\\
};
\begin{scope}[on background layer]
\draw[transition,shorten >=3ex,] (tableau-2-2.center)
    -- (tableau-1-1.center)
    -- (tableau-1-2.center)
    -- (tableau-2-1.center);
\draw[transition line,shorten <=4em,shorten >=5em,
    postaction={draw,line width=10mm,color=Crimson!25,shorten <=3.9em,shorten
    >=4.9em}]   
    (tableau-1-2.center)
    -- (tableau-2-1.center);
\end{scope}
\end{tikzpicture}
\end{document}

enter image description here

Here is a version with a fake arrow head (a sloped pic).

\documentclass[class=article,border=0pt,svgnames]{standalone}

\usepackage{tikz}
\usetikzlibrary{matrix,backgrounds}

\begin{document}

\tikzset{%
transition line/.style={line width=1pt,
    black,
    double=Crimson!25,
    double distance=10mm},
transition/.style={
    transition line,
    line join=round,
    line cap=round,
    opacity=1},
    pics/tarot/.style={code={\pgfmathsetmacro{\pft}{#1}
    \draw[fill=Crimson!25,line width=1pt,shorten >=0pt,shorten <=0pt] 
    (5mm,\pft pt) -- (0pt,\pft pt) -- ({-cos(50)*\pft pt},0)
    -- (0pt,-\pft pt) -- (5mm,-\pft pt);  }},
tableau proportionnalite/.style={
    draw,
    matrix of math nodes,
    row sep=2cm,
    column sep=2cm,
    nodes={
        font=\Huge,
        minimum width=2cm,
        minimum height=2cm,
    }
    }
}

\begin{tikzpicture}
\matrix (tableau) [tableau proportionnalite]{
    3 & 4\\
    5 & A\\
};
\begin{scope}[on background layer]
\draw[transition,shorten >=7ex,] (tableau-2-2.center)
    -- (tableau-1-1.center)
    -- (tableau-1-2.center)
    -- (tableau-2-1.center);
\draw[transition line,shorten <=4em,shorten >=6em,
    postaction={draw,line width=10mm,color=Crimson!25,shorten <=3.9em,shorten
    >=4.9em}]   
    (tableau-1-2.center)
    -- (tableau-2-1.center) pic[pos=0.87,sloped]{tarot={5mm+0.5pt}};
\end{scope}
\end{tikzpicture}
\end{document}

enter image description here

Please note that the knots package overcomes such difficulties in a nice way, and you can have color change as demonstrated in this answer.

  • Thanks, it does the job, except for the arrow head... I'm just considering using knot library however because of reproductibility of the process : thus, I would not have to adjust the line if I change the points it's passing through. – Sylcha May 20 '20 at 07:28
  • 1
    @SylvainChambon To be honest, I missed the point of the arrow head, but I also do not know what "not concerned" in "In addition, the arrow's end of the line is not concerned by the border which is not acceptable." means. Can you please try to explain it? –  May 20 '20 at 07:35
  • I meant that the arrow head should be pink with a black border as the main line is... – Sylcha May 20 '20 at 07:44
  • 1
    @SylvainChambon I added a fake arrow head, a pic that is sloped and mimics an arrow. –  May 20 '20 at 08:09
  • That look's great ! Thanks ! I've edited my answer to use the knots library as you suggested. Crossing looks weird... – Sylcha May 20 '20 at 08:19
  • 1
    @SylvainChambon I need to decouple now. However, I think this knot problem would make a nice new question. –  May 20 '20 at 08:26