%%
%% This is file `realboxes.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% realboxes.dtx  (with options: `realboxes.sty')
%% 
%% Copyright (C) 2011 by Martin Scharrer <martin@scharrer-online.de>
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3c
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%% 
%%    http://www.latex-project.org/lppl.txt
%% 
%% and version 1.3c or later is part of all distributions of LaTeX
%% version 2008/05/04 or later.
%% 
%% This work has the LPPL maintenance status `maintained'.
%% 
%% The Current Maintainer of this work is Martin Scharrer.
%% 
%% This work consists of the files realboxes.dtx, realboxes.ins
%% and the derived file realboxes.sty.
%% 
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{realboxes}[2011/08/08 v0.2 Change box commands to read there content as real boxes]
\newif\ifrealboxes@core
\newif\ifrealboxes@xcolor
\newif\ifrealboxes@color
\newif\ifrealboxes@graphicx
\newif\ifrealboxes@graphics
\newif\ifrealboxes@dashbox
\newif\ifrealboxes@fancybox
\DeclareOption{all}{%
    \realboxes@coretrue
    \realboxes@xcolortrue
    \realboxes@colortrue
    \realboxes@graphicxtrue
    \realboxes@graphicstrue
    \realboxes@dashboxtrue
    \realboxes@fancyboxtrue
}
\DeclareOption*{%
    \begingroup
    \expandafter\ifx\csname realboxes@\CurrentOption true\endcsname\relax
        \endgroup
        \@unknownoptionerror
    \else
        \endgroup
        \csname realboxes@\CurrentOption true\endcsname
    \fi
}
\ProcessOptions\relax
\edef\@tempa{\@ptionlist{\@currname.\@currext}}
\ifx\@tempa\empty
    \realboxes@coretrue
    \@ifpackageloaded{dashbox}{\realboxes@dashboxtrue}{}
    \@ifpackageloaded{color}{\realboxes@colortrue}{}
    \@ifpackageloaded{xcolor}{\realboxes@xcolortrue}{}
    \@ifpackageloaded{graphics}{\realboxes@graphicstrue}{}
    \@ifpackageloaded{graphicx}{\realboxes@graphicxtrue}{}
    \@ifpackageloaded{fancybox}{\realboxes@fancyboxtrue}{}
\fi
\ifrealboxes@fancybox
    \realboxes@coretrue
\fi
\RequirePackage{collectbox}
\IfFileExists{adjcalc.sty}{%
    \RequirePackage{adjcalc}
}{%
    \RequirePackage{calc}
    \def\adjsetlength{\setlength}
}
\ifrealboxes@core
\newcommand*{\Makebox}{%
    \collectboxcheckenv{Makebox}%
    \@ifnextchar[%
        \@Makebox
        \mbox
}
\def\@Makebox[#1]{%
    \@ifnextchar[%
        {\@iMakebox{#1}}%
        {\@iMakebox{#1}[c]}%
}
\def\@iMakebox#1[#2]{%
    \@collectbox{%
        \let\@tempboxa\collectedbox
        \adjsetlength\@tempdima{#1}%
        \hb@xt@\@tempdima{\csname bm@#2\endcsname}%
    }%
}
\newcommand*\Fbox{%
    \collectbox@{\kern\fboxsep}{\let\@tempboxa\collectedbox\@frameb@x\relax}{\kern\fboxsep}%
}
\newcommand*\Frame{%
    \@collectbox{\frame\BOXCONTENT}%
}
\newcommand*\Mbox{%
    \leavevmode
    \@ifnextchar\bgroup
        \hbox
        \mbox
}
\newcommand*\Raisebox[1]{%
    \leavevmode
    \collectboxcheckenv{Raisebox}%
    \@ifnextchar[%
        {\@Rsbox{#1}}%
        {\@collectbox{\@iRsbox{#1}{}}}%
}
\def\@Rsbox#1[#2]{%
    \@ifnextchar[%
        {\@iiRsbox{#1}{#2}}%
        {\@collectbox{\@iRsbox{#1}{#2}}}%
}
\def\@iRsbox#1#2{%
    \adjsetlength\@tempdima{#1}%
    \ifx \\#2\\\else
        \adjsetlength\@tempdimb{#2}%
    \fi
    \setbox\collectedbox\hbox{\raise\@tempdima\box\collectedbox}%
    \ifx \\#2\\\else
        \ht\collectedbox\@tempdimb
    \fi
    \box\collectedbox
}
\def\@iiRsbox#1#2[#3]{%
    \@collectbox{\@iiiRsbox{#1}{#2}{#3}}%
}
\def\@iiiRsbox#1#2#3{%
    \adjsetlength\@tempdima{#1}%
    \adjsetlength\@tempdimb{#2}%
    \adjsetlength\dimen@{#3}%
    \setbox\collectedbox\hbox{\raise\@tempdima\box\collectedbox}%
    \ht\collectedbox\@tempdimb
    \dp\collectedbox\dimen@
    \box\collectedbox
}
\newcommand*\Leftline{\nocollectbox@to\linewidth{}{}\hss}
\newcommand*\Rightline{\nocollectbox@to\linewidth\hss{}{}}
\newcommand*\Centerline{\nocollectbox@to\linewidth\hss{}\hss}
\newcommand*\Rlap{\nocollectbox@to\z@{}{}\hss}
\newcommand*\Llap{\nocollectbox@to\z@\hss{}{}}
\newcommand*\Framebox{%
    \collectboxcheckenv{Framebox}%
    \@ifnextchar[%
        \@Framebox
        \Fbox
}
\def\@Framebox[#1]{%
  \@ifnextchar[%
    {\@iFramebox{#1}}%
    {\@iFramebox{#1}[c]}%
}
\def\@iFramebox#1[#2]{%
    \@collectbox{\@iiFramebox{#1}{#2}}%
}
\def\@iiFramebox#1#2{%
    \let\@tempboxa\collectedbox
    \adjsetlength\@tempdima{#1}%
    \setbox\@tempboxa\hb@xt@\@tempdima
         {\kern\fboxsep\csname bm@#2\endcsname\kern\fboxsep}%
    \@frameb@x{\kern-\fboxrule}%
}
\newcommand\Parbox{%
  \collectboxcheckenv{Parbox}%
  \@ifnextchar[%
    \@iParbox
    {\@iiiParbox c\relax[s]}%
}
\def\@iParbox[#1]{%
  \@ifnextchar[%
    {\@iiParbox{#1}}%
    {\@iiiParbox{#1}\relax[s]}%
}
\def\@iiParbox#1[#2]{%
  \@ifnextchar[%
    {\@iiiParbox{#1}{#2}}%
    {\@iiiParbox{#1}{#2}[#1]}%
}
\def\@iiiParbox#1#2[#3]#4{%
  \leavevmode
  \begingroup
  \@pboxswfalse
  \adjsetlength\@tempdima{#4}%
  \let\collect@box\vbox
  \let\@tempboxa\collectedbox
  \collectbox@{\hsize\@tempdima\@parboxrestore}{\@vParbox{#1}{#2}{#3}}{\@@par}%
}
\def\@vParbox#1#2#3{%
    \ifx\relax#2\else
      \adjsetlength\@tempdimb{#2}%
      \edef\@parboxto{to\the\@tempdimb}%
    \fi
    \if#1b\vbox
    %\else\if #1B\vbox
    \else\if #1t\vtop
    %\else\if #1T\vtop
    \else\ifmmode\vcenter
    \else\@pboxswtrue $\vcenter
    \fi\fi\fi
    %\fi\fi
    \@parboxto{\let\hss\vss\let\unhbox\unvbox
       \csname bm@#3\endcsname}%
    \if@pboxsw \m@th$\fi
  \endgroup
}
\newcommand*\Sbox@[1]{\@collectboxto{#1}{}}
\def\Savebox#1{%
  \@ifnextchar[%
    {\@Savebox#1}%
    {\Sbox@#1}%
}
\ifrealboxes@fancybox
\RequirePackage{fancybox}
\let\orig@fancy@Sbox\Sbox
\def\Sbox{%
    \begingroup
    \def\@tempa{Sbox}%
    \expandafter\endgroup
    \ifx\@currenvir\@tempa
        \orig@fancy@Sbox
        \edef\@currenvir{\@currenvir\space}%
    \else
        \expandafter\Sbox@
    \fi
}
\else
\let\Sbox\Sbox@
\AtBeginDocument{\@ifpackageloaded{fancybox}{%
    \PackageWarning{realboxes}{Package 'fancybox' got loaded. This requires 'realboxes' to be loaded with the 'fancybox' option!}%
}{}}%
\fi
\def\@Savebox#1[#2]{%
  \@ifnextchar [%
    {\@iSavebox#1{#2}}%
    {\@iSavebox#1{#2}[c]}%
}
\def\@iSavebox#1#2[#3]{%
    \@collectboxto#1{\@iiSavebox{#1}{#2}{#3}}%
}
\def\@iiSavebox#1#2#3{%
    \sbox#1{%
        \let\@tempboxa#1%
        \adjsetlength\@tempdima{#2}%
        \hb@xt@\@tempdima{\csname bm@#3\endcsname}%
    }%
}
\fi
\ifrealboxes@xcolor
    \RequirePackage{xcolor}
    \realboxes@colortrue
\else
  \ifrealboxes@color
    \RequirePackage{color}
  \fi
\fi
\ifrealboxes@color
\newcommand*\Colorbox{}%
\def\Colorbox#1#{%
    \collectboxcheckenv{Colorbox}%
    \Color@box{#1}%
}
\def\Color@box#1#2{%
    \@collectbox{\color@box{#1}{#2}\BOXCONTENT}%
}
\newcommand*\Fcolorbox{}
\def\Fcolorbox#1#{%
    \collectboxcheckenv{Fcolorbox}%
    \Color@fbox{#1}%
}
\def\Color@fbox#1#2#3#{%
    \Color@@fbox{#1}{#2}{#3}%
}
\def\Color@@fbox#1#2#3#4{%
    \protect\@collectbox{\protect\color@fb@x{#1}{#2}{#3}{#4}\BOXCONTENT}%
}
\fi
\ifrealboxes@graphicx
    \RequirePackage{graphicx}
    \realboxes@graphicstrue
\else
  \ifrealboxes@graphics
    \RequirePackage{graphics}
  \fi
\fi
\ifrealboxes@graphics
\newcommand*\Rotatebox{%
    \collectboxcheckenv{Rotatebox}%
    \@ifnextchar[%
        \Rotatebox@kv
        \Rotatebox@std
}
\def\Rotatebox@kv[#1]#2{%
    \@collectbox{\Grot@box@kv[#1]{#2}\BOXCONTENT}%
}
\def\Rotatebox@std#1{%
    \@collectbox{\Grot@box@std{#1}\BOXCONTENT}%
}
\newcommand*\Scalebox[1]{%
    \collectboxcheckenv{Scalebox}%
    \@ifnextchar[%
        {\Scale@box{#1}}%
        {\Scale@box{#1}[#1]}%
}
\def\Scale@box#1[#2]{%
    \@collectbox{\Gscale@box{#1}[#2]\BOXCONTENT}%
}
\newcommand*\Reflectbox{%
    \collectboxcheckenv{Reflectbox}%
    \Scale@box{-1}[1]%
}
\newcommand*\Resizebox{%
    \collectboxcheckenv{Resizebox}%
    \@ifstar
        {\@Resizebox\totalheight}%
        {\@Resizebox\height}%
}
\@namedef{Resizebox*}{%
    \@collectboxisenv{Resizebox*}%
    \@Resizebox\totalheight
}
\def\@Resizebox#1#2#3{%
    \@collectbox{\let\setlength\adjsetlength\Gscale@@box{#1}{#2}{#3}\BOXCONTENT}%
}
\fi
\ifrealboxes@dashbox
\RequirePackage{dashbox}
\newcommand*\Dbox{%
    \@collectbox{\dbox{\BOXCONTENT}}%
}
\newcommand*\Dashbox{%
    \@ifnextchar[%
        \@Dashbox
        \Dbox
}
\def\@Dashbox[#1]{%
    \@ifnextchar[%
        {\@iDashbox{#1}}%
        {\@iDashbox{#1}[c]}%
}
\def\@iDashbox#1[#2]{%
    \@collectbox{\dashbox[#1][#2]{\BOXCONTENT}}%
}
\newcommand*\Lbox{%
    \@ifnextchar[%
        \@Lbox
        {\@collectbox{\lbox{\BOXCONTENT}}}%
}
\def\@Lbox[#1]{%
    \@collectbox{\lbox[#1]{\BOXCONTENT}}%
}
\newcommand*\Dlbox{%
    \@ifnextchar[%
        \@Dlbox
        {\@collectbox*\dlbox}%
}
\def\@Dlbox[#1]{%
    \@collectbox{\dlbox[#1]{\BOXCONTENT}}%
}
\fi
\endinput
%%
%% End of file `realboxes.sty'.
