[pstricks] \pspentagonbox()
Herbert Voss
Herbert.Voss at alumni.TU-Berlin.DE
Sat Nov 13 13:59:48 CET 2004
Herbert Voss wrote:
> Ahmet Saygin wrote:
>
>> How do I have a \pspentagonbox that surrounds the text given to it?
>> Ex: kind of \pspentagonbox{Pstricks is so funny!}
>> should create a pentagon arround that text?
>
>
> http://PSTricks.de/Nodes/nodes.phtml#hexagon
>
> may help
sorry, I read hexagon instead of pentagon.
here comes the right one.
Herbert
\documentclass[a4paper]{article}
\usepackage{pst-tree}
\makeatletter
% Box of an pentagon form built using the code of \psframebox
\def\pspentagonbox{\pst at object{pspentagonbox}}
\def\pspentagonbox at i{\pst at makebox\pspentagonbox at ii}
\def\pspentagonbox at ii{{%
\begingroup
\pst at useboxpar
\pst at dima=\pslinewidth
\advance\pst at dima by \psframesep
\pst at dimc=\wd\pst at hbox\advance\pst at dimc by \pst at dima
\pst at dimb=\dp\pst at hbox\advance\pst at dimb by \pst at dima
\pst at dimd=\ht\pst at hbox\advance\pst at dimd by \pst at dima
\setbox\pst at hbox=\hbox{%
\ifpsboxsep\kern\pst at dima\fi
\begin at ClosedObj
\addto at pscode{%
\psk at cornersize
\pst at number\pst at dima neg
\pst at number\pst at dimb neg
\pst at number\pst at dimc
\pst at number\pst at dimd
.5
\tx at pentagonA
}%
\def\pst at linetype{2}%
\showpointsfalse
\end at ClosedObj
\box\pst at hbox
\ifpsboxsep\kern\pst at dima\fi%
}%
\ifpsboxsep\dp\pst at hbox=\pst at dimb\ht\pst at hbox=\pst at dimd\fi
\leavevmode
\box\pst at hbox
\endgroup%
}}
% From the Frame PostScript macro
\pst at def{pentagonA}<{%
% .5 dimd dimc -dimb -dima cornersize
CLW mul
/a ED % .5*currentlinewidth
3 -1 roll
2 copy gt { exch } if
a sub
/y2 ED
a add
/y1 ED
2 copy gt { exch } if
a sub /x2 ED
a add /x1 ED
1 index 0 eq {pop pop \tx at pentagon } { OvalFrame } ifelse
}>
\pst at def{pentagon}<{%
%
x2 x1 sub dup mul y2 y1 sub dup mul sqrt /radius exch def
/l radius 2 mul 36 sin mul def
x2 x1 add 2 div y2 y1 add 2 div translate 0 radius moveto
/alpha 90 def
5 { /alpha alpha 72 add def
radius alpha cos mul
radius alpha sin mul
lineto } repeat
closepath
}>
\makeatother
\pagestyle{empty}
\begin{document}
\Large
\pspentagonbox{T}\hfill
\pspentagonbox[framesep=0.1]{T}\hfill
\pspentagonbox[framesep=0.6]{T}\hfill
\pspentagonbox[framesep=-0.5]{T}
\vspace{2cm}
\pspentagonbox{Text}\hfill
\pspentagonbox[linecolor=red,fillstyle=solid,fillcolor=cyan,
doubleline=true,framesep=0.2]{Text}
\vspace{2cm}
\pspentagonbox{Long text}\hfill
\pspentagonbox[framesep=0.5]{Long text}\hfill
\pspentagonbox{\shortstack{Text\\Text\\Text}}\hfill
\end{document}
--
http://TeXnik.de/
http://PSTricks.de/
ftp://ftp.dante.de/tex-archive/info/math/voss/Voss-Mathmode.pdf
http://www.dante.de/faq/de-tex-faq/
http://www.tex.ac.uk/cgi-bin/texfaq2html?introduction=yes
More information about the PSTricks
mailing list