1
0
mirror of https://github.com/moparisthebest/xeps synced 2024-12-04 15:02:19 -05:00
xeps/deps/adjustbox.sty

1242 lines
34 KiB
Plaintext
Raw Normal View History

%% Copyright (C) 2011-2012 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.3
%% 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.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 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 adjustbox.dtx, adjustbox.ins
%% and the derived file adjustbox.sty.
%%
\ProvidesPackage{adjustbox}[%
2012/05/21
v1.0
Adjusting TeX boxes (trim, clip, ...)]
\RequirePackage{xkeyval}
\RequirePackage{adjcalc}
\def\adjbox@fam{adjbox}
\DeclareOptionX<Adjbox>{export}{\def\adjbox@fam{Gin}}
\DeclareOptionX<Adjbox>{Export}{\AtEndOfPackage{\let\includegraphics\adjincludegraphics}}
\DeclareOptionX<Adjbox>{patch}{%
\PackageWarning{adjustbox}{%
The 'patch' option is now deprecated.\MessageBreak
Use the new \string\adjustimage\space or \string\adjincludegraphics\space macros instead%
\@gobble
}%
}
\DeclareOptionX<Adjbox>{minimal}{\let\adjustbox@minimal\endinput}
\DeclareOptionX<Adjbox>{pgfmath}{\AtEndOfPackage{\RequirePackage{pgf}\adjcalcset{pgfmath}}}
\DeclareOptionX<Adjbox>{calc}{\AtEndOfPackage{\RequirePackage{calc}\adjcalcset{calc}}}
\DeclareOptionX<Adjbox>{etex}{\AtEndOfPackage{\adjcalcset{etex}}}
\DeclareOptionX<Adjbox>{defaultunit}{\AtEndOfPackage{\adjcalcset{defaultunit={#1}}}}
\DeclareOptionX<Adjbox>{pgf}{\PassOptionsToPackage{pgf}{trimclip}}
\DeclareOptionX<Adjbox>{PGF}{\PassOptionsToPackage{pgf}{trimclip}\AtEndOfPackage{\RequirePackage{pgf}\adjcalcset{pgfmath}}}
\DeclareOptionX*{%
\IfFileExists{tc-\CurrentOption.def}{%
\PassOptionsToPackage\CurrentOption{trimclip}%
}{%
\PassOptionsToPackage\CurrentOption{graphicx}%
}%
}
\ProcessOptionsX*<Adjbox>\relax
\RequirePackage{trimclip}
\RequirePackage{graphicx}[1999/02/16]
\RequirePackage{collectbox}[2012/05/17]
\@ifpackagelater{collectbox}{2012/05/17}{}{%
\let\@Collectbox\@collectbox
}
\newcommand*\adjustboxset{%
\@ifstar
{\adjbox@addkeysafter}%
{\adjbox@addkeysbefore}%
}
\def\adjbox@addkeysbefore#1{%
\ifx\@nnil#1\@nnil
\let\adjbox@keysbefore\@empty
\else
\expandafter\def\expandafter\adjbox@keysbefore\expandafter{\adjbox@keysbefore,#1}%
\let\adjbox@setkeys\adjbox@setkeys@ba
\fi
}
\let\adjbox@keysbefore\@empty
\def\adjbox@addkeysafter#1{%
\begingroup
\def\@tempa{#1}%
\ifx\@tempa\@empty
\endgroup
\let\adjbox@keysafter\@empty
\else
\expandafter\expandafter
\expandafter\endgroup
\expandafter\expandafter
\expandafter\def
\expandafter\expandafter
\expandafter\adjbox@keysafter
\expandafter\expandafter
\expandafter{\expandafter\@tempa\expandafter,\adjbox@keysafter}%
\let\adjbox@setkeys\adjbox@setkeys@ba
\fi
}
\let\adjbox@keysafter\@empty
\newcommand\adjustbox[1]{%
\begingroup
\edef\adjbox@line{\the\inputlineno}%
\let\collectbox@mode\relax
\let\collectbox@noindent\relax
\collectboxcheckenv{adjustbox}%
\ifcollectboxenv\else
\let\adjustbox@noindent\relax
\fi
\begingroup
\adjbox@setkeys{#1}%
\expandafter\expandafter\expandafter
\endgroup
\expandafter
\adjbox@collectbox\expandafter{\expandafter\adjustbox@\expandafter{\XKV@rm}}%
}
\def\adjbox@collectbox{\@collectbox}
\def\adjbox@setkeys@ba{%
\expandafter\expandafter
\expandafter\adjbox@@setkeys@ba
\expandafter\expandafter
\expandafter{\expandafter\adjbox@keysbefore\expandafter}%
\expandafter{\adjbox@keysafter}%
}
\def\adjbox@@setkeys@ba#1#2#3{%
\setkeys*{ADJBOX}{#1,#3,#2}%
}
\def\adjbox@setkeys{%
\setkeys*{ADJBOX}%
}
\let\adjustbox@noindent\noindent
\def\adjustbox@#1{%
\adjbox@Width\width
\adjbox@Height\height
\adjbox@Depth\depth
\adjbox@Totalheight\totalheight
\let\Width\adjbox@Width
\let\Height\adjbox@Height
\let\Depth\adjbox@Depth
\let\Totalheight\adjbox@Totalheight
\let\Gin@esetsize\adjbox@esetsize
\let\@collectbox\@Collectbox
\@tempswatrue
\toks@{{\adjustbox@content}}%
\def\setlength{\adjsetlength}%
\setkeys{adjbox,Gin,adjcalc}{#1}%
\adjbox@esetsize
\adjustbox@noindent
\the\toks@
\endgroup
}
\def\adjustbox@content{%
\usebox\collectedbox
}
\newdimen\adjbox@Width
\newdimen\adjbox@Height
\newdimen\adjbox@Depth
\newdimen\adjbox@Totalheight
\def\adjbox@esetsize{%
\ifcase0%
\ifx\Gin@ewidth\Gin@exclamation\else 1\fi
\ifx\Gin@eheight\Gin@exclamation\else 1\fi
\relax
\else
\edef\@tempa{\toks@{\noexpand
\Gscale@@box\noexpand\Gin@eresize
{\Gin@ewidth}{\Gin@eheight}{\the\toks@}}}%
\@tempa
\let\Gin@ewidth\Gin@exclamation
\let\Gin@eheight\Gin@exclamation
\fi
}
\newcommand*\adjustimage[2]{%
\adjustbox{#1}{\Gin@clipfalse\Gin@i{#2}}%
}
\newcommand*\adjincludegraphics[2][]{%
\adjustbox{#1}{\Gin@clipfalse\Gin@i{#2}}%
}
{\csname adjustbox@minimal\endcsname}
\def\adjbox@Gin@add#1{%
\def\@tempa{#1}%
\toks@\expandafter\expandafter\expandafter{\expandafter\@tempa\expandafter{\the\toks@}}%
}
\def\adjbox@Gin@Add{%
\Gin@esetsize
\@tempswatrue
\adjbox@Gin@add
}
\newcommand\newadjustboxkey{%
\@adjustboxkey\adjustbox@newkey
}
\newcommand\renewadjustboxkey{%
\@adjustboxkey\adjustbox@renewkey
}
\newcommand\provideadjustboxkey{%
\@adjustboxkey\adjustbox@providekey
}
\newcommand\defadjustboxkey{%
\@adjustboxkey\@secondoftwo
}
\def\@adjustboxkey#1{%
\@ifstar
{\@adjustboxkey@i#1*}%
{\@adjustboxkey@i#1\relax}%
}
\def\@adjustboxkey@i#1#2#3{%
\@ifnextchar{[}%
{\@adjustboxkey@ii#1#2{#3}}%
{\@adjustboxkey@ii#1#2{#3}[\@nnil]}%
}
\def\@adjustboxkey@ii#1#2#3[#4]#5{%
\ifx\@nnil#4\relax
\@adjustboxkey@iii#1#2{#3}{}{#5}%
\else
\@adjustboxkey@iii#1#2{#3}{[#4]}{#5}%
\fi
}
\def\@adjustboxkey@iii#1#2#3#4#5{%
#1{#3}{%
\ifx*#2\relax
\define@key\adjbox@fam{#3}#4{#5}%
\else
\define@key\adjbox@fam{#3}#4{%
\adjbox@Gin@Add{\@Collectbox{#5}}%
}%
\fi
}{}%
}
\def\define@adjboxkey#1#2{%
\define@key\adjbox@fam{#1}{%
\adjbox@Gin@Add{#2}%
}%
}
\def\define@adjboxkey@defvalue#1#2#3{%
\define@key\adjbox@fam{#1}[{#2}]{%
\adjbox@Gin@Add{#3}%
}%
}
\def\define@adjboxkey@novalue#1#2{%
\define@key\adjbox@fam{#1}[\@nil]{%
\adjbox@novalue{##1}%
\adjbox@Gin@Add{#2}%
}%
}
\def\adjbox@novalue#1{%
\ifx\@nil#1\else
\PackageWarning{adjustbox}{%
Key '\XKV@tkey' does not await a value.\MessageBreak
Given value will be ignored%
}%
\fi
}
\def\adjustbox@newkey#1#2{%
\@ifundefined{KV@\adjbox@fam @#1}{#2}{%
\PackageError{adjustbox}{Key '#1' already defined}{}%
}%
}
\def\adjustbox@renewkey#1{%
\@ifundefined{KV@\adjbox@fam @#1}{%
\PackageError{adjustbox}{Key '#1' undefined}{}%
}%
}
\def\adjustbox@providekey#1#2{%
\@ifundefined{KV@\adjbox@fam @#1}{#2}{}%
}
\def\adjbox@let@key#1#2#3{%
\expandafter\let\csname KV@#1@#2\expandafter\endcsname\csname KV@#1@#3\endcsname
\expandafter\let\csname KV@#1@#2@default\expandafter\endcsname\csname KV@#1@#3@default\endcsname
}
\define@key{adjbox}{viewport}{%
\def\adjustbox@content{%
\@trimclip{%
\ifGin@clip
\expandafter\@clipvpbox
\else
\expandafter\@viewportbox
\fi
}{#1}%
}%
}
\define@adjboxkey{Viewport}{\trimbox@s{#1}}%
\define@key{adjbox}{trim}{%
\def\adjustbox@content{%
\@trimclip{%
\ifGin@clip
\expandafter\@clipbox
\else
\expandafter\@trimbox
\fi
}{#1}%
}%
}
\define@adjboxkey{Trim}{\trimbox@{#1}}%
\define@adjboxkey{Clip}{\clipbox@{#1}}
\define@adjboxkey{Clip*}{\clipbox@s{#1}}
\define@adjboxkey{margin}{\marginbox@{#1}}
\define@adjboxkey{margin*}{\marginbox@s{#1}}
\adjbox@let@key\adjbox@fam{padding}{margin}
\adjbox@let@key\adjbox@fam{padding*}{margin*}
\define@key\adjbox@fam{scale}{%
\@ifnextchar\bgroup{%
\adjbox@scale@xy
}{%
\adjbox@scale@x
}#1\@nnil
}
\def\adjbox@scale@x#1\@nnil{%
\adjbox@scale@xy{#1}{#1}\@nnil%
}
\def\adjbox@scale@xy#1#2\@nnil{%
\if@tempswa
\adjbox@Gin@add{\Gscale@box{#1}[{#2}]}%
\else
\def\Gin@req@sizes{%
\def\Gin@scalex{#1}\def\Gin@scaley{#2}%
\Gin@req@height\Gin@scaley\Gin@nat@height
\Gin@req@width\Gin@scalex\Gin@nat@width}%
\fi
\@tempswatrue
}
\define@key\adjbox@fam{reflect}[]{%
\adjbox@scale@xy{-1}{1}\@nnil
}
\expandafter\let\csname KV@\adjbox@fam @rotate\endcsname\KV@Gin@angle
\def\adjbox@halign#1#2#3{%
\@collectbox{\@adjbox@halign{#1}{#2}{#3}}%
}
\def\@adjbox@halign#1#2#3{%
\begingroup
\adjsetlength\@tempdima{#1}%
\leavevmode\hb@xt@\the\@tempdima{#2\BOXCONTENT#3}%
\endgroup
}
\define@adjboxkey@defvalue{center}{\linewidth}{\adjbox@halign{#1}\hss\hss}
\define@adjboxkey@defvalue{left}{\linewidth}{\adjbox@halign{#1}\relax\hss}
\define@adjboxkey@defvalue{right}{\linewidth}{\adjbox@halign{#1}\hss\relax}
\newcommand\centerbox[1][\linewidth]{%
\adjustbox@noindent
\adjbox@halign{#1}\hss\hss
}
\newcommand\leftalignbox[1][\linewidth]{%
\adjustbox@noindent
\adjbox@halign{#1}\relax\hss
}
\newcommand\rightalignbox[1][\linewidth]{%
\adjustbox@noindent
\adjbox@halign{#1}\hss\relax
}
\define@adjboxkey@defvalue{outer}{\linewidth}{%
\outersidebox[{#1}]%
}
\define@adjboxkey@defvalue{inner}{\linewidth}{%
\innersidebox[{#1}]%
}
\newcommand\outersidebox[1][\linewidth]{%
\collectboxcheckenv{outersidebox}%
\adjustbox@noindent
\adjbox@halign{#1}{%
\checkoddpage
\ifoddpageoroneside
\hss
\else
\relax
\fi
}{%
\ifoddpageoroneside
\relax
\else
\hss
\fi
}%
}
\newcommand\innersidebox[1][\linewidth]{%
\collectboxcheckenv{innersidebox}%
\adjustbox@noindent
\adjbox@halign{#1}{%
\checkoddpage
\ifoddpageoroneside
\relax
\else
\hss
\fi
}{%
\ifoddpageoroneside
\hss
\else
\relax
\fi
}%
}
\IfFileExists{ifoddpage.sty}{%
\RequirePackage{ifoddpage}%
}{%
\renewcommand\outersidebox[1][]{%
\PackageError{adjustbox}{%
The 'outer' and 'inner' keys as well as the\MessageBreak
\string\outersidebox\space and \string\innersidebox\space macros\MessageBreak
require the 'ifoddpage' package, which is not\MessageBreak
installed}{}%
}%
\let\innersidebox\outersidebox
}%
\define@key\adjbox@fam{raise}{%
\@ifnextchar\bgroup{%
\adjbox@raise
}{%
\adjbox@raise{#1}{}{}%
}#1{}{}{}\@nnil
}
\def\adjbox@raise#1#2#3#4\@nnil{%
\adjbox@Gin@Add{\adjbox@raisebox{#1}{#2}{#3}}%
}
\def\adjbox@raisebox#1#2#3{%
\@collectbox{\adjbox@@raisebox{#1}{#2}{#3}}%
}
\def\adjbox@@raisebox#1#2#3{%
\ifx\@nnil#1\@nnil
\setbox\@tempboxa\copy\collectedbox
\else
\adjsetlength\@tempdima{#1}%
\setbox\@tempboxa\hbox{\raise\@tempdima\copy\collectedbox}%
\fi
\ifx\@nnil#2\@nnil\else
\adjsetlength\@tempdima{#2}%
\ht\@tempboxa\@tempdima
\fi
\ifx\@nnil#3\@nnil\else
\adjsetlength\@tempdima{#3}%
\dp\@tempboxa\@tempdima
\fi
\leavevmode
\box\@tempboxa
}
\define@key\adjbox@fam{valign}{%
\expandafter\adjbox@Gin@Add\expandafter{\csname adjbox@valign@#1\endcsname}%
}
\def\adjboxvtop{\ht\strutbox}
\def\adjboxvcenter{1ex}
\def\adjboxvbottom{-\dp\strutbox}
\def\adjbox@valign@t{%
\adjbox@raisebox{-\height+\adjboxvtop}{}{}%
}
\def\adjbox@valign@T{%
\adjbox@raisebox{-\height}{}{}%
}
\def\adjbox@valign@M{%
\adjbox@raisebox{.5\depth-.5\height}{}{}%
}
\def\adjbox@valign@m{%
\adjbox@raisebox{.5\depth-.5\height+\adjboxvcenter}{}{}%
}
\def\adjbox@valign@c#1{%
\leavevmode
\hbox{%
$\vcenter{\hbox{#1}}\m@th$%
}%
}
\def\adjbox@valign@b{%
\adjbox@raisebox{\depth+\adjboxvbottom}{}{}%
}
\def\adjbox@valign@B{%
\adjbox@raisebox{\depth}{}{}%
}
\define@adjboxkey{set height}{\adjbox@raisebox{}{#1}{}}
\define@adjboxkey{set depth}{\adjbox@raisebox{}{}{#1}}
\define@adjboxkey{set vsize}{\adjbox@raisebox{}#1}
\define@key\adjbox@fam{vspace}{%
\adjbox@vskip#1 {} \@nnil{}%
}
\define@key\adjbox@fam{vspace*}{%
\adjbox@vskip#1 {} \@nnil*%
}
\def\adjbox@vskip#1 #2 #3\@nnil#4{%
\ifx\@nnil#2\@nnil
\adjust@addcode{\par\vspace#4{#1}\noindent}{\par\vspace#4{#1}}%
\else
\adjust@addcode{\par\vspace#4{#1}\noindent}{\par\vspace#4{#2}}%
\fi
}
\define@adjboxkey{min width}{\@minsizebox\height{#1}!}
\define@adjboxkey{max width}{\@maxsizebox\height{#1}!}
\define@adjboxkey{min height}{\@minsizebox\height!{#1}}
\define@adjboxkey{max height}{\@maxsizebox\height!{#1}}
\define@adjboxkey{min totalheight}{\@minsizebox\totalheight!{#1}}
\define@adjboxkey{max totalheight}{\@maxsizebox\totalheight!{#1}}
\def\adjbox@Gin@sizeadd#1#2\@nnil{%
\@ifnextchar\bgroup{%
\adjbox@Gin@Add{#1#2}%
\remove@to@nnil
}{%
\adjbox@Gin@Add{#1{#2}{#2}}%
\remove@to@nnil
}#2\@nnil
}
\define@key\adjbox@fam{min size}{%
\adjbox@Gin@sizeadd{\@minsizebox\height}#1\@nnil
}
\define@key\adjbox@fam{max size}{%
\adjbox@Gin@sizeadd{\@maxsizebox\height}#1\@nnil
}
\define@key\adjbox@fam{min totalsize}{%
\adjbox@Gin@sizeadd{\@minsizebox\totalheight}#1\@nnil
}
\define@key\adjbox@fam{max totalsize}{%
\adjbox@Gin@sizeadd{\@maxsizebox\totalheight}#1\@nnil
}
\define@adjboxkey@defvalue{warn width}{\linewidth}{\@Collectbox{\adjbox@warnwidth{#1}}}
\def\adjbox@warnwidth#1{%
\@tempdima=#1\relax
\advance\@tempdima by -\width
\@tempdima=-\@tempdima
\ifdim\@tempdima>\hfuzz
\typeout{Overfull \string\hbox\space (\the\@tempdima\space too wide) in adjustbox at
\ifnum\adjbox@line=\inputlineno
line \adjbox@line
\else
lines \adjbox@line--\the\inputlineno
\fi
}%
\fi
\BOXCONTENT
}
\newcommand*\minsizebox{%
\collectboxcheckenv{minsizebox}%
\@ifstar{\@minsizebox\totalheight}{\@minsizebox\height}%
}
\expandafter\newcommand\expandafter*\csname minsizebox*\endcsname{%
\@collectboxisenv{minsizebox*}%
\@minsizebox\totalheight
}
\newcommand*\@minsizebox[3]{%
\@collectbox{\@minmaxsizebox>#1{#2}{#3}}%
}
\newcommand*\maxsizebox{%
\collectboxcheckenv{maxsizebox}%
\@ifstar{\@maxsizebox\totalheight}{\@maxsizebox\height}%
}
\expandafter\newcommand\expandafter*\csname maxsizebox*\endcsname{%
\@collectboxisenv{maxsizebox*}%
\@maxsizebox\totalheight
}
\newcommand*\@maxsizebox[3]{%
\@collectbox{\@minmaxsizebox<#1{#2}{#3}}%
}
\newcommand*\@minmaxsizebox[4]{%
\edef\@tempa{#3}%
\edef\@tempb{#4}%
\ifcase0%
\ifx\@tempa\Gin@exclamation
\ifx\@tempb\Gin@exclamation
\else
\ifdim\@tempb#1#2%
1%
\fi
\fi
\else
\ifx\@tempb\Gin@exclamation
\ifdim\@tempa#1\width
2%
\fi
\else
\ifdim\@tempa#1\width
\ifdim\@tempb#1#2%
3%
\else
2%
\fi
\else
\ifdim\@tempb#1#2%
1%
\fi
\fi
\fi
\fi
\relax% 0
\BOXCONTENT
\or
\adjsetlength\@tempdima\@tempb
\Gscale@div\@tempa\@tempdima#2%
\Gscale@box\@tempa[\@tempa]\BOXCONTENT
\or
\adjsetlength\@tempdima\@tempa
\Gscale@div\@tempa\@tempdima\width
\Gscale@box\@tempa[\@tempa]\BOXCONTENT
\or
\adjsetlength\@tempdima\@tempa
\Gscale@div\@tempa\@tempdima\width
\adjsetlength\@tempdima\@tempb
\Gscale@div\@tempb\@tempdima#2%
\ifdim\@tempa\p@#1\@tempb\p@
\let\@tempb\@tempa
\else
\let\@tempa\@tempb
\fi
\Gscale@box\@tempa[\@tempb]\BOXCONTENT
\fi
}
\define@key\adjbox@fam{frame}[{{\fboxrule}}]{%
\adjbox@frame{\fboxsep\z@}#1 {} {} \relax\relax\@nnil
}
\define@key\adjbox@fam{fbox}[{{\fboxrule}}]{%
\adjbox@frame{}#1 {} {} {} \relax\relax\@nnil
}
\def\adjbox@frame#1#2 #3 #4 #5\relax{%
\adjbox@Gin@Add{%
\@Collectbox{#1\adjbox@@frame{}{#2}{#3}{#4}}%
}%
\remove@to@nnil
}
\define@key\adjbox@fam{cframe}{%
\adjbox@checkcolor
\adjbox@cframe{\fboxsep\z@}#1 {} {} {} \relax\relax\@nnil
}
\define@key\adjbox@fam{cfbox}{%
\adjbox@checkcolor
\adjbox@cframe{}#1 {} {} {} \relax\relax\@nnil
}
\def\adjbox@cframe#1#2 #3 #4 #5 #6\relax{%
\adjbox@Gin@Add{%
\@Collectbox{#1\adjbox@@frame{\color{#2}}{#3}{#4}{#5}}%
}%
\remove@to@nnil
}
\def\adjbox@checkcolor{%
\ifcase0%
\expandafter\ifx\csname ver@xcolor.sty\endcsname\relax
\expandafter\ifx\csname ver@color.sty\endcsname\relax
\expandafter\ifx\csname ver@xxcolor.sty\endcsname\relax 1\fi\fi\fi
\relax
\global\let\adjbox@checkcolor\relax
\else
\PackageError{adjustbox}{Using a macro, environment or key with color\MessageBreak
requires a color package to be loaded manually.\MessageBreak
Recommended is 'xcolor' but 'color' is ok, too}{}.
\fi
}
\def\adjbox@@frame#1#2#3#4{%
\ifx\@nnil#2\@nnil\else
\adjsetlength\fboxrule{#2}%
\fi
\ifx\@nnil#3\@nnil\else
\adjsetlength\fboxsep{#3}%
\fi
\adjsetlength\tc@llx{\fboxrule + \fboxsep}%
\@marginbox\collectedbox\tc@llx\tc@llx\tc@llx\tc@llx
\ifx\@nnil#4\@nnil\else
\setbox\collectedbox
\fi
\hbox\bgroup\color@setgroup
\BOXCONTENT
\hskip-\width
#1%
\adjbox@boxframe\width\height\depth
\color@endgroup\egroup
\ifx\@nnil#4\@nnil\else
\adjsetlength\tc@llx{#4}%
\@marginbox\collectedbox\tc@llx\tc@llx\tc@llx\tc@llx
\BOXCONTENT
\fi
}
\let\adjbox@boxframe\boxframe
\providecommand\adjbox@boxframe[3]{%
\hbox{%
\dimen@ #2%
\advance \dimen@ #3\relax
\lower #3\vbox {%
\hrule \@height \fboxrule
\@tempdima -0.5\fboxrule
\ifodd\fboxrule
\advance \@tempdima \m@ne sp
\fi
\kern \@tempdima
\hbox {%
\advance \dimen@ -\fboxrule
\vrule \@width \fboxrule \@height \dimen@ \@depth \z@
\@tempdima #1%
\advance \@tempdima -\tw@ \fboxrule
\kern \@tempdima
\vrule \@width \fboxrule \@height \dimen@ \@depth \z@
}%
\kern -0.5\fboxrule
\hrule \@height \fboxrule
}%
}%
}
\define@key\adjbox@fam{dpi}{%
\adjsetlength\pdfpxdimen{1in/(#1)}%
}
\define@key\adjbox@fam{pxdim}{%
\adjsetlength\pdfpxdimen{#1}%
}
\define@key\adjbox@fam{execute}{%
#1%
}
\define@key\adjbox@fam{@debug}[]{%
\showthe\toks@
}
\define@key{ADJBOX}{Execute}{%
#1%
}
\define@key{adjbox}{Addcode}{%
\adjust@@addcode#1{}\@nnil%
}
\define@key{adjbox}{addcode}{%
\Gin@esetsize
\@tempswatrue
\adjust@@addcode#1{}\@nnil%
}
\long\def\adjust@@addcode#1#2#3\@nnil{%
\ifx\@nnil#3\@nnil
\adjust@addcode{#1}{#2}%
\else
\PackageError{adjustbox}{Incorrect input for key 'addcode={<code before>}{<code afterwards>}'!}%
\fi
}
\define@key{adjbox}{precode}{%
\Gin@esetsize
\@tempswatrue
\adjust@addcode{#1}{}%
}
\define@key{adjbox}{Precode}{%
\adjust@addcode{#1}{}%
}
\define@key{adjbox}{appcode}{%
\toks@\expandafter{\the\toks@#1}%
}
\long\def\adjust@addcode#1#2{%
\def\@tempa{#1}%
\toks@\expandafter\expandafter\expandafter{\expandafter\@tempa\expandafter{\the\toks@}#2}%
}%
\define@key\adjbox@fam{env}{%
\@ifnextchar\bgroup{%
\adjbox@addenv
}{%
\adjbox@addenv{#1}\@nnil%
\remove@to@nnil
}#1\@nnil
}
\def\adjbox@addenv#1#2\@nnil{%
\def\@tempa{\begin{#1}#2}%
\toks@\expandafter\expandafter\expandafter{\expandafter\@tempa\the\toks@\end{#1}}%
}%
\define@key\adjbox@fam{bgcolor}{%
\adjbox@checkcolor
\@ifnextchar\bgroup{%
\adjbox@bgcolor
}{%
\adjbox@bgcolor{}{#1}%
}#1\@nnil
}
\def\adjbox@bgcolor#1#2#3\@nnil{%
\ifx\@nnil#1\@nnil
\adjbox@Gin@add{\@Collectbox{\adjbox@@bgcolor{\color{#2}}}}%
\else
\adjbox@Gin@add{\@Collectbox{\adjbox@@bgcolor{\color[#1]{#2}}}}%
\fi
}
\define@key\adjbox@fam{bgcolor*}{%
\adjbox@checkcolor
\adjbox@Gin@add{\@Collectbox{\adjbox@@bgcolor{#1}}}%
}
\def\adjbox@@bgcolor#1{%
\mbox{%
\hbox{%
#1%
\vrule\@width\width\@height\height\@depth\depth%
}%
\hskip-\width
\BOXCONTENT
}%
}%
\newcommand*\bgimagebox[2][]{%
\collectboxcheckenv{bgimagebox}%
\@collectbox{\@bgimagebox{#1}{#2}}%
}
\def\@bgimagebox#1#2{%
\mbox{%
\lower\depth\hbox{%
\edef\@tempa{\noexpand\adjustimage
{#1,width=\the\width,totalheight=\the\totalheight}%
{#2}%
}%
\@tempa
}%
\hskip-\width%
\BOXCONTENT
}%
}
\define@key{adjbox}{bgimage}{%
\@ifnextchar\bgroup{%
\adjbox@bgimage
}{%
\adjbox@bgimage{}{#1}%
}#1\@nnil
}
\def\adjbox@bgimage#1#2#3\@nnil{%
\adjbox@Gin@add{\@Collectbox{\@bgimagebox{#1}{#2}}}%
}
\define@key\adjbox@fam{lap}{%
\@ifnextchar\bgroup{%
\adjbox@lapbox
}{%
\adjbox@lapbox{#1}{}%
}#1{}{}\@nnil
}
\def\adjbox@lapbox#1#2#3\@nnil{%
\ifx\@nnil#2\@nnil
\adjbox@Gin@Add{\lapbox{#1}}%
\else
\adjbox@Gin@Add{\lapbox[{#1}]{#2}}%
\fi
}
\define@key\adjbox@fam{rlap}[]{%
\adjbox@Gin@Add{\lapbox{\width}}%
}
\define@key\adjbox@fam{llap}[]{%
\adjbox@Gin@Add{\lapbox{-\width}}%
}
\newcommand*\lapbox[2][\width-\@tempdimb]{%
\collectboxcheckenv{lapbox}%
\@collectbox{\@lapbox{#1}{#2}}%
}
\def\@lapbox#1#2{%
\adjsetlength\@tempdima{#2}%
\ifdim\@tempdima<\z@
\@tempdimb=-\@tempdima
\else
\@tempdimb=\@tempdima
\fi
\adjsetlength\@tempdimc{#1}%
\ifdim\@tempdimc<\z@
\@tempdimc=\z@
\fi
\leavevmode
\ifdim\@tempdima<\z@
\hb@xt@\@tempdimc{\hss\hb@xt@\@tempdimb{\usebox\collectedbox\hss}\hskip\@tempdimc}%
\else
\hb@xt@\@tempdimc{\hskip\@tempdimc\hb@xt@\@tempdimb{\hss\usebox\collectedbox}\hss}%
\fi
}
\define@key{ADJBOX}{minipage}{%
\adjbox@page{minipage}{#1}%
}
\define@key{ADJBOX}{varwidth}{%
\adjbox@page{varwidth}{#1}%
}
\def\adjbox@page#1#2{%
\@ifnextchar[{%
\adjbox@@page{#1}%
}{%
\@ifnextchar\bgroup{%
\adjbox@@page{#1}%
}{%
\adjbox@@page{#1}{{#2}}\@nnil%
\remove@to@nnil
}%
}#2\@nnil
}
\def\adjbox@@page#1#2\@nnil{%
\def\adjbox@collectbox##1{\collectbox@{\adjbox@set\begin{#1}#2\adjbox@reset}{##1}{\end{#1}}}%
}
\def\adjbox@set{%
\let\adjbox@origsetlength\setlength
\def\setlength{\adjsetlength}%
}
\def\adjbox@reset{%
\let\setlength\adjbox@origsetlength
}
\newcommand*\stackbox[1][c]{%
\collectboxcheckenv{stackbox}%
\@ifnextchar[%]
{\@stackbox{#1}}%
{\@@stackbox{#1}{b}[]}%
}
\def\@stackbox#1[#2]{%
\@testopt{\@@stackbox{#1}{#2}}{}%
}
\def\@@stackbox#1#2[#3]{%
\collectbox@
{\begin{varwidth}[#2]{\linewidth}\csname adjbox@halign@#1\endcsname#3}
\BOXCONTENT
{\end{varwidth}}%
}
\def\adjbox@halign@c{\centering}
\def\adjbox@halign@l{\raggedright}
\def\adjbox@halign@r{\raggedleft}
\def\adjbox@halign@j{\let\\\newline}
\define@key{ADJBOX}{stack}[{}{}{}]{%
\adjbox@stack#1{}{}{}\@nnil
}
\def\adjbox@stack#1#2#3#4\@nnil{%
\ifx\@nnil#1\@nnil
\adjbox@@stack{c}{b}{}%
\else
\ifx\@nnil#2\@nnil
\adjbox@@stack{#1}{b}{}%
\else
\adjbox@@stack{#1}{#2}{#3}%
\fi\fi
}
\def\adjbox@@stack#1#2#3{%
\def\adjbox@collectbox##1{%
\collectbox@{%
\begin{varwidth}[#2]{\linewidth}%
\csname adjbox@halign@#1\endcsname#3%
}{##1}{\end{varwidth}}%
}%
}
\IfFileExists{varwidth.sty}
{\RequirePackage{varwidth}}{%
\define@key{ADJBOX}{varwidth}{%
\PackageError{adjustbox}{The 'varwidth' key requires the 'varwidth' package, which is not installed}{}%
}
\define@key{ADJBOX}{stack}{%
\PackageError{adjustbox}{The 'stack' key requires the 'varwidth' package, which is not installed}{}%
}
}%
\define@key{ADJBOX}{tabular}{%
\@ifnextchar[{%
\adjbox@tabular{tabular}%
}{%
\adjbox@tabular{tabular}{{#1}}\@nnil%
\remove@to@nnil
}#1\@nnil
}
\def\adjbox@tabular#1#2\@nnil{%
\ifcollectboxenv
\adjbox@innerenv{#1}{#2}\@nnil
\else
\def\adjbox@collectbox##1{\collectbox@tab{#1}{#2}{}{##1}{}}%
\fi
}
\define@key{ADJBOX}{tabular*}{%
\adjbox@tabular{tabular*}#1\@nnil
}
\define@key{ADJBOX}{array}{%
\@ifnextchar[{%
\adjbox@array%
}{%
\adjbox@array{{#1}}\@nnil%
\remove@to@nnil
}#1\@nnil
}
\def\adjbox@array#1\@nnil{%
\ifcollectboxenv
\adjbox@innercode{\(\begin{array}#1}{\end{array}\)}%
\else
\def\adjbox@collectbox##1{\collectbox@tab{array}{#1}{\(}{##1}{\)}}%
\fi
}
\define@key{ADJBOX}{innerenv}{%
\@ifnextchar\bgroup{%
\adjbox@@innerenv
}{%
\adjbox@innerenv{#1}\@nnil%
\remove@to@nnil
}#1\@nnil
}
\def\adjbox@innerenv#1#2\@nnil{%
\def\adjbox@collectbox##1{\collectbox@{\begin{#1}#2}{##1}{\end{#1}}}%
}%
\def\adjbox@@innerenv#1{%
\adjbox@@@innerenv{#1}{}%
}%
\def\adjbox@@@innerenv#1#2\@nnil{%
\expandafter\adjbox@@@@innerenv\expandafter{\@gobble#2}{#1}%
}%
\def\adjbox@@@@innerenv#1#2{%
\adjbox@innerenv{#2}{#1}\@nnil
}%
\define@key{ADJBOX}{innercode}{%
\adjbox@innercode#1{}{}%
}
\def\adjbox@innercode#1#2{%
\def\adjbox@collectbox##1{\collectbox@{#1}{##1}{#2}}%
}%
\define@key\adjbox@fam{label}{%
\def\adjbox@label{\label{#1}}%
}
\let\adjbox@label\@empty
\chardef\adjbox@caption@pos=11
\define@key\adjbox@fam{captionabove}{%
\chardef\adjbox@caption@pos=1
\csname KV@\adjbox@fam @caption\endcsname{#1}%
}
\define@key\adjbox@fam{captionbelow}{%
\chardef\adjbox@caption@pos=0
\csname KV@\adjbox@fam @caption\endcsname{#1}%
}
\define@key\adjbox@fam{caption}{%
\@ifnextchar{[}{%
\adjbox@def@caption
}{%
\adjbox@def@@caption
}#1\@nnil
}
\def\adjbox@def@@caption#1\@nnil{%
\def\adjbox@caption{\caption{#1}}%
}
\def\adjbox@def@caption[#1]#2\@nnil{%
\def\adjbox@caption{\caption[#1]{#2}}%
}
\let\adjbox@caption\@empty
\define@key\adjbox@fam{figure}[]{%
\let\adjustbox@noindent\relax
\ifx\@nnil#1\@nnil
\adjbox@addfloat{figure}{\begin{figure}}{}{\end{figure}}%
\else
\adjbox@addfloat{figure}{\begin{figure}}{[{#1}]}{\end{figure}}%
\fi
}
\define@key\adjbox@fam{float}{%
\let\adjustbox@noindent\relax
\@ifnextchar\bgroup{%
\adjbox@float
}{%
\adjbox@float{#1}{}\@nnil
\remove@to@nnil
}#1\@nnil
}
\def\adjbox@float#1#2\@nnil{%
\adjbox@addfloat{#1}{\begin{#1}}{#2}{\end{#1}}%
}
\define@key\adjbox@fam{nofloat}[figure]{%
\adjbox@addfloat{#1}{\adjnofloat}{{#1}}{\endadjnofloat}%
}
\def\adjbox@caption@table@pos{1}
\def\adjbox@addfloat#1#2#3#4{%
\ifnum\adjbox@caption@pos>10
\chardef\adjbox@caption@pos=0\csname adjbox@caption@#1@pos\endcsname\relax
\fi
\ifcase\adjbox@caption@pos
\def\@tempa{\adjust@addcode{#2#3}}%
\expandafter\expandafter\expandafter\@tempa
\expandafter\expandafter\expandafter{\expandafter\adjbox@caption\adjbox@label#4}%
\else
\def\@tempa##1{\adjust@addcode{#2#3\adjbox@captionabove##1}}%
\expandafter\expandafter\expandafter\@tempa
\expandafter\expandafter\expandafter
{\expandafter\adjbox@caption\adjbox@label}{#4}%
\fi
}
\@ifpackageloaded{caption}{%
\let\adjbox@captionabove\relax
}{%
\def\adjbox@captionabove{%
\begingroup
\edef\@tempa{\endgroup
\abovecaptionskip=\the\belowcaptionskip\relax
\belowcaptionskip=\the\abovecaptionskip\relax
}%
\@tempa
}%
\AtBeginDocument{%
\@ifpackageloaded{caption}{%
\global\let\adjbox@captionabove\relax
}{}%
}%
}
\newenvironment{adjnofloat}[1]{%
\trivlist
\def\@captype{#1}%
\parindent\z@
\item\relax
}{%
\endtrivlist
}
\define@key\adjbox@fam{phantom}[]{%
\expandafter\ifx\csname #1phantom\endcsname\relax
\adjust@addcode{\phantom}{}%
\else
\expandafter\adjust@addcode\expandafter{\csname #1phantom\endcsname}{}%
\fi
}
\newcommand*\phantombox[3]{%
\begingroup
\adjsetlength\@tempdima{#1}%
\adjsetlength\@tempdimb{#2}%
\adjsetlength\@tempdimc{#3}%
\setbox\collectedbox\hbox{}%
\wd\collectedbox\@tempdima
\ht\collectedbox\@tempdimb
\dp\collectedbox\@tempdimc
\leavevmode
\box\collectedbox
\endgroup
}
\define@key\adjbox@fam{gobble}[\@nil]{%
\adjbox@novalue{#1}%
\let\adjustbox@noindent\relax
\adjbox@Gin@Add{\@Collectbox{}}%
}
\adjbox@let@key\adjbox@fam{discard}{gobble}%
\define@adjboxkey{content}{\@Collectbox{#1}}%
\define@adjboxkey{gstore}{\global\@collectboxto{#1}{\BOXCONTENT}}
\define@key\adjbox@fam{gstore*}{%
\let\adjustbox@noindent\relax
\adjbox@Gin@Add{\global\sbox{#1}}%
}
\define@key{adjbox}{gstore width}{%
\adjbox@Gin@Add{\@Collectbox{\global#1=\width\BOXCONTENT}}%
}
\define@key{adjbox}{gstore depth}{%
\adjbox@Gin@Add{\@Collectbox{\global#1=\depth\BOXCONTENT}}%
}
\define@key{adjbox}{gstore height}{%
\adjbox@Gin@Add{\@Collectbox{\global#1=\height\BOXCONTENT}}%
}
\define@key{adjbox}{gstore totalheight}{%
\adjbox@Gin@Add{\@Collectbox{\global#1=\totalheight\BOXCONTENT}}%
}
\define@key{adjbox}{gstore sizes}{%
\adjbox@Gin@Add{\@Collectbox{\adjbox@gstore@sizes#1\relax\relax\relax\relax\@nnil\BOXCONTENT}}%
}
\def\adjbox@gstore@sizes#1#2#3#4#5\@nnil{%
\ifx\relax#1\relax\else
\global#1=\width
\fi
\ifx\relax#2\relax\else
\global#2=\height
\fi
\ifx\relax#3\relax\else
\global#3=\depth
\fi
\ifx\relax#4\relax\else
\global#4=\totalheight
\fi
}
%%\RequirePackage{storebox}
\newcommand\splitbox[2]{%
\collectboxcheckenv{splitbox}%
\@collectbox{\@splitbox{#1}{#2}}%
}
\define@adjboxkey{split}{\@Collectbox{\@splitbox#1}}
\def\@splitbox#1#2{%
\ifstorebox
\storebox\splittedbox{\BOXCONTENT}%
\setbox\collectedbox\hbox{\usestorebox\splittedbox}%
\fi
\xdef\@tempa{#1}%
\xdef\@tempb{#2}%
\ifx\@tempa\Gin@exclamation
\@tempdima\maxdimen
\else
\adjsetlength\@tempdima\@tempa
\fi
\ifx\@tempb\Gin@exclamation
\Gin@nat@height\maxdimen
\else
\adjsetlength\Gin@nat@height\@tempb
\fi
\ifdim\@tempdima>\width
\@tempdima\width
\fi
\ifdim\Gin@nat@height>\totalheight
\Gin@nat@height\totalheight
\fi
\tc@llx\z@
\tc@lly\totalheight
\tc@urx\width
\tc@ury\z@
\advance\tc@lly-\Gin@nat@height
\@@splitbox
}
\def\@@splitbox{%
\advance\tc@urx-\@tempdima
\@@@splitbox
\ifdim\tc@urx>\z@
\advance\tc@llx+\@tempdima
\expandafter\@@splitbox
\else
\ifdim\tc@lly<\splitbox@epsilon
\splitboxlastnewline
\else
\splitboxnewline
\tc@llx\z@
\tc@urx\width
\advance\tc@lly-\Gin@nat@height
\advance\tc@ury+\Gin@nat@height
\expandafter\expandafter
\expandafter\@@splitbox
\fi
\fi
}
\def\@@@splitbox{%
\begingroup
\setbox\collectedbox=\copy\collectedbox
\@clipbox\collectedbox\tc@llx\tc@lly\tc@urx\tc@ury
\splitboxcmd{\usebox\collectedbox}%
\endgroup
}
\def\@@@splitbox{%
\begingroup
\setbox\collectedbox=\copy\collectedbox
\@clipbox\collectedbox\tc@llx\tc@lly\tc@urx\tc@ury
\splitboxcmd{\usebox\collectedbox}%
\endgroup
}
\let\splitboxcmd\empty
\newcommand\splitboxnewline{\\}
\newcommand\splitboxlastnewline{\splitboxnewline}
\def\splitbox@epsilon{100sp}
\newcommand\pagebreakbox{%
\par\noindent
\collectboxcheckenv{pagebreakbox}%
\@collectbox{\@pagebreakbox}%
}
\define@key\adjbox@fam{pagebreak}[]{%
\adjbox@Gin@Add{\@Collectbox{\@pagebreakbox}}%
}
\def\@pagebreakbox{%
\sbox\collectedbox{\raise\dp\collectedbox\hbox{\BOXCONTENT}}%
\ifstorebox
\storebox\splittedbox{\BOXCONTENT}%
\setbox\collectedbox\hbox{\usestorebox\splittedbox}%
\fi
\adjsetlength\tc@lly
{\totalheight-\pagegoal+\pagetotal+\pagebreakboxoffset}%
\ifdim\tc@lly>\z@
\begingroup
\setbox\collectedbox=\copy\collectedbox
\@clipbox\collectedbox\z@\tc@lly\z@\z@
\BOXCONTENT
\endgroup
\par\noindent
\adjsetlength\tc@ury{\totalheight-\tc@lly}%
\ifdim\tc@lly>\textheight
\loop
\advance\tc@lly-\textheight
\begingroup
\setbox\collectedbox=\copy\collectedbox
\@clipbox\collectedbox\z@\tc@lly\z@\tc@ury
\BOXCONTENT
\endgroup
\advance\tc@ury\textheight
\par\noindent
\ifdim\tc@lly>\textheight
\repeat
\@clipbox\collectedbox\z@\z@\z@\tc@ury
\BOXCONTENT
\else
\@clipbox\collectedbox\z@\z@\z@\tc@ury
\par\noindent
\BOXCONTENT
\fi
\else
\BOXCONTENT%
\fi
\par
}
\newcommand*\pagebreakboxoffset{\ht\strutbox}
\endinput
%%
%% End of file `adjustbox.sty'.