TikZ 노드 거리

TikZ 노드 거리

경로와 노드의 적절한 간격에 대해 질문이 있습니다.

나는 다음 사진을 원한다:

tikzimage

그리고 현재 다음 코드를 사용하고 있습니다.

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

관련 정보