TR: [pstricks] Save a length for later use

Patrice Mégret patrice.megret at fpms.ac.be
Tue May 24 18:03:46 CEST 2005



Dear Ulrik,

For posters, there are two interesting packages:

a0poster for defining the size of your poster (A3,A2,A1,A0)
textpos for defining and placing boxes into the poster

All these packages are available on CTAN

Then in the boxes, you can use whatever you want (formula, pstricks, ...)

Best regards,

Patrice

 
-----Message d'origine-----
De : pstricks-bounces at tug.org [mailto:pstricks-bounces at tug.org] De la part
de Ulrik Stervbo
Envoyé : mardi 24 mai 2005 11:04
À : pstricks at tug.org
Objet : [pstricks] Save a length for later use

Hello everybody,

I'm trying to setup ease creating posters in latex. The idea is to let the
macro
place textboxes in columns, and for that I need the total height of all
boxes
placed.

The problem is scope, global and local variables (not really a pstrick
question
i know). I've attached example code - anyone got any idea how I can solve my
problem and if it's possible at all?

Sincerely
Ulrik

And the code:
%--------------------------------------------------------------------------
%        File: ps-tricks_play.tex
%     Created: Wed May 18 11:38 2005
%  Maintainer: Ulrik Stervbo
% Last Change: Wed May 20 14:52 2005
%
% Description: Messing about with pstricks and the geometry package
%--------------------------------------------------------------------------
\documentclass[dvips]{article}

\usepackage{calc}
\usepackage{pstricks-add}
\usepackage{pstricks}
\usepackage[a4paper]{geometry}

% creating a grid
\newpsobject{showgrid}{psgrid}{subgriddiv=1,griddots=10,gridlabels=6pt}

\makeatletter
%--------------------------------------------------------------------------
% creating and setting a few lengths
\newlength{\fypos}
\setlength{\fypos}{\textheight}
\newlength{\sypos}
\setlength{\sypos}{\textheight}
%
\newlength{\fxpos}
\setlength{\fxpos}{0cm}
\newlength{\sxpos}
\setlength{\sxpos}{0cm}
%
\newlength{\curr at textboxheight}
%--------------------------------------------------------------------------
% This box is taken from the textbox example from http://tug.org/PSTricks/
% and slightly modified
\def\mytextbox{\pst at object{mytextbox}}
\def\mytextbox at i#1#2{{%
	\use at par                        % Local parameters
	\if at star\solid at star\fi          % Stared version
	\newdimen\d
% The height of the box
	\pssetlength{\pst at dimc}{-\psframesep}
	\psaddtolength{\pst at dimc}{-\psframesep}
	\psaddtolength{\pst at dimc}{-\pslinewidth}
	\psaddtolength{\pst at dimc}{-\pslinewidth}
	\pssetlength{\pst at dima}{#1}
	\psaddtolength{\pst at dima}{\pst at dimc}
	\pssetlength{\pst at dimb}{\pst at dimc}
	\setbox\z@=\vbox{\hsize=\pst at dima \par\noindent\raggedright #2}%
	\d=\ht\z@\advance\d by\dp\z@
	\psframebox{\box\z@}
	% we need to get the value from the outside of this scope
	\pssetlength{\global\curr at textboxheight}{\d}
}}

%--------------------------------------------------------------------------
% Create a poster environment, which starts a pspicture environment with
% the width and height of the page. If we're in draft mode we'll draw a
% nice grid.
\newenvironment{poster}{\begin{center}
	\begin{pspicture}(0,0)(\textwidth,\textheight)
		\showgrid(0,\textheight)(\textwidth,0)
}{\end{pspicture}\end{center}}

%--------------------------------------------------------------------------
% The titlebox environment
% Three textboxes are defined
\newenvironment{titlebox}[2]{
	\newlength\titlebox at totalheight		% the total height of the
textboxes
	\newlength\mytextbox at width				% the width
of the textboxes within the titlebox
	\setlength{\mytextbox at width}{10cm}
	\addtolength{\mytextbox at width}{-#2}
	\addtolength{\mytextbox at width}{-#2}
	\newlength\textbox at fxpos					%
the x-coor within the titlebox
	\setlength{\textbox at fxpos}{\fxpos}
	\addtolength{\textbox at fxpos}{#2}
	\newlength\textbox at fypos					%
the y-coor within the titlebox
	\setlength{\textbox at fypos}{\fypos}
	\addtolength{\textbox at fypos}{-#2}
	%%%%
	\def\mytitle[##1]##2{%
		\rput[tl](\textbox at fxpos,\textbox at fypos){%
			\mytextbox[##1]{\mytextbox at width}{%
							##2%
		}}%
		\addtolength{\titlebox at totalheight}{\curr at textboxheight}%
		\addtolength{\textbox at fypos}{\curr at textboxheight}
		\rput[bl](12,19.5){titlebox at totalheight1
\the\titlebox at totalheight}%
	}%

	% The height of this psframe should be calculated from the height of
mytitle
	
\psframe[#1](\fxpos,\fypos)(10,18)%\textboxframe at sypos)%\textbox at fypos)
	\rput[tl](12,19){titlebox at totalheight2 \the\titlebox at totalheight}
}{}
% This text box should automatically be placed just below the previous
puttextbox
% In case of being the first puttextbox below the titlebox, so we need the
% \textbox at fypos
\def\puttextbox[#1]#2#3#4{%
	\rput[tl](#2,#3){%
		\mytextbox[#1]{10cm}{#4}%
	}
	\rput[tl](12,#3){titlebox at totalheight3 \the\titlebox at totalheight}
}
\makeatother

\pagestyle{empty}

\begin{document}
\begin{poster}
	
\begin{titlebox}{framearc=0.2,fillstyle=solid,fillcolor=lightgray}{4mm}
		\mytitle[framesep=6pt]{Lorem ipsum dolor sit amet, urna
augue. Luctus
sollicitudin, accusantium nostrum. Scelerisque duis eget nonummy, rhoncus
quis
nulla praesent}
	\end{titlebox}
	%
	\puttextbox[fillcolor=yellow,
fillstyle=solid,linestyle=none]{0}{17}{Lorem
ipsum dolor sit amet, urna augue. Luctus sollicitudin}
\end{poster}
\end{document}

_______________________________________________
pstricks mailing list
pstricks at tug.org
http://tug.org/mailman/listinfo/pstricks





More information about the PSTricks mailing list