蛇形装饰不适用于 tikz 中的 decorations.pathmorphing

蛇形装饰不适用于 tikz 中的 decorations.pathmorphing

我有一个简单的例子,效果很好

\documentclass[a4paper,12pt,oneside,titlepage]{report}
\usepackage{tikz}
\usetikzlibrary{snakes}

\begin{document}
    \begin{figure}[H]   
        \begin{tikzpicture}[line width = 1pt]               
            \draw[fill = black!100] {[snake] (0, 0)circle[radius=2pt] -- (2, 0)circle[radius=2pt]} -- (7, 0)circle[radius=2pt] -- (9, 0)circle[radius=2pt];             
        \end{tikzpicture}
        \caption{time-line.}
        \label{fig:cus}
    \end{figure}
\end{document}

我在输出中注意到:

Package tikz Warning: Snakes have been superseded by decorations. Please use th
e decoration libraries instead of the snakes library on input line 14.

如果我将代码更改为

\documentclass[a4paper,12pt,oneside,titlepage]{report}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}

\begin{document}
    \begin{figure}[H]   
        \begin{tikzpicture}[line width = 1pt]               
            \draw[fill = black!100] {[decorate,decoration=snake] (0, 0)circle[radius=2pt] -- (2, 0)circle[radius=2pt]} -- (7, 0)circle[radius=2pt] -- (9, 0)circle[radius=2pt];             
        \end{tikzpicture}
        \caption{time-line.}
        \label{fig:cus}
    \end{figure}
\end{document}

它没有像第一个示例中那样绘制“蛇”。如何正确使用装饰替换 tikz 包中的蛇库?

答案1

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

\begin{document}

\begin{figure}[H]   
\begin{tikzpicture}[line width = 1pt]               
\draw[fill = black!100] circle[radius=2pt] decorate [decoration={snake}]
 {(0, 0) -- (2, 0)} circle[radius=2pt] -- (7, 0) circle[radius=2pt] -- (9, 0) circle[radius=2pt];             
\end{tikzpicture}
\caption{time-line.}
\label{fig:cus}
\end{figure}

\end{document}

在此处输入图片描述

相关内容