Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Edit 1

Claudio gave a nice solution to my question. But the image should be included in a beamer presentation. I use for that the option transform canvas={scale=0.5} and this has a side problem with the node position. Compare the image below with that provided in Claudio's answer.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{backgrounds,positioning}
\pgfdeclarelayer{foreground}
\pgfsetlayers{main,foreground}


\begin{document}
\thispagestyle{empty}
\tikzset{every picture/.style={transform canvas={scale=0.5}}}
\begin{tikzpicture}[
 cross appereance/.style={
   white,very thick,
 },
 cross/.style={append after command={
    \pgfextra{
    \begin{pgfinterruptpath}
    \begin{pgfonlayer}{foreground}
     \draw[cross appereance,shorten <=0.35\pgflinewidth,shorten >=0.35\pgflinewidth]
  (\tikzlastnode.south) -- 
  (\tikzlastnode.north);
     \draw[cross appereance,shorten <=0.4\pgflinewidth,shorten >=0.4\pgflinewidth]
  (\tikzlastnode.west) -- 
  (\tikzlastnode.east);
    \end{pgfonlayer}
    \end{pgfinterruptpath}
    }
  } 
 },
  quad/.style={cross,fill=purple, cross,rectangle, thick, label=below:{quad},minimum width=1cm},
]

   \node[quad]  (quad1) {};

 \begin{scope}[shift={(1cm,1cm)}, every node/.style={rotate=-60}]
   \node[quad, right= of quad1] (quad2) {};
 \end{scope}
\end{tikzpicture}
\end{document}

enter image description here

Original question

I made a rectangle with a white cross in the centre using the picture path and the shapes anchors (north, south,...). My problem is that when I rotate the node the cross is not rotated.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}
\begin{tikzpicture}[
 cross/.style={path picture={ 
  \draw[white,very thick]
  (path picture bounding box.south) -- (path picture bounding box.north) (path picture bounding box.west) -- (path picture bounding box.east);}},
  quad/.style={fill,cross, purple, rectangle, thick, label=below:{quad},minimum width=1cm},
]

   \node[quad]  (quad1) {};

 \begin{scope}[xshift=1cm, every node/.style={rotate=-60}]
   \node[quad, right= of quad1] (quad2) {};
 \end{scope}
\end{tikzpicture}
\end{document}

enter image description here

share|improve this question

1 Answer 1

up vote 6 down vote accepted

I guess the problem here relies on how the cross has been created: my feeling is that by exploiting the path picture bounding box as reference makes things rather complicated. I'm not sure whether is possible to rotate that (perhaps yes, but what's the effort?) and for sure there's a simpler way. Indeed, for debugging purposes it is possible to draw the path picture bounding box and notice that it isn't rotate at all with your code:

