I am trying to create a beamer animation using tikz, but I can't even get basic rotating of a tikz image working as desired.

I have a rectangle specified by

\draw[rounded corners,dotted] (-3.5,0) rectangle (-0.5,2);

I would like to rotate this rectangle about the point (-1,.5) (which is near the bottom right corner of the rectangle). I've tried:

            \draw[rounded corners,dotted] (-3.5,0) rectangle (-0.5,2);}}

But this produces an error. If I just use the origin=c option, it compiles, but it rotates the rectangle about the point (0,0). I've also tried it with just the x=-1,y=.5 (without the origin option), and it fails to compile.

I have searched the documentation, which is where I learned about the options x=xdim and y=ydim. However, I can't find a single example demonstrating how these options should be used.

Any suggestions would be greatly appreciated.

Also, if there is a better command for rotating things that will be more suitable for use in a beamer animation, please let me know. Thanks!


TikZ has a rotate around={<angle>:<coordinate>} option:

\fill (-1,0.5) circle [radius=2pt];
\draw[rounded corners] (-3.5,0) rectangle (-0.5,2);
\draw[rounded corners,red,rotate around={30:(-1,0.5)}] (-3.5,0) rectangle (-0.5,2);
  • Yes it is definitely the right way, even without rotate around it is possible but more complicated to obtain the same result but I think it should be avoided in most cases, rotatebox, resizebox etc. – Alain Matthes Feb 29 '12 at 6:44
  • +1 As usual, a brilliant answer. I notice that you usually use the standalone documentclass for demonstrating pictures- is this a convention that you adopt when producing documents too? – cmhughes Feb 29 '12 at 17:37

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.