[pstricks] pspicture: shift vs. baseline

Antonio Polo antonio.polo at pu.t-com.hr
Wed Jul 26 18:16:22 CEST 2006

On 2006, July 4th, Bernd Westphal wrote:
> Moin.
> If I understand it correctly, old versions of pstricks use
>   \begin{pspicture}[0.5]
> to set the baseline at half the height of the box and
>   \begin{pspicture}[]
> puts the baseline through the origin.
> The newer versions only have 'shift' where
>   \begin{pspicture}[shift=0.5]
> shifts by 0.5 "units", i.e. not related to the box' height.
> Is there a way to obtain the "old" behaviour with the newer versions, other
> than explicitly calculating the height and setting shift correspondingly?
> Is there in particular an easy way to put the baseline through the origin
> with the newer versions?
> Schoen'n Gruss
>   Bernd Westphal

I had the same problem, expecially when I tried to use old pspictures with the 
new version of pstricks: the problem is not to calculate the shift parameter 
for the new pictures, but to re-edit and re-calculate it for the old ones. I 
solved this problem by myself and also I (think to have) solved the problems 
of compatibility of the old version with the new one; after the loading of 
pstricks package, you put these lines in your preamble:

%--begin-------Re-definition of "\pst at picture"-------------------------
\def\pst at picture{%
  {\pst at picture@}%
  {\pst at picture@[shift=0]}}
\def\pst at picture@[#1]#2(#3,#4){%
  \pssetylength\pst at dimb{#3}%
  \pssetylength\pst at dimd{#5}%
  \ifdim\pst at dimb>\pst at dimd%
  \pst at dimg=\pst at dimb%
  \pst at dimb=\pst at dimd%
  \pst at dimd=\pst at dimg%
  \pst@@@picture@#1(#2,\pst at dimb)(#4,\pst at dimd)}
  {\pst@@@@picture@ shift=\pst at dimb}%
  \set at ps#1==\@nil%
\def\set at ps#1#2=#3=#4\@nil{%
  \pst at dimg=0pt%
  \pst at dimg=\pst at dimb%
  \pst at dimg=-\pst at dimd%
  \advance\pst at dimg\pst at dimb%
  \pst at dimg=0.5\pst at dimg%
  \pst at dimg=#1#2\pst at dimg%
  \psset{shift=\pst at dimg}%
%---end--------Re-definition of "\pst at picture"-------------------------

Obviously it would be better to change the command directly in the 
"pstricks.tex" file, but I can't do it and these lines work fine too.
With this change, the environment "pspicture" works so:

It shifts the baseline linearly along the height of the pspicture.
<number>=0 means "bottom" and <number>=1 means "top";
all decimal numbers are allowed.

The baseline is aligned with the origin of the pspicture.

This is something more: 
<letter>=b same as <number>=0: baseline aligned with the bottom 
<letter>=c same as <number>=0.5: baseline aligned with the center
<letter>=t same as <number>=1: baseline aligned with the top
<letter>=o means baseline aligned with the origin
Expecially the last is useful with the next case.

4)\begin{pspicture}[...,<option>,<number> or <letter>,<option>...]...
You can put the number or the letter also between the other classical options 
such as "showgrid=true", "linestyle=dashed" and so on.

Now I hope you enjoy shifting pspictures.


More information about the PSTricks mailing list