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.

A very powerful feature of pstricks is its possibly nested rput command that can be used to rotate and move a portion of a drawing. Is there something similar in tikz?

share|improve this question
    
I don't know pstricks, but isn't \begin{scope}[rotate=90,xshift=1cm]...\end{scope} what you are looking for? –  Peter Grill Sep 21 '11 at 3:04
    
that sounds like it could be it! I'll try. –  pluton Sep 21 '11 at 3:16

2 Answers 2

up vote 14 down vote accepted

This can be done placing the contents within a scope:

\begin{scope}[rotate=90,xshift=1cm]
  ...
\end{scope}

Inside a tikzpicture environment the scope environment applies all options local to the environment contents. Furthermore, if you include \usetikzlibrary{scopes} in the preamble, you can start a scope at "certain places" with a { provided that the single brace is followed by the options within [].

From the documentation (Section 12.3 in the v2.10 TiKZ & PGF manual):

The “certain places” where an opening brace has this special meaning are the following: First, right after the semicolon that ends a path. Second, right after the end of a scope. Third, right at the beginning of a scope, which includes the beginning of a picture. Also note that some square bracket must follow, otherwise the brace is treated as a normal TeX scope.

share|improve this answer

Now you can use \rput with the package tikzrput (version beta but it seems stable). You need only to download tikzrput.sty from here. I need time to finish the doc but the options are the same of \rput of pstricks Logically you can replace tikzrput by pstricks and the code compiles.

Some examples :

  1. in the first only, objects are tikz pictures

    enter image description here

    \documentclass{scrartcl}
    \PassOptionsToPackage{dvipsnames,svgnames}{xcolor}  
    \usepackage{tikz} 
    \usepackage{tikzrput} % from http://altermundus.com/pages/tkz/tikzrput/   
    \begin{document}
    \def\myEye{
    \begin{tikzpicture}  
          \filldraw (-0.4,1.5)--(0.7,1.8)--(0.2,2.2)--(-0.5,1.6)--cycle;   
          \draw [clip] (0,0) circle [x radius=.8cm, y radius=1.5cm]; 
          \fill[MidnightBlue] (0,-1) circle [radius=1cm];
    \end{tikzpicture}        
    }
    
    Tu as de beaux yeux !
    \rput(8,-2){\myEye}
    \rput(6,-2){\reflectbox{\myEye}}
    
    \end{document} 
    
  2. it's a part of the doc of pstricks

    enter image description here

    \documentclass{article}
    \usepackage[utf8]{inputenc} 
    \usepackage[T1]{fontenc} 
    \PassOptionsToPackage{dvipsnames,svgnames}{xcolor}     
    \usepackage{amsmath,tikzrput,fancyvrb,booktabs,fullpage} 
    
    \begin{document}
    
    \section{Placing whatever, wherever } 
    
    \begin{tabular}{@{}p{\dimexpr \textwidth-6cm}@{} p{1.5cm}@{} p{4 cm}@{}}
    As we have already seen, the \Verb+{\rput}+ macro can be used to place objects.
    The second mandatory argument (in curly braces) is the stuff to place the first
    mandatory argument (in parenthesis) is the coordinate pair of the point where
    the stuff is placed.
    Now we turn to the optional arguments of the \Verb+{\rput}+ macro.
    The first one is given in brackets. It determines the justification of the
    bounding box of the object to place with respect to the point given in paren-
    thesis. The admissible values are the same as the values for the option origin
    of the \verb+{\includegraphics}+ macro. For an instance \Verb+{[br]}+ for bottom-right.
    The default is mc meaning middle - center.
    The second optional argument is given in curly braces just before the left
    parenthesis. It is a number that stands for the rotation angle as illustrated in
    the last instance of the \Verb+{\rput}+ macro on the slide.
    The two optional arguments make \Verb+{\rput}+ more 
    exible than the \Verb+{\put}+ macro
    of the picture environment. 
    & &
     \begin{tikzpicture}[baseline=(current bounding box.north)] 
          \draw[help lines] (-1,0) grid (1,5) ; 
     \foreach \x/\y in {0/5,-1/3,1/2,0.5/1} {%
          \rput(\x,\y ){\tikz\draw[fill=red] circle(2pt);};} 
    \rput(0,5){Center,Middle}
    \rput[bl](-1,3){$\underbrace{
    \text{bottom,left}
    }_{\text{Really!}}$}
    \rput[Br](1,2){$\underbrace{
    \text{Baseline,right}
    }_{\text{Really!}}$}
    \rput[tr]{45}(0.5,1)
    {\parbox{5cm}{\flushright Rotated\\
    by $45^{\circ}$}}
    \end{tikzpicture}  
    \end{tabular}
    \end{document} 
    
  3. Only TikZ to build \rput

    enter image description here

    \documentclass{scrartcl}
    \usepackage{tikzrput}
    \begin{document}
    
    \null\vspace*{4cm}%
    \hspace*{5cm}%
    \foreach \a in {0,16,...,356}{\rput(\a;2){$\bullet$}}\rput[B](0;0){Circle}%     
    
    \vspace*{4cm}% 
    \hspace{5cm}end\rput[B](180;5cm){start} 
    
    a line :\ \rput[B](5,0){end}\rput[Bl](0,0){start}
    \hrule
    \end{document} 
    
share|improve this answer
    
This sounds like a interesting and useful tool. One problem though, the link doesn't seem to work at the moment. –  Frédéric Mar 6 '12 at 2:33
    
@Frédéric: Link seems to work fine for me. –  qubyte Mar 6 '12 at 4:01
    
It works now, thanks for checking. –  Frédéric Mar 6 '12 at 5:26

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.