[pstricks] absolute coordinates

Herbert Voss Herbert.Voss at alumni.TU-Berlin.DE
Sat Aug 16 19:23:07 CEST 2003


Stefano Baroni schrieb:
> Hi here! Can anybody help me place graphic objects on a page in absolute
> coordinates, using pstrics? From the pstricks documentation, I thought I
> understood that the default origin was the upper left corner of the
> page. The enclosed stupid test demonstrate that the default origin is
> instead the current latex point ...

maybe this helps

Herbert

\documentclass[12pt]{article}
\usepackage{pstcol}%
\usepackage{pstricks}%
\usepackage{pst-node}%
\psset{unit=1in}%
%
\oddsidemargin0pt
\topmargin=0pt
\topskip=0pt
\headheight=0pt
\headsep=0pt
\parindent=0pt
%
\SpecialCoor%
\makeatletter%
\def\putAbs(#1)#2{%
     \pnode(0,0){tempNodeA}% get the "cursor" position
     \pst at getcoor{Origin}\pst at tempa% Origin of the paper
     \pst at getcoor{#1}\pst at tempb%     Absolute coordinates
     \pst at getcoor{tempNodeA}\pst at tempc% relative coordinates
     \pnode(!%
         /XA \pst at tempa pop \pst at number\psxunit div def
         /YA \pst at tempa exch pop \pst at number\psyunit div def
         /XB \pst at tempb pop \pst at number\psxunit div def
         /YB \pst at tempb exch pop \pst at number\psyunit div def
         /XC \pst at tempc pop \pst at number\psxunit div def
         /YC \pst at tempc exch pop \pst at number\psyunit div def
         XB XC sub XA add YB YC sub YA add){tempNodeB}
     \rput[l](tempNodeB){#2}%
}
\makeatother
\newcommand\x{blah blub laber text nonsense }
\begin{document}
     \qdisk(-1,1){2pt}\rput[lt](-1,1){Upper Left}
     \pnode(0,0){Origin}%
     {\psset{linecolor=red}%
         \qdisk(0,0){4pt}\rput[l](0,0){\red Origin}%
     }%
     Nonsense Text\putAbs(1,-2){\qdisk(0,0){4pt}\red Point(1,-2)}\\
     Nonsense Text\\
     Nonsense Text\putAbs(0,-2){\qdisk(0,0){4pt}\red Point(0,-2)}\\
     Nonsense Text\\
     Nonsense Text\putAbs(0,-1){\qdisk(0,0){4pt}\red Point(0,-1)}\\
     \parbox{\textwidth}{%
         \x\x\x\x\putAbs(3,-0.5){\qdisk(0,0){4pt}\blue Point(3,0.5)}\x\x\x\x
         \putAbs(3,-5){\qdisk(0,0){4pt}\blue Point(3,-5)}
     }
\end{document}


-- 
http://www.pstricks.de/




More information about the PSTricks mailing list