TikZノード距離

TikZノード距離

パスとノードの適切な間隔について質問があります。

次の画像が欲しいです:

ティクジ画像

そして私は現在このコードを使用しています:

\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}

理解できないのは、なぜこのstyle={shorten <=-1.1mm}指示が非表示ノードに必要なのかということです。他の矢印はすべてノード上で完全に整列して始まりますが、この矢印はノード上で少し離れたところから始まります。

免責事項:これはTiを使用する初めての試みですZ および上記のコードは c&p 作業です。

答え1

「隠しノード」でも\node[above =1cm of AES, text width=0mm, inner sep=0mm, outer sep=0mm] (splitof) {};いくらかのスペースが必要になると思われるため、座標を使用する必要があります。

短縮せずに動作するコードは次のとおりです。

% 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}

関連情報