TikZ-Knotenabstand

TikZ-Knotenabstand

Ich habe eine Frage zum richtigen Abstand zwischen Pfaden und Knoten.

Ich möchte folgendes Bild:

Abonnieren

Und ich verwende derzeit diesen Code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows, arrows.meta, positioning, calc}
\begin{document}
\begin{tikzpicture}[node distance=1cm, auto]  
\tikzset{
    block/.style= {draw, rectangle, align=center,minimum width=2cm,minimum height=1cm},
    >={Classical TikZ Rightarrow[length=1.7mm]},
    XOR/.style={draw,circle,append after command={
        [shorten >=\pgflinewidth, shorten <=\pgflinewidth,]
        (\tikzlastnode.north) edge (\tikzlastnode.south)
        (\tikzlastnode.east) edge (\tikzlastnode.west)}}
}
%}  
\node[] (k) {k};
\node[right=of k] (t) {t};
\node[block, below =2cm of t] (AES) {AES};
\node[above =1cm of AES] (splitof) {};
\node[XOR, below =1cm of AES] (xor) {};
\node[below =1.5cm of xor] (c) {c};

%% paths
\path[draw,->] (k) |- (AES);
\path[draw,->] (AES) edge (xor);
\path[draw,->] (t) edge (AES);
\path[draw,->,style={shorten <=-1.1mm}] (splitof) -- +(2, 0) |- (xor);
\path[draw,->] (xor) edge (c);

\end{tikzpicture} 
\end{document}

Was ich nicht verstehe, ist, warum ich diese style={shorten <=-1.1mm}Anweisung für den versteckten Knoten brauche. Alle anderen Pfeile beginnen perfekt ausgerichtet auf ihren Knoten, aber dieser hier beginnt ansonsten einfach ein paar Abstände entfernt.

Haftungsausschluss: Dies ist mein erster Versuch, Ti zu verwendenkZ und der obige Code sind C&P-Arbeit.

Antwort1

Sie sollten anstelle Ihres „versteckten Knotens“ eine Koordinate verwenden, da dieser sogar \node[above =1cm of AES, text width=0mm, inner sep=0mm, outer sep=0mm] (splitof) {};etwas Platz zu benötigen scheint.

Hier der Code, der ohne Verkürzung funktioniert:

% arara: pdflatex

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, positioning}

\begin{document}
\begin{tikzpicture}
    \tikzset{%
        ,block/.style={%
            ,draw
            ,rectangle
            ,align=center
            ,minimum width=2cm
            ,minimum height=1cm
            }
        ,>={Classical TikZ Rightarrow[length=1.7mm]}
        ,XOR/.style={%
            ,draw
            ,circle,append after command={%
                [shorten >=\pgflinewidth, shorten <=\pgflinewidth,]
                (\tikzlastnode.north) edge (\tikzlastnode.south)
                (\tikzlastnode.east) edge (\tikzlastnode.west)
                }
            }
        }
    \node (k) {k};
    \node[right=of k] (t) {t};
    \node[block, below =2cm of t] (AES) {AES};%
    \coordinate[above =1cm of AES] (splitof) {};
    \node[XOR, below =1cm of AES] (xor) {};
    \node[below =1.5cm of xor] (c) {c};

    \path[draw,->] (k) |- (AES);
    \path[draw,->] (AES) edge (xor);
    \path[draw,->] (t) edge (AES);
    \path[draw,->] (splitof) -- +(2, 0) |- (xor);
    \path[draw,->] (xor) edge (c);  
\end{tikzpicture} 
\end{document}

verwandte Informationen