1

I am trying to draw a yz-axis, and ontop of it, a rotated y'z'-axis for some work in mathematics. The following code

\newcommand{\axislength}{2}
\draw [->, -latex]
(0,0) coordinate (O) node[above left]  {} 
-- (0,\axislength) coordinate (Z) node[above]  {Z}; 
\draw [->, -latex]
(O) -- (\axislength,0) coordinate (Y) node[right] {Y};
\draw[->, -latex, dotted,rotate around={30:(0,0)}] (O) -- (Z) node[above left] 
{Z'};

produces

wrong result

whereas

\newcommand{\axislength}{2}
\draw [->, -latex]
 (0,0) coordinate (O) node[above left]  {} 
 -- (0,\axislength) coordinate (Z) node[above]  {Z}; 
 \draw [->, -latex]
(O) -- (\axislength,0) coordinate (Y) node[right] {Y};
  \draw[->, -latex, dotted,rotate around={30:(O)}] (0,0) -- (0,\axislength) 
  node[above left] {Z'};

produces

correct result

All I've done is changed the last line. Clearly when I reference (O), LaTex does not interpret it exactly as the coordinate. But, in most cases, I have been able to put the coordinate name where Latex expected to see an actual coordinate, and it worked. Is there an error in my work, or are some functions just capable of interpreting what I mean by a coordinate name while others are not?

  • 2
    Welcome to TeX-SE! Symbolic coordinates do not get transformed, which is wht you are seeing here. – user121799 Jun 24 at 15:13
  • @marmot Thanks for your help! – Kraig Jun 24 at 15:14
2

In TikZ, standard transformations do not transform symbolic coordinates. (However, you can transform shapes by using the key transform shape, and you can transform low level shapes by saying \pgflowlevelsynccm.) It is possible to transform symbolic coordinates with transform canvas. Notice, however, that this key is to be used with great care. It does not transform the bounding box. However, it is also very powerful because it allows you to, say, rotate ball shadings, which do not get transformed under ordinary transformations. Nevertheless, use transform canvas only if you absolutely need to.

\documentclass[tikz,border=3.14mm]{standalone}
\begin{document}
\begin{tikzpicture}[font=\sffamily,pics/brimborium/.style={code={\draw [->, -latex] (0,0) coordinate (O) node[above left]  {} 
-- (0,\axislength) coordinate (Z) node[above]  {Z}; 
\draw [->, -latex] (O) -- (\axislength,0) coordinate (Y) node[right] {Y};}}]
\newcommand{\axislength}{2}
\begin{scope}[local bounding box=explicit,xshift=-8cm]
 \pic {brimborium};
 \draw[->, -latex, dotted,rotate around={30:(0,0)}] (0,0) -- (0,\axislength)   node[above left] {Z'};
\end{scope}
\path (explicit.north) node[above]{explicit coordinates};
\begin{scope}[local bounding box=symbolic,xshift=-4cm]
 \pic {brimborium};
 \draw[->, -latex, dotted,rotate around={30:(0,0)}] (O) -- (Z) node[above left] {Z'};
\end{scope}
\path (symbolic.north) node[above]{symbolic coordinates};
\begin{scope}[local bounding box=canvas,xshift=0cm]
 \pic {brimborium};
 \draw[->, -latex, dotted,transform canvas={rotate around={30:(0,0)}}] (O) -- (Z) node[above left] {Z'};
\end{scope}
\path (canvas.north) node[above]{canvas transformation};
\end{tikzpicture}
\end{document}

enter image description here

If you use node[above left,transform shape] {Z'} in the first scope, you get the same output as in the last one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.