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.

This is a beta version of \rput with TikZ. I don't know if the psticks version accepts polar coordinates but I added this option. My problem is to add the options ref = B, Bl , Br, t, tl , tr, b, bl , br. I don't know what is the good way to do this(pgfkeys ? IeX ?). I know how to apply these options but I don't how to get the values correctly.

\documentclass{scrartcl} 
\usepackage{ifpdf,tikz}     

\def\myobject{% this is to make some tests
\pgfpathmoveto{\pgfqpoint{0bp}{0bp}} 
\pgfpathcurveto{\pgfqpoint{50bp}{0bp}}
               {\pgfqpoint{150bp}{0bp}}
               {\pgfqpoint{200bp}{16bp}}
\pgfpathcurveto{\pgfqpoint{250bp}{0bp}}
               {\pgfqpoint{350bp}{0bp}}
               {\pgfqpoint{400bp}{0bp}}
\pgfpathlineto{\pgfqpoint{400bp}{1bp}}
\pgfpathcurveto{\pgfqpoint{350bp}{0bp}}
               {\pgfqpoint{250bp}{0bp}}
               {\pgfqpoint{200bp}{22bp}}  
\pgfpathcurveto{\pgfqpoint{150bp}{0bp}}
               {\pgfqpoint{50bp}{0bp}}
               {\pgfqpoint{0bp}{1bp}}
\pgfpathlineto{\pgfqpoint{0bp}{0bp}}   
\pgfusepath{fill,stroke}}% 