\documentclass[tikz,png,border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{backgrounds,positioning}
\pgfdeclarelayer{foreground}
\pgfsetlayers{main,foreground}

\begin{document}
\begin{tikzpicture}[
 cross/.style={path picture={ 
  \begin{pgfonlayer}{foreground}
  \draw[white,very thick]
  (path picture bounding box.south) -- (path picture bounding box.north) (path picture bounding box.west) -- (path picture bounding box.east);
  \draw[blue]  
  (path picture bounding box.south west) -- 
  (path picture bounding box.north west) -- 
  (path picture bounding box.north east) -- 
  (path picture bounding box.south east) -- cycle;
  \end{pgfonlayer}
  }},
  quad/.style={fill,cross, purple, rectangle, thick, label=below:{quad},minimum width=1cm},
]

   \node[quad]  (quad1) {};

 \begin{scope}[xshift=1cm, every node/.style={rotate=-60}]
   \node[quad, right= of quad1] (quad2) {};
 \end{scope}
\end{tikzpicture}
\end{document}

enter image description here

Similarly to what did in How to modify nodes in TikZ to automatically add a line on their top? one can proceed as follows:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{backgrounds,positioning}
\pgfdeclarelayer{foreground}
\pgfsetlayers{main,foreground}


\begin{document}
\begin{tikzpicture}[
 cross appereance/.style={
   white,very thick,
 },
 cross/.style={append after command={
    \pgfextra{
    \begin{pgfinterruptpath}
    \begin{pgfonlayer}{foreground}
     \draw[cross appereance,shorten <=0.35\pgflinewidth,shorten >=0.35\pgflinewidth]
  (\tikzlastnode.south) -- 
  (\tikzlastnode.north);
     \draw[cross appereance,shorten <=0.4\pgflinewidth,shorten >=0.4\pgflinewidth]
  (\tikzlastnode.west) -- 
  (\tikzlastnode.east);
    \end{pgfonlayer}
    \end{pgfinterruptpath}
    }
  } 
 },
  quad/.style={cross,fill=purple, cross,rectangle, thick, label=below:{quad},minimum width=1cm},
]

   \node[quad]  (quad1) {};

 \begin{scope}[xshift=1cm, every node/.style={rotate=-60}]
   \node[quad, right= of quad1] (quad2) {};
 \end{scope}
\end{tikzpicture}
\end{document}

The result:

enter image description here

After the comments

If you apply a transformation, then perhaps you want to change a bit the quad style otherwise besides having the label too distant there are also bad effects.

That's what happens to me:

\documentclass{beamer}
\usepackage{lmodern}
\usepackage{tikz}
\usetikzlibrary{backgrounds,calc,positioning}
\pgfdeclarelayer{foreground}
\pgfsetlayers{main,foreground}

\tikzset{every picture/.style={transform canvas={scale=0.5}}}

\tikzset{white circle/.style={circle,minimum size=4cm, draw}}
\tikzset{green circle/.style={circle,minimum size=0.1cm, draw,bottom color=green!80}}
\tikzset{red circle/.style={circle,minimum size=0.1cm, draw,bottom color=red!80}}
\tikzset{blue circle/.style={circle,minimum size=0.1cm, draw,bottom color=blue!80}}

\begin{document}

\begin{frame}{A picture alone}
\centering
\begin{tikzpicture}
\pgfmathsetseed{123456}
\node (inc) at (0,5) [white circle,label=INCLUSIONE] {};

\foreach \circle in {1,...,10}{
  \pgfmathrandom{0,360}
  \pgfmathtruncatemacro\angle\pgfmathresult
  \pgfmathrnd
  \pgfmathsetmacro\distance\pgfmathresult
  \node[green circle] at ($(inc.center)!\distance!(inc.\angle)$){};
}

\foreach \circle in {1,...,10}{
  \pgfmathrandom{0,360}
  \pgfmathtruncatemacro\angle\pgfmathresult
  \pgfmathrnd
  \pgfmathsetmacro\distance\pgfmathresult
  \node[red circle] at ($(inc.center)!\distance!(inc.\angle)$){};
}

\foreach \circle in {1,...,10}{
  \pgfmathrandom{0,360}
  \pgfmathtruncatemacro\angle\pgfmathresult
  \pgfmathrnd
  \pgfmathsetmacro\distance\pgfmathresult
  \node[blue circle] at ($(inc.center)!\distance!(inc.\angle)$){};
}
\end{tikzpicture}

\end{frame}

\begin{frame}{Title}


Without change the style:

\begin{center}
\begin{tikzpicture}[
 cross appereance/.style={
   white,very thick,
 },
 cross/.style={append after command={
    \pgfextra{
    \begin{pgfinterruptpath}
    \begin{pgfonlayer}{foreground}
     \draw[cross appereance,shorten <=0.35\pgflinewidth,shorten >=0.35\pgflinewidth]
  (\tikzlastnode.south) -- 
  (\tikzlastnode.north);
     \draw[cross appereance,shorten <=0.4\pgflinewidth,shorten >=0.4\pgflinewidth]
  (\tikzlastnode.west) -- 
  (\tikzlastnode.east);
    \end{pgfonlayer}
    \end{pgfinterruptpath}
    }
  } 
 },
  quad/.style={fill,cross, purple, rectangle, thick, label=below:{quad},minimum width=1cm},
]

   \node[quad]  (quad1) {};

 \begin{scope}[every node/.style={rotate=-60}]
   \node[quad, right= of quad1] (quad2) {};
 \end{scope}
\end{tikzpicture}
\end{center}

By changing the style:

\begin{center}
\begin{tikzpicture}[
 cross appereance/.style={
   white,very thick,
 },
 cross/.style={append after command={
    \pgfextra{
    \begin{pgfinterruptpath}
    \begin{pgfonlayer}{foreground}
     \draw[cross appereance,shorten <=0.35\pgflinewidth,shorten >=0.35\pgflinewidth]
  (\tikzlastnode.south) -- 
  (\tikzlastnode.north);
     \draw[cross appereance,shorten <=0.4\pgflinewidth,shorten >=0.4\pgflinewidth]
  (\tikzlastnode.west) -- 
  (\tikzlastnode.east);
    \end{pgfonlayer}
    \end{pgfinterruptpath}
    }
  } 
 },
  quad/.style={cross,fill=purple, cross,rectangle, thick,minimum width=1cm},
]

   \node[quad,label=below:quad]  (quad1) {};

 \begin{scope}[every node/.style={rotate=-60}]
   \node[quad, right= of quad1,label=quad,xshift=-1] (quad2) {};
 \end{scope}
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}

The results:

enter image description here

enter image description here

share|improve this answer
    
It is workng fine like a standalone, but I would like to include the picture in a beamer slide. For that I scale all the tikzpicture with transform canvas={scale=0.5}. In this case the quads are not showing. –  zunbeltz Jun 14 '13 at 10:06
    
Did you used my working code? With my approach I don't perceive problems in Beamer with \tikzset{every picture/.style={transform canvas={scale=0.5}}} added to the preamble. Perhaps it is worth to modify your question in order to resemble your real needs. –  Claudio Fiandrino Jun 14 '13 at 10:13
    
Your example is working fine. The problem is that the shape appear very far from the label (which is ok). It also hapens in your code if you change xshift to shift={(1cm,1cm)}. –  zunbeltz Jun 14 '13 at 10:33
    
Sorry, but I'm confused: The problem is that the shape appear very far from the label (which is ok). Hence, it is a problem or it is ok? It appears far since you applied the canvas transformation, but, again, if you can provide a MWE with that picture plus another I can give you some more information. –  Claudio Fiandrino Jun 14 '13 at 18:38
    
Sorry for not being clear enough. I made an edit to the question with the problem (MWE and image included). –  zunbeltz Jun 17 '13 at 7:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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