Koordinateneinheit in pt, obwohl in TikZ standardmäßig cm verwendet wird

Koordinateneinheit in pt, obwohl in TikZ standardmäßig cm verwendet wird

Wie wir wissen, wird in TikZ die Einheit cmstandardmäßig übernommen, wenn sie in der Koordinate nicht erwähnt wird.

Beim Extrahieren der Koordinaten habe ich die Einheit als erwartet cm. Aber TikZ zeigt die Einheit in der Koordinate als an pt.

Wie bestimmt TikZ die Maßeinheit in einer Koordinate, wenn keine Einheit angegeben ist?

MWE:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}
\tikzset{zigzag/.style={decorate,decoration=zigzag}}
\begin{document}

\newdimen\XCoord
\newdimen\YCoord
\newcommand*{\ExtractCoordinate}[1]{\path (#1); \pgfgetlastxy{\XCoord}{\YCoord};}

\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 (singularity); },
    },
    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 singularity,red] (sn) {singularity};
  \draw[red,->] (sn) -- ($(singularity)+(0,1)$);
  \ExtractCoordinate{x};
  \node[above] at (\XCoord,\YCoord) {(\XCoord,\YCoord)};
\end{tikzpicture}

\end{document} 

Bildbeschreibung hier eingeben

Antwort1

Sie können immer alles von pt in cm oder zurück umrechnen, indem Sie es mit dem Verhältnis 1pt/1cmoder seinem Kehrwert multiplizieren. (Wenn das nicht das ist, wonach Sie suchen, entferne ich den Beitrag gerne.)

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}
\tikzset{zigzag/.style={decorate,decoration=zigzag}}
\begin{document}

\newdimen\XCoord
\newdimen\YCoord
\newcommand*{\ExtractCoordinate}[1]{\path (#1); \pgfgetlastxy{\XCoord}{\YCoord};}

\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 (singularity); },
    },
    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 singularity,red] (sn) {singularity};
  \draw[red,->] (sn) -- ($(singularity)+(0,1)$);
  \ExtractCoordinate{x};
  \node[above] at (\XCoord,\YCoord) {%
  (\pgfmathparse{\XCoord*1pt/1cm}\pgfmathprintnumber{\pgfmathresult}\,cm,%
  \pgfmathparse{\YCoord*1pt/1cm}\pgfmathprintnumber[fixed,precision=2]{\pgfmathresult}\,cm)};
\end{tikzpicture}
\end{document} 

Bildbeschreibung hier eingeben

verwandte Informationen