Different dimensions with shift and xshift

In TikZ always the default unit for length values is pt. And we have

/tikz/xshift=<dimension>

So the default unit for xshift is pt.

In (1,0) you can think of cm as default unit but there is no default unit. Simply (1,0) is 1.x+0.y so it depends on the value of the x vector, which is initially set to (1cm,0).


Some thoughts:

  • You're not doing anything incorrect.
  • Is it a bug? It is not a bug in the sense that the program crashes or that the result deviates from what one may expect from the manual. So my take it is not a bug.
  • The default unit for coordinates is cm, so at (1,0) and at (1cm,0) are equivalent. That's why the shift={(5,0)} and shift={(5cm,0)} can be used interchangedly.
  • Is this not the only situation where cm is the unit. Another situation in which the default unit is cm is a cricle, so \draw (0,0) circle(1); gives you a circle of radius 1cm, similarly for arcs.
  • But for "most" other situations the default unit is pt.

An example that ilustrate @Kpym's nice answer.

\documentclass{article}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}
\draw[help lines] (0,0) grid (5,3) ;
  \node (a) at (0,3) {a};
  \node (b) at (0,2) {b};
  \node (c) at (0,1) {c};
  \node (d) at (0,0) {d};
  \begin{scope}[x={(2,1)}] % change the vector x 
  \node[xshift=2cm] at (a) {aa}; % 2cm to the right
  \node[shift={(2cm,0)}] at (b) {bb}; % 2cm to the right and 0pt to the top
  \node[xshift=2] at (c) {cc}; % 2pt to the right
  \node[shift={(2,0)}] at (d) {dd}; % 2x+0y
  \draw[blue] circle[radius=0.5]; % 0.5 is interpreted as xradius =0.5x and yradius =0.5 y
  \draw[red] circle[radius=0.5cm]; % .0.5cm is interpreted as xradius=yradius=0.5cm

  \end{scope}
\end{tikzpicture}

\end{document}

enter image description here

Tags:

Tikz Pgf