[pstricks] Problem placing boxes and undwanted space
Ulrik Stervbo
ulriks at ruc.dk
Thu May 26 16:39:57 CEST 2005
Hello everyone,
I'm working on making it easier (for me) to make posters with latex. To comply
with the CVI of Novo Nordisk, I need a box with rounded corners and on the top
of that a heading:
+-- Abstract ---------+
| text text text text |
| text text text text |
+---------------------+
I've tried modifying one of the overpic examples, but simply cant get it to work
properly.
I've attached some code which compiles.
One problem is that there is a space between the textbox and the page margin,
another problem is that the headingbox is placed at the top of the textbox
minus some length, which I have no idea of what is.
Appologies if I (once again) have forgotten to think, but I am quite new to
messing with latex like this. And any help is appreciated.
Ulrik
\documentclass[draft]{article}
% Declaring a few flags
\newif\ifdraftmode
\DeclareOption{draft}{\draftmodetrue}
\newif\ifshowtextframe
\DeclareOption{showframe}{\showtextframetrue}
\ProcessOptions\relax
\usepackage{calc}
%\usepackage[dvips,a0paper,portrait,noheadfoot,
% centering,body={76cm,111cm}]{geometry}
\usepackage[dvips,a4paper,portrait,noheadfoot,
centering]{geometry}
\usepackage{pstricks}
% if were in draft mode, show a frame around the textarea
\ifdraftmode
\geometry{showframe}
\fi
% creating a grid
\newpsobject{showgrid}{psgrid}{subgriddiv=1,griddots=10,gridlabels=6pt}
% Turn off page numbers and section numbers
\pagestyle{empty}
\setcounter{secnumdepth}{0}
% setting the default font to sans serif
\renewcommand{\familydefault}{\sfdefault}
\makeatletter
%--------------------------------------------------------------------------
% creating and setting a few lengths and counters
%
% First lengths and counters that has got to do with the general
% page layout e.g. all the column stuff
% And while we're at it, leys set the defaults
\newcount\postercolnum
\newlength\postercolsep
\newlength\postercolwidth
\newlength\posterboxskip
\postercolnum=2
\setlength\postercolsep{0.5cm}
\setlength\postercolwidth{(\textwidth - \postercolsep) / \postercolnum}
\setlength\parindent{0pt}
\setlength{\parskip}{1ex plus 0.2ex minus 0.2ex}
\setlength{\posterboxskip}{1ex plus 0.2ex minus 0.2ex}
% Set the rounding of the archs to Novo's default according to theis CVI:
% 1/5 of the shortest side
\newcount\roundedness
\pst at divide{1pt}{5pt}\roundedness
\def\postertextbox{\pst at object{postertextbox}}
\def\postertextbox at i#1#2{{%
\use at par % Local parameters
\if at star\solid at star\fi % Stared version
\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 #2}%
\ifshowtextframe
\psframebox[linestyle=solid]{\box\z@}%
\else
\psframebox{\box\z@}
\fi%
}}
%
\newsavebox\sbPostertextbox
\newsavebox\sbPostertextheadingbox
\newlength\posterabstractboxheight
\newsavebox\sb at Postertextbox
\newsavebox\sb at Postertextheadingbox
\newlength\poster at abstractboxheight
\def\abstractbox{\@ifnextchar [{\abstractbox at i}{\abstractbox at i[]}}%
\def\abstractbox at i[#1]#2{%
% Create the textbox'
\savebox{\sb at Postertextheadingbox}{\psframebox[framesep=0pt,linestyle=none,fillstyle=solid,fillcolor=yellow]{%
\hspace{3pt}\Large Abstract\hspace{3pt}}}
\savebox{\sb at Postertextbox}{
\postertextbox[#1]{\postercolwidth}{#2}%
}%
\psaddtolength{\poster at abstractboxheight}{\ht\sb at Postertextheadingbox}%
\psaddtolength{\poster at abstractboxheight}{\ht\sb at Postertextbox}%
\begin{minipage}[t][\poster at abstractboxheight]{\wd\sb at Postertextbox}
\begin{pspicture}(\wd\sb at Postertextbox,\poster at abstractboxheight)\showgrid
\rput[lb](0,0){\usebox{\sb at Postertextbox}}
\rput[bl](1,\ht\sb at Postertextbox){\usebox{\sb at Postertextheadingbox}}
\psline(0,0)(0,\poster at abstractboxheight)(\wd\sb at Postertextbox,\poster at abstractboxheight)
\end{pspicture}%
\vspace{\baselineskip}\\
sb at Postertextbox width: \the\wd\sb at Postertextbox\\
postercolwidth: \the\postercolwidth\\
sb at Postertextbox height: \the\ht\sb at Postertextbox\\
poster at abstractboxheight: \the\poster at abstractboxheight
\end{minipage}%
}%
\makeatother
\begin{document}
using the abstractbox command\\
\abstractbox%[framearc=\roundedness,fillstyle=solid,fillcolor=lightgray,framesep=4mm]
{Lorem ipsum dolor sit amet, urna augue. Luctus sollicitudin,
accusantium
nostrum. Scelerisque duis eget nonummy, rhoncus}
\vspace{3cm}\\
Repeating the content of the abstractbox command\\
\savebox{\sbPostertextheadingbox}{\psframebox[framesep=0pt,linestyle=none,fillstyle=solid,fillcolor=yellow]{%
\hspace{3pt}\Large Abstract\hspace{3pt}}}
\savebox{\sbPostertextbox}{
\postertextbox[%framearc=\roundedness,fillstyle=solid,fillcolor=lightgray,framesep=4mm]
]{\postercolwidth}{Lorem ipsum dolor sit amet, urna
augue. Luctus
sollicitudin, accusantium nostrum. Scelerisque duis eget nonummy, rhoncus}%
}%
\psaddtolength{\posterabstractboxheight}{\ht\sbPostertextheadingbox}%
\psaddtolength{\posterabstractboxheight}{\ht\sbPostertextbox}%
\psaddtolength{\posterabstractboxheight}{2pt}%
\begin{minipage}[t][\posterabstractboxheight]{\wd\sbPostertextbox}
\begin{pspicture}(\wd\sbPostertextbox,\posterabstractboxheight)\showgrid
\rput[lb](0,0){\usebox{\sbPostertextbox}}
\rput[bl](1,\posterabstractboxheight){\usebox{\sbPostertextheadingbox}}
\psline(0,0)(0,\posterabstractboxheight)(\wd\sbPostertextbox,\posterabstractboxheight)
\end{pspicture}%
\vspace{\baselineskip}\\
sbPostertextbox width: \the\wd\sbPostertextbox\\
postercolwidth: \the\postercolwidth\\
sbPostertextbox height: \the\ht\sbPostertextbox\\
poster at abstractboxheight: \the\posterabstractboxheight
\end{minipage}%
\vspace{3cm}\\
What it really should look like\\
\hspace{10mm}\psframebox[framesep=0pt,linestyle=none,fillstyle=solid,fillcolor=yellow]{%
\hspace{3pt}\Large Abstract\hspace{3pt}}\vspace{-2pt}\\
\psframebox[framearc=\roundedness,fillstyle=solid,fillcolor=lightgray,framesep=4mm]{\parbox[t]{\postercolwidth}{Lorem
ipsum dolor sit amet, urna augue. Luctus sollicitudin, accusantium nostrum.
Scelerisque duis eget nonummy, rhoncus}}
\end{document}
More information about the PSTricks
mailing list