[pstricks] add latex text (and code) in pstricks

tiM tiporichie at hotmail.com
Tue Aug 8 23:57:45 CEST 2006

Dear Jean-Côme Charpentier,

Merci beaucoup for your extensive explanation. At first, I already expected
the mainjob had to be done in LaTeX itself, just couldn't find how on the
web, so I assumed it couldn't be done. I learned much from your example
and... Also very glad to know that there's something like a calc package...
The ugly programming I did in the past to simulate something like that!. 

Anyway, thanks again!!!

-----Original Message-----
From: pstricks-bounces at tug.org [mailto:pstricks-bounces at tug.org] On Behalf
Of Jean-Côme Charpentier
Sent: dinsdag 8 augustus 2006 21:55
To: Graphics with PSTricks
Subject: Re: [pstricks] add latex text (and code) in pstricks

tiM Sportny a écrit :
> hello,
> just started using pstricks two days ago and skipped one night of 
> sleep using it. Not that it's hard to use, just because it's too much 
> fun to see all possibilities.

Isn't it :-)
I understand: I have skipped many nights of sleep too!

> But there's one i can't find, don't know if it's possible but lets try:

*All* is possible.

> I'm looking for a way to make a function/environment in latex where a 
> paragraph (or two) can be printed and the pstricks picture will adjust 
> it's height to it.

It's not a pstricks question. For this kind of problem, you can put the body
of the environment in a box, using environment lrbox, and make what you want
in the final part of your environment.

> For example make the following code:
> \begin{mypsenv}
>     just some example text that is used to illustrate my plans 
> \end{mypsenv}
> print the text of the environment and place it in a gray box with 
> rounded lower corners.
> One way i came up with was something like this:
> \newenvironment{mypsenv}[0]{\begin{pspicture}(\linewidth,-1)
> \psline*[linearc=.5,linecolor=gray](0,0)(0,-\parheight)(\linewidth,-\p
> arheight)(\linewidth,0)
> \end{pspicture}}{\vspace{1cm}}
> where \parheight would reprecent the total height of the text in the 
> environment. There is one majar drawback, i couldn't find a way to 
> determine the height of the text in the environment (\parheight).

With box, it's \ht\nameofbox+\dp\nameofbox.

> Does somebody know the way to do this kind of things? I prefer to let 
> latex do the typesetting itself

It's a good idea.

> so i can use latex tables or something in it, but if someone has a 
> solution that fits just for text i'd be a great help to.

Ok. Let's go. I use \psframesep in order to have separation between text and
frame. For calculation, the calc package is very nice.
In this kind of problem, the hardest part is to deal vertical and horizontal
dimensions in a correct way.



   % \parheight = vertical space before frame.
   % -0.3\baselineskip is onky a proposition, you can
   % play with other values.
   % \parwidth = whole width, that is, width of frame.
   % #1 don't exist in the final part, \parwidth will exist.
   % material typesetted in a minipage
   % Note that the material is shorter than the frame.
   % \parheight = total height (of minipage)
   % no problem for width.
   % about height, there will be a shifting relative to
   % minipage (look the code carefully)
   % minipage shifted by \psframesep.

Some text above.
Some text below.

Second trial:
Some text below.

The last one:
Some text below.


In this code, mypsenv works without pspicture. If you put mypsenv in a
pspicture environment, you have to remove \par(s) and \vspace(s) (an

Hope this help,

   Jean-Côme Charpentier
pstricks mailing list
pstricks at tug.org

More information about the PSTricks mailing list