ポストアクションの装飾の 2 番目のマーク座標が認識されません

ポストアクションの装飾の 2 番目のマーク座標が認識されません

装飾では、2 番目のマークの座標が認識されません。

  \draw[thick,red,zigzag,postaction={
    decoration={
        markings,
        mark=at position 0.7 with \coordinate (x);
        mark=at position 0.5 with \coordinate (z); %unable to recognize z
    },
    decorate
  }] (-2,0) coordinate(a) -- (2,0) coordinate(b);

MWE は次のとおりです。

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}
\tikzset{zigzag/.style={decorate,decoration=zigzag}}
\begin{document}
\begin{tikzpicture}
  \coordinate (c) at (0,-2);
  \coordinate (d) at (4,-2);
  \coordinate (e) at (2,-4);
  \draw[thick,red,zigzag,postaction={
    decoration={
        markings,
        mark=at position 0.7 with \coordinate (x);
        mark=at position 0.5 with \coordinate (z); %unable to recognize z
    },
    decorate
  }] (-2,0) coordinate(a) -- (2,0) coordinate(b);

  \draw[thick,fill=blue!20] (c) -- (b) -- (d) -- (e) -- cycle;
  \draw[thick,postaction={
    decoration={
        markings,
        mark = at position 0.7 with \coordinate (y);
    },
    decorate
  }] (a) -- (c);
  \draw[thick,red,dashed] (x) -- (y);

  \node[above = 10ex of z,red] (sn) {singularity};
\end{tikzpicture}
\end{document} 

PDFLaTeX を使用してこのコードをコンパイルすると、次のようになります。

! Package pgf Error: No shape named z is known.

See the pgf package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.32   \node[above = 10ex of z,red]
                                    (sn) {singularity};
? 

どこが間違っているのか教えてください。

答え1

オプションはコンマで区切る必要があります。複雑な引数は中括弧で囲むのもよいでしょう。

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}
\tikzset{zigzag/.style={decorate,decoration=zigzag}}
\begin{document}
\begin{tikzpicture}
  \coordinate (c) at (0,-2);
  \coordinate (d) at (4,-2);
  \coordinate (e) at (2,-4);
  \draw[thick,red,zigzag,postaction={
    decoration={
        markings,
        mark=at position 0.7 with {\coordinate (x);},
        mark=at position 0.5 with {\coordinate (z);},
    },
    decorate
  }] (-2,0) coordinate(a) -- (2,0) coordinate(b);

  \draw[thick,fill=blue!20] (c) -- (b) -- (d) -- (e) -- cycle;
  \draw[thick,postaction={
    decoration={
        markings,
        mark = at position 0.7 with \coordinate (y);
    },
    decorate
  }] (a) -- (c);
  \draw[thick,red,dashed] (x) -- (y);

  \node[above = 10ex of z,red] (sn) {singularity};
\end{tikzpicture}
\end{document}

ここに画像の説明を入力してください

関連情報