\makeatletter
\ifpdf 
\pgfutil@ifundefined{rput}
{\def\rput{\pgfutil@ifnextchar[{\rput@i}{\rput@ii}}% the code is based on pstricks version
\def\rput@i[#1]{\global\edef\opt@rput{#1}\rput@ii}%
\def\rput@ii{\pgfutil@ifnextchar({\def\angle@rput{0}\rput@iv}{\rput@iii}}%
\def\rput@iii#1{\def\angle@rput{#1}\pgfutil@ifnextchar({\rput@iv}{\rput@iv(0,0)}}%,
\def\rput@iv(#1){\edef\pos@rput{#1}\rput@v}%   
\def\rput@v#1{%
\begingroup% 
\makeatletter  
\begin{tikzpicture}[overlay]
\path (0,0)--(\pos@rput);
\protected@edef\rput@temp{%
\noexpand
\node[inner sep=0pt,anchor=base,\opt@rput,rotate=\angle@rput]}\rput@temp at (\pos@rput) {#1}; 
\end{tikzpicture}% 
\endgroup%
\ignorespaces}}{}% 
\fi 
\makeatother
\begin{document}

a\foreach \y in {0,6,...,72}{\pgfmathsetmacro{\ratio}{0.2+\y*0.01}%
\rput[](50pt,\y pt){\pgftransformscale{\ratio}\myobject}} 
\vspace{5cm}
a\foreach \a in {0,4,...,356}{\rput(\a:3){$\bullet$}} 
\hrule
bad\rput{40}(-90:4){\myobject}\rput(0:5){good}  
\hrule 
\end{document} 
share|improve this question
    
pstricks's \rput does accept polar coordinates after issuing \SpecialCoor. Polar coordinates are then used via a (<r>;<t>) notation (or semi-colon ;), as opposed to (<x>,<y>) (or comma ,). –  Werner Feb 22 '12 at 0:58
    
@Werner thank for these informations. I don't know what I want to do : exactly the same syntax or not ? ; instead : is possible but the code is more complicated. B Bl Br are more important. I wanted to know the better way to this. –  Alain Matthes Feb 22 '12 at 7:47
add comment

1 Answer

Finally I found a way for the ref options. I used something similar to what I saw in pstricks. I do not know if I did it right but for the moment I keep this method. I try with pgfkeys but I have some difficulties.

\protected@edef\rput@temp is useful but I don't know how to replace this macro, perhaps with a lot of \expandafter. My problem is to manage the keys but I would like my code works with plain tex.

If you find something simpler or better, I will be happy.

update 4

I added ; instead of : for polar coordinates and some values for ref like r and l. I corrected some bad blank spaces and \ignorespaces like in the pstricks version. Finally I created a little package : tikzrput.sty

tikzrput.sty

%% Options are the same of /rput in pstricks
\NeedsTeXFormat{LaTeX2e}% 
\RequirePackage{tikz,ifpdf}%
\ProvidesPackage{tikzrput}[2012/02/23 v0.1 rput for tikz]%
\edef\rputPtVirCode{\the\catcode`\;} 
\edef\rputAtCode{\the\catcode`\@}  
\catcode`\;=12\relax
\catcode`\:=12\relax
\catcode`\@=11\relax

\newif\ifrput@polar\rput@polarfalse
\def\rput@empty{}

\def\rput@parsecoordinate#1{%
\rput@getseparator#1,\@nil
\ifrput@polar 
   \rput@getfrompolar#1\@nil 
\fi
}%
\def\rput@getseparator#1,#2\@nil{%
\ifx\rput@empty#2\rput@empty%
   \rput@polartrue
\else
   \rput@polarfalse
\fi
}%
\def\rput@getfrompolar#1;#2\@nil{%
  \def\pos@rput{#1:#2}%
}%

\def\rput@pos@   {\def\rput@anchor{center}}
\def\rput@pos@B  {\def\rput@anchor{base}} 
\def\rput@pos@Br {\def\rput@anchor{base east}} 
\def\rput@pos@Bl {\def\rput@anchor{base west}} 
\def\rput@pos@tr {\def\rput@anchor{north east}} 
\def\rput@pos@tl {\def\rput@anchor{north west}}
\def\rput@pos@br {\def\rput@anchor{south east}} 
\def\rput@pos@bl {\def\rput@anchor{south west}}
\def\rput@pos@t  {\def\rput@anchor{north}}
\def\rput@pos@b  {\def\rput@anchor{south}}
\def\rput@pos@r  {\def\rput@anchor{east}}
\def\rput@pos@l  {\def\rput@anchor{west}}
\ifpdf 
\pgfutil@ifundefined{rput}%
  {%
  \def\rput{\pgfutil@ifnextchar[{\rput@i}{\global\edef\opt@rput{}\rput@ii}}%
  \def\rput@i[#1]{\global\edef\opt@rput{#1}\rput@ii}%
  \def\rput@ii{\pgfutil@ifnextchar({\def\angle@rput{0}\rput@iv}{\rput@iii}}%
  \def\rput@iii#1{\def\angle@rput{#1}\pgfutil@ifnextchar({\rput@iv}{\rput@iv(0,0)}}%,
  \def\rput@iv(#1){\def\pos@rput{#1}%
                   \rput@parsecoordinate{#1}%
                   \rput@v}%
  \def\rput@v#1{%
               \begingroup
                  \@nameuse{rput@pos@\opt@rput}%
                  \begin{tikzpicture}[overlay] 
                    \path (0,0)--(\pos@rput);
                    \protected@edef\rput@temp{%
                                              \noexpand\node[inner sep=0pt,
                                                            anchor=\rput@anchor,
                                                            rotate=\angle@rput]%
                                             }\rput@temp at (\pos@rput) {#1}; 
                  \end{tikzpicture}% 
               \endgroup\ignorespaces
               }%
  }{%
     }%
\fi 
\catcode`\;=\rputPtVirCode\relax
\catcode`\@=\rputAtCode\relax 
\endinput 



\documentclass{scrartcl}
\usepackage{ifpdf,tikz}
\edef\rputPtVirCode{\the\catcode`\;} 
\edef\rputAtCode{\the\catcode`\@}  
\catcode`\;=12\relax
\catcode`\:=12\relax   
\catcode`\@=11\relax 
\newif\ifrput@polar\rput@polarfalse
\def\rput@empty{}

\def\rput@parsecoordinate#1{%
\rput@getseparator#1,\@nil
\ifrput@polar 
   \rput@getfrompolar#1\@nil 
\fi
}%
\def\rput@getseparator#1,#2\@nil{%
\ifx\rput@empty#2\rput@empty%
   \rput@polartrue
\else
   \rput@polarfalse
\fi
}%
\def\rput@getfrompolar#1;#2\@nil{%
  \def\pos@rput{#1:#2}%
}%

\def\rput@pos@   {\def\rput@anchor{center}}
\def\rput@pos@B  {\def\rput@anchor{base}} 
\def\rput@pos@Br {\def\rput@anchor{base east}} 
\def\rput@pos@Bl {\def\rput@anchor{base west}} 
\def\rput@pos@tr {\def\rput@anchor{north east}} 
\def\rput@pos@tl {\def\rput@anchor{north west}}
\def\rput@pos@br {\def\rput@anchor{south east}} 
\def\rput@pos@bl {\def\rput@anchor{south west}}
\def\rput@pos@t  {\def\rput@anchor{north}}
\def\rput@pos@b  {\def\rput@anchor{south}}
\def\rput@pos@r  {\def\rput@anchor{east}}
\def\rput@pos@l  {\def\rput@anchor{west}}
\ifpdf 
\pgfutil@ifundefined{rput}%
  {%
  \def\rput{\pgfutil@ifnextchar[{\rput@i}{\global\edef\opt@rput{}\rput@ii}}%
  \def\rput@i[#1]{\global\edef\opt@rput{#1}\rput@ii}%
  \def\rput@ii{\pgfutil@ifnextchar({\def\angle@rput{0}\rput@iv}{\rput@iii}}%
  \def\rput@iii#1{\def\angle@rput{#1}\pgfutil@ifnextchar({\rput@iv}{\rput@iv(0,0)}}%,
  \def\rput@iv(#1){\def\pos@rput{#1}%
                   \rput@parsecoordinate{#1}%
                   \rput@v}%
  \def\rput@v#1{%
               \begingroup
                  \@nameuse{rput@pos@\opt@rput}%
                  \begin{tikzpicture}[overlay] 
                    \path (0,0)--(\pos@rput);
                    \protected@edef\rput@temp{%
                                              \noexpand\node[inner sep=0pt,
                                                            anchor=\rput@anchor,
                                                            rotate=\angle@rput]%
                                             }\rput@temp at (\pos@rput) {#1}; 
                  \end{tikzpicture}% 
               \endgroup\ignorespaces
               }%
  }{%
     }%  
\fi 
\catcode`\;=\rputPtVirCode\relax
\catcode`\@=\rputAtCode\relax 
\begin{document}

\null\vspace*{4cm}%
\hspace*{5cm}%
\foreach \a in {0,4,...,356}{\rput(\a;3){$\bullet$}}\rput[B](0;0){Circle}%     

\hspace{5cm}end\rput[B](180;5cm){start} 
\end{document}

How to use :

\documentclass{scrartcl}
\usepackage{tikzrput}
\begin{document}

\null\vspace*{4cm}%
\hspace*{5cm}%
\foreach \a in {0,4,...,356}{\rput(\a;3){$\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}  

Result :

enter image description here

share|improve this answer
    
Finally I build a little package with this code –  Alain Matthes Feb 23 '12 at 10:29
add comment

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.