TikZ 中的箭头不完整且缺少箭头头

TikZ 中的箭头不完整且缺少箭头头

我有以下看起来不错的情节,但有两个问题:

  1. 并非所有的箭都有箭头。我不知道这是为什么。
  2. 有些边不够长。例如,根的左边缘未接触根的底部。

我该如何修复此问题?

\tikzstyle{every node}=[align=center, fill=white, rectangle, draw, rounded corners]
    \tikzset{external/remake next}
    \begin{tikzpicture}[->, thick,scale=0.8, level distance=3em, growth parent anchor=south]
    \node {Cryptographic\\primitives}
    [sibling distance=25em]
    child {
        [sibling distance=10em]
        node {Public-key\\primitives}
        child{ 
            [sibling distance=.5em]
            node {Public-key\\ciphers}
        }
        child{ 
            [sibling distance=.5em]
            node {Signatures}
        }
    }   
    child {
        [sibling distance=10em]
        node {Symmetric-key\\primitives}
        child{ 
            [sibling distance=10em]
            node {Symmetric-key\\ciphers}
            child {
                node {Block\\ciphers}
                child {
                    node {Lightweight\\block ciphers}
                }   
            }
            child {
                node {Stream\\ciphers}
            }
        }
        child{ 
            [sibling distance=2em]
            node {Hash\\functions}
        }
        child{ 
            [sibling distance=2em]
            node {Pseudo-random\\sequences}
        }
    }
    ;
    \end{tikzpicture}

答案1

问题是由于您[sibling distance=..]在每个步骤中手动指定覆盖箭头。最好通过 声明一次距离level 1/.style={...}

这是我的 MWE:

\documentclass{scrartcl}

\usepackage{tikz}
\usetikzlibrary{trees,arrows}

\begin{document}
\tikzset{every node/.style={align=center, fill=white, rectangle, draw, rounded corners}}
\tikzset{level 1/.style={sibling distance =25em}}
\tikzset{level 2/.style={sibling distance =10em}}
\tikzset{level 3/.style={sibling distance =7em}}
\tikzset{level 4/.style={sibling distance =5em}}

    \begin{tikzpicture}[-stealth,thick,scale=0.8, level distance=3em, growth parent anchor=south]
    \node {Cryptographic\\primitives}
    child {
        node {Public-key\\primitives}
        child{ 
            node {Public-key\\ciphers}
        }
        child{ 
            node {Signatures}
        }
    }   
    child {
        node {Symmetric-key\\primitives}
        child{ 
            node {Symmetric-key\\ciphers}
            child {
                node {Block\\ciphers}
                child {
                    node {Lightweight\\block ciphers}
                }   
            }
            child {
                node {Stream\\ciphers}
            }
        }
        child{ 
            node {Hash\\functions}
        }
        child{ 
            node {Pseudo-random\\sequences}
        }
    };
    \end{tikzpicture}

\end{document}

图形结果:

在此处输入图片描述

为了让所有箭头正确符合框,可以删除选项growth parent anchor=south并增加level distance。例如:

\begin{tikzpicture}[-stealth,thick,scale=0.8, level distance=6em]

这将给出:

在此处输入图片描述

相关内容