I want to create a new environment which depend if a parameter exists or not. The basic definition, which works fine, is:
\newrgbcolor{bcolor}{1. 1. 1.}%
\newenvironment{pbox}
{\begin{lrbox}{\dummybox}%
\begin{minipage}{0.95\linewidth}
}
{\end{minipage}\end{lrbox}%
{\setlength{\fboxsep}{0.02\linewidth}%
\colorbox{bcolor}{\usebox{\dummybox}}}\vskip1.2em}
In some cases I need to specify the height of the minipage, there for I tried
\usepackage{ifthen}
\newrgbcolor{bcolor}{1. 1. 1.}%
\newenvironment{pbox}[1][0]
{\begin{lrbox}{\dummybox}%
\ifthenelse{\value{#1}=0}
{\begin{minipage}{0.95\linewidth}}
{\begin{minipage}[c][#1][c]{0.95\linewidth}}
}
{\end{minipage}\end{lrbox}%
{\setlength{\fboxsep}{0.02\linewidth}%
\colorbox{bcolor}{\usebox{\dummybox}}}\vskip1.2em}
which does not.
In most cases I want to use the pbox without the extra argument to detect the right size automatilly. Only when I specifiy the additional parameter the box should be fixed to this size.
Example:
\begin{pbox}
This is a normal pbox which height is depending on the content.
\end{pbox}
\begin{pbox}[10cm]
This is a pbox which is at least 10cm height
\end{pbox}
How can this be done in a correct way?

\newrgbcolorcome from? Also I do not think it is a good idea to declare a new color each time the environment is used. – daleif Feb 1 '12 at 15:10