%%
%% This is file `pbox.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% pbox.dtx  (with options: `style')
%% 
%% Copyright (C) 2003,2011  Simon Law
%% 
%%   This program is free software: you can redistribute it and/or modify
%%   it under the terms of the GNU General Public License as published by
%%   the Free Software Foundation, either version 3 of the License, or
%%   (at your option) any later version.
%% 
%%   This program is distributed in the hope that it will be useful,
%%   but WITHOUT ANY WARRANTY; without even the implied warranty of
%%   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%%   GNU General Public License for more details.
%% 
%%   You should have received a copy of the GNU General Public License
%%   along with this program.  If not, see <http://www.gnu.org/licenses/>.
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{pbox}[2011/12/07 v1.2 Dynamic parboxes]
\RequirePackage{calc}
\RequirePackage{ifthen}
\newcommand{\settominwidth}[3][\columnwidth]{%
  \settowidth{#2}{\begin{tabular}{@{}l@{}}#3\end{tabular}}%
  \ifthenelse{\lengthtest{#1<#2}}{\setlength{#2}{#1}}{}}
\newcommand{\widthofpbox}[1]{%
  \widthof{\begin{tabular}{@{}l@{}}#1\end{tabular}}}
\DeclareRobustCommand*{\pbox}[1][]{%
  \def\pb@xargi{#1}%
  \pb@xi}
\DeclareRobustCommand*{\pb@xi}[1][]{%
  \def\pb@xargii{#1}%
  \pb@xii}
\DeclareRobustCommand*{\pb@xii}[1][]{%
  \def\pb@xargiii{#1}%
  \pb@xiii}
\newlength{\pb@xlen}
\DeclareRobustCommand{\pb@xiii}[2]{%
  \settominwidth[#1]{\pb@xlen}{#2}%
  \ifthenelse{\equal{\pb@xargi}{}}
    {\parbox{\pb@xlen}{#2}}
    {\ifthenelse{\equal{\pb@xargii}{}}
      {\ifthenelse{\equal{\pb@xargiii}{}}
        {\parbox[\pb@xargi]{\pb@xlen}{#2}}
        {\parbox[\pb@xargi][][\pb@xargiii]{\pb@xlen}{#2}}}
      {\ifthenelse{\equal{\pb@xargiii}{}}
        {\parbox[\pb@xargi][\pb@xargii]{\pb@xlen}{#2}}
        {\parbox[\pb@xargi][\pb@xargii][\pb@xargiii]{\pb@xlen}{#2}}}}%
  \def\pb@xargi\relax
  \def\pb@xargii\relax
  \def\pb@xargiii\relax
  \makebox[0pt]{}}
\endinput
%%
%% End of file `pbox.sty'.
