# Different dimensions with shift and xshift

I discovered that there is a different default dimension in shift and xshift.

Consider the following mwe

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node (a) at (0,3) {a};
\node (b) at (0,2) {b};
\node (c) at (0,1) {c};
\node (d) at (0,0) {d};
\node[xshift=5cm] at (a) {aa};
\node[shift={(5cm,0)}] at (b) {bb};
\node[xshift=5] at (c) {cc};
\node[shift={(5,0)}] at (d) {dd};
\draw[help lines] (0,0) grid (5,3) ;
\end{tikzpicture}
\end{document}


It gives the following result:

For the two first lines given with 'cm' (a and b), the behavior of shift and xshift is the same.

But without dimensions (c and d) , it seems that shift uses default tikz dimensions, while xshift seems to use point?

I noticed that in the manual xshift is always given with cm, but this behavior is not explained.

Am I doing something incorrect? Is it a bug or a feature?

• You're not doing anything incorrect, and this has been noticed before. 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. As you have noticed, this is also true for coordinates, 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. But for "most" other situations the default unit is pt. – marmot Jan 13 at 1:05
• I can understand that commands doing completely different actions have different default dimensions. But shift and xshift seem very close, at least in terms of functionality. And this difference in behavior is really confusing... – Alain Merigot Jan 13 at 1:14
• I agree it is confusing. But in my list of confusing things this is below the confusion which library one has to load to make an example from the pgfmanual run through. (And I would like to draw your attention to this source of confusion, which confuses me, too. ;-) – marmot Jan 13 at 1:17

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).

• If "In TikZ always the default unit for length values is pt. " is really always true, why doesn't it apply to radii and the like? Or is in your opinion a radius not a length unit? – marmot Jan 13 at 4:45
• The manual is slightly more subtle. For the coordinates, it defines unit vectors (x-vector, y-vector and z-vector) which have by default a length of 1 cm. See page 366 of manual 3.1 – AndréC Jan 13 at 8:02
• @marmot circle(1) is the same as circle[radius=1] which is the same as circle[x radius=1,y radius=1] which is the ellipse that goes throw the points +x-vector and +y-vector. You can check this with circle[x={(1,1)},radius=1]. In the manual radius is not a dimension but a value because it can be dimension or factor. – Kpym Jan 13 at 10:04
• Well, I disagree. This is all under the question "Different dimensions with shift and xshift". My take is that the OP is wondering that, if they use dimensionless numbers, dimensions will be appended and they are different in different contexts. I agree with this observation and give another example in which cm get appended. If it was always a factor, why would \draw (0,0) circle (1cm); work. – marmot Jan 13 at 15:06

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.
• marmot, see Kpym's answer, pt is the default unit for length. – CarLaTeX Jan 13 at 4:38
• @CarLaTeX Well, depends on how you define default unit. From the OP's post I thought their definition is what is inserted when you do not specify the unit. If you adopt this definition, it is not the case for, say, circles and arcs. I would even make the stronger statement that, in view of the behavior of circles etc., the statement "In TikZ always the default unit for length values is pt." is not entirely correct. What is a radius if not a length (scale)? – marmot Jan 13 at 4:40
• I don't know, maybe it is considered a sort of polar coordinate. – CarLaTeX Jan 13 at 5:28
• @CarLaTeX Yes, sure. I really thin it boils down how you interpret "I discovered that there is a different default dimension in shift and xshift.". My interpretation is that the question concerns the observation that, if you do not specify the dimensions, TikZ will insert some for you, and the dimension TikZ inserts depends on the context. All I am saying is that this is true, and that the dimension automatically inserted in the case of a circle is also cm, whereas it is pt for most other situations. – marmot Jan 13 at 5:33
• The syntax \draw (0,0) circle (1) is an old syntax that still works but is deprecated. tex.stackexchange.com/q/303130/138900 – AndréC Jan 13 at 7:57

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