TikZ/pgf:使用“圆角”时路径装饰看起来很破损

TikZ/pgf:使用“圆角”时路径装饰看起来很破损

以下是一个例子snake

\documentclass{standalone}

%======================================
\usepackage{tikz}
\usetikzlibrary{graphdrawing}
\usetikzlibrary{arrows}
\usetikzlibrary{graphs}
\usetikzlibrary{decorations.pathmorphing}
\usegdlibrary{force, layered, trees}
%======================================

\begin{document}

\tikz [rounded corners]
    \graph [spring layout, node distance=25mm]
    {
        a ->[decorate, decoration=snake]
        b -> 
        c ->
        a ->
        e -> 
        b
    };

\end{document}

蛇

以下是一个例子zigzag

\documentclass{standalone}

%======================================
\usepackage{tikz}
\usetikzlibrary{graphdrawing}
\usetikzlibrary{arrows}
\usetikzlibrary{graphs}
\usetikzlibrary{decorations.pathmorphing}
\usegdlibrary{force, layered, trees}
%======================================

\begin{document}

\tikz [rounded corners]
    \graph [spring layout, node distance=25mm]
    {
        a ->[decorate, decoration=zigzag]
        b -> 
        c ->
        a ->
        e -> 
        b
    };

\end{document}

在此处输入图片描述

为什么装饰路径无法正确渲染?我保证我没有混淆snake和的图像zigzag。尝试自己渲染它们。

答案1

删除rounded corners即可解决问题:

\documentclass{standalone}

%======================================
\usepackage{tikz}
\usetikzlibrary{graphdrawing}
\usetikzlibrary{arrows}
\usetikzlibrary{graphs}
\usetikzlibrary{decorations.pathmorphing}
\usegdlibrary{force, layered, trees}
%======================================

\begin{document}

\tikz %[rounded corners] remove this
    \graph [spring layout, node distance=25mm]
    {
        a ->[decorate, decoration=snake]
        b ->
        c ->
        a ->
        e ->
        b
    };

\end{document}

蛇

\documentclass{standalone}

%======================================
\usepackage{tikz}
\usetikzlibrary{graphdrawing}
\usetikzlibrary{arrows}
\usetikzlibrary{graphs}
\usetikzlibrary{decorations.pathmorphing}
\usegdlibrary{force, layered, trees}
%======================================

\begin{document}

\tikz %[rounded corners] remove this
    \graph [spring layout, node distance=25mm]
    {
        a ->[decorate, decoration=zigzag]
        b ->
        c ->
        a ->
        e ->
        b
    };

\end{document}

之字形

这是一个基本的演示,它没有使用库只是为了展示这是使用依赖于短线段的装饰graphdrawing的效果(我认为):rounded corners

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}

\begin{document}

\begin{tikzpicture} 
    \draw (0,0) [decorate, decoration=snake] -> (1,0);
    \draw (0,-.25) [decorate, decoration=zigzag] -> (1,-.25);
    \draw (0,-.5) [decorate, decoration=snake, rounded corners] -> (1,-.5);
    \draw (0,-.75) [decorate, decoration=zigzag, rounded corners] -> (1,-.75);
\end{tikzpicture}

\end{document}

最小演示

相关内容