[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"-------------------------
%---------------------------------------------------------------------------
\makeatletter
\def\pst at picture{%
\@ifnextchar[%
{\pst at picture@}%
{\pst at picture@[shift=0]}}
\def\pst at picture@[#1]#2(#3,#4){%
\@ifnextchar(%
{\pst@@picture@#1,(#3,#4)}
{\pst@@picture@#1,(0,0)(#3,#4)}}
\def\pst@@picture@#1(#2,#3)(#4,#5){%
\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%
\fi%
\pst@@@picture@#1(#2,\pst at dimb)(#4,\pst at dimd)}
\def\pst@@@picture@{%
\@ifnextchar,%
{\pst@@@@picture@ shift=\pst at dimb}%
{\pst@@@@picture@}}
\def\pst@@@@picture@#1,{%
\set at ps#1==\@nil%
\@ifnextchar(%
{\pst@@@picture[]}%
{\pst@@@@picture@}}
\def\set at ps#1#2=#3=#4\@nil{%
\ifx#4=%
\psset{#1#2=#3}%
\else%
\ifx#1b%
\pst at dimg=0pt%
\else%
\ifx#1o%
\pst at dimg=\pst at dimb%
\else%
\pst at dimg=-\pst at dimd%
\advance\pst at dimg\pst at dimb%
\ifx#1t%
\else%
\ifx#1c%
\pst at dimg=0.5\pst at dimg%
\else%
\pst at dimg=#1#2\pst at dimg%
\fi%
\fi%
\fi%
\fi%
\psset{shift=\pst at dimg}%
\fi}
\makeatother
%---------------------------------------------------------------------------
%---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:
1)\begin{pspicture}[<number>]...
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.
2)\begin{pspicture}[]...
The baseline is aligned with the origin of the pspicture.
3)\begin{pspicture}[<letter>]...
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.
Toni
More information about the PSTricks
mailing list