# Rotating pictures and labels together with pics in TikZ

I have created a pic with TikZ 3.0 that includes an \includegraphics statement, and a label above a path with the arguments [sloped, above, midway].

The intention of the pic is to reuse it in other parts of my code. At times, I want to rotate the entire pic. However, the graphic and the label are unaffected.

Here is an MWE:

\documentclass{article}

\usepackage{tikz}

\begin{document}
\tikzset{
testpic/.pic={
\node at (3,0) {\includegraphics[width=1cm] {Rock.png}};
\draw (0,0) -- (1,1) node [midway, sloped, above] {test};
}
}

\begin{tikzpicture}
\pic[rotate=90] {testpic};
\end{tikzpicture}

\end{document}


Here is the output:

As you can see, the rock is not rotated by 90 degree. It is intended that it is also rotated, as if I specified \includegraphics[angle=90]. The label above the path is also not rotated.

How can this be fixed?

Asset:

-
Use \pic[rotate=90,transform shape] {testpic}; –  esdd Apr 25 '14 at 13:22
Well, that solved it. Why am I always missing the 'obvious' ;-)? Or, asked differently, why is that not the default option? –  Ingo Apr 25 '14 at 13:23
@Ingo Because normally you use nodes for labeling your graph and don't want to rotate these when turning the rest. –  Henri Menke Apr 25 '14 at 13:34

By default scaling or rotating do not apply to nodes. The reason is that normally the text should not be transformed even if the graphic is scaled or rotated.

If you wish to transform the nodes you have to add the option transform shape to the \pic command:

\documentclass[tikz,margin=5mm]{standalone}

\begin{document}
\tikzset{
testpic/.pic={
\node at (3,0) {\includegraphics[width=1cm] {Rock}};
\draw (0,0) -- (1,1) node [midway, sloped, above] {test};
}
}

\begin{tikzpicture}
\pic[rotate=90,transform shape] {testpic};
\end{tikzpicture}

\end{document}


-