Labels positioning

Denis Girou Denis.Girou at idris.fr
Wed Jan 26 18:39:29 CET 2000


-----------------------------------------------------------------------------
This is the PSTricks mailing list, devoted to discussions about computational
graphics in (La)TeX using the PSTricks package from Timothy van Zandt.
For help using this mailing list, see instructions at the end of message.
-----------------------------------------------------------------------------

  Having some exchanges with somebody who start to use PSTricks, the following 
code that he use could to be useful to comment to wider audience.

  Comparing the (nearly) original version and the rewritted one:

    - the \pstVerb macro allows here to simplify the code and to improve
readability,

    - the "\pc..." variants (opposite to the "\ps..." ones), like \pccoil
and \pcline here, help heavily to position labels relative to these
connections and avoid to specify explicitely the coordinates for the labels
(see the betadoc1.ps documentation file).

\documentclass[a4paper]{article}

\usepackage{pst-node}
\usepackage{pst-coil}

\pagestyle{empty}

\psset{subgriddiv=0}

\begin{document}

\SpecialCoor

% (Nearly) original code
\begin{pspicture}(4,4)\psgrid[gridcolor=red]
  \pscircle(2,2){2}
  \qdisk(!2  2 70 sin mul add 2 -2 70 cos mul add){4pt}
  \pscoil[coilarm=2mm,coilwidth=2mm]{-}%
         (2,0)(!2 2 70 sin mul add 2 -2 70 cos mul add)
  \rput(3.6,1.6){$m$}
  \rput(2.8,1){$k$}
  \psline{<-}(0,2)(2,2)
  \rput(1,2.2){$r$}
\end{pspicture}
\hfill
% Rewritted code
\begin{pspicture}(4,4)\psgrid[gridcolor=red]
  \psset{labelsep=0.2}
  \pscircle(2,2){2}
  \pstVerb{/Xcoord 2  2 70 sin mul add def
           /Ycoord 2 -2 70 cos mul add def}
  \qdisk(! Xcoord Ycoord){4pt}
  \pccoil[coilarm=0.2,coilwidth=0.2](2,0)(! Xcoord Ycoord)
    \naput{$k$}\naput[npos=1]{$m$}
  \pcline{<-}(0,2)(2,2)\naput{$r$}
\end{pspicture}

\end{document}

D.G.

-----------------------------------------------------------------------------
The list interface (subscription, information, access to the archives) is on:
http://www.tug.org/cgi-bin/lwgate/pstricks
Otherway to unsubscribe, send mail to pstricks-request at mail.tug.org
with a blank subject and in body the line unsubscribe <email-address>
-----------------------------------------------------------------------------



More information about the PSTricks mailing list