%% Copyright (C) 2011-2022 by Martin Scharrer %% ------------------------------------------------------------------- %% 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}[% 2022/10/17 v1.3a Adjusting TeX boxes (trim, clip, ...)] \RequirePackage{xkeyval} \RequirePackage{adjcalc} \def\adjbox@fam{adjbox} \DeclareOptionX{export}{\def\adjbox@fam{Gin}} \DeclareOptionX{Export}{\AtEndOfPackage{\let\includegraphics\adjincludegraphics}} \DeclareOptionX{patch}{% \PackageWarning{adjustbox}{% The 'patch' option is now deprecated.\MessageBreak Use the new \string\adjustimage\space or \string\adjincludegraphics\space macros instead% \@gobble }% } \DeclareOptionX{minimal}{\let\adjustbox@minimal\endinput} \DeclareOptionX{pgfmath}{\AtEndOfPackage{\RequirePackage{pgf}\adjcalcset{pgfmath}}} \DeclareOptionX{calc}{\AtEndOfPackage{\RequirePackage{calc}\adjcalcset{calc}}} \DeclareOptionX{etex}{\AtEndOfPackage{\adjcalcset{etex}}} \DeclareOptionX{defaultunit}{\AtEndOfPackage{\adjcalcset{defaultunit={#1}}}} \DeclareOptionX{pgf}{\PassOptionsToPackage{pgf}{trimclip}} \DeclareOptionX{PGF}{\PassOptionsToPackage{pgf}{trimclip}\AtEndOfPackage{\RequirePackage{pgf}\adjcalcset{pgfmath}}} \DeclareOptionX{draft}{\PassOptionsToPackage{draft}{graphicx}} \DeclareOptionX{final}{\PassOptionsToPackage{final}{graphicx}} \DeclareOptionX{hiderotate}{\PassOptionsToPackage{hiderotate}{graphicx}} \DeclareOptionX{hidescale}{\PassOptionsToPackage{hidescale}{graphicx}} \DeclareOptionX{hiresbb}{\PassOptionsToPackage{hiresbb}{graphicx}} \DeclareOptionX{demo}{\PassOptionsToPackage{demo}{graphicx}} \DeclareOptionX*{% \IfFileExists{tc-\CurrentOption.def}{% \PassOptionsToPackage\CurrentOption{trimclip}% }{% \PassOptionsToPackage\CurrentOption{graphicx}% }% } \ProcessOptionsX*\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{% \begingroup \collectboxcheckenv{adjustbox}% \@adjustbox } \long\def\@adjustbox#1{% \edef\adjbox@line{\the\inputlineno}% \let\collectbox@mode\relax \let\collectbox@noindent\relax \let\adjbox@collectbox\@collectbox \let\adjbox@begininnercode\@empty \let\adjbox@endinnercode\@empty \chardef\adjbox@innerlevel\z@ \ifcollectboxenv \let\adjustbox@noindent\noindent \let\adjustbox@unskip\unskip \let\adjustbox@ignorespaces\ignorespaces \else \let\adjustbox@noindent\relax \let\adjustbox@unskip\relax \let\adjustbox@ignorespaces\relax \fi \let\XKV@checksanitizea\adjbox@kvsanitize \adjbox@setkeys{#1}% \expandafter \adjbox@collectbox\expandafter{\expandafter\adjustbox@\expandafter{\XKV@rm}}% } \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}% } \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 } \begingroup \catcode`\, 3 \catcode`\= 3 \gdef\adjbox@comma@iii{,}% \gdef\adjbox@equal@iii{=}% \catcode`\, 4 \catcode`\= 4 \gdef\adjbox@comma@iv{,}% \gdef\adjbox@equal@iv{=}% \catcode`\, 7 \catcode`\= 7 \gdef\adjbox@comma@vii{,}% \gdef\adjbox@equal@vii{=}% \catcode`\, 8 \catcode`\= 8 \gdef\adjbox@comma@viii{,}% \gdef\adjbox@equal@viii{=}% \catcode`\, 10 \catcode`\= 10 \gdef\adjbox@comma@x{,}% \gdef\adjbox@equal@x{=}% \catcode`\, 11 \catcode`\= 11 \gdef\adjbox@comma@xi{,}% \gdef\adjbox@equal@xi{=}% \catcode`\, 13 \catcode`\= 13 \gdef\adjbox@comma@xiii{,}% \gdef\adjbox@equal@xiii{=}% \catcode`\, 12 \catcode`\= 12 \gdef\adjbox@comma@xii{,}% \gdef\adjbox@equal@xii{=}% \gdef\adjbox@kvsanitize#1#2{% \def\@tempa{\expandafter\noexpand\adjbox@comma@xiii}% \def\@tempb{}% \ifnum\catcode`\,=12 \else \ifnum\catcode`\,=13 \else \@ifundefined{adjbox@comma@\romannumeral\catcode`\,}{% \PackageError{adjustbox} {Invalid comma catcode \the\catcode`\,}{}% }{}% \edef\@tempb{\csname adjbox@comma@\romannumeral\the\catcode`\,\endcsname}% \fi \fi \edef\@tempa{\@tempa\@tempb}% \XKV@tempa@toks{#1}% \expandafter\adjbox@replacecatcodes\expandafter,\@tempa\@nnil \def\@tempa{\expandafter\noexpand\adjbox@equal@xiii}% \def\@tempb{}% \ifnum\catcode`\==12 \else \ifnum\catcode`\==13 \else \@ifundefined{adjbox@equal@\romannumeral\catcode`\=}{% \PackageError{adjustbox} {Invalid equal sign catcode \the\catcode`\=}{}% }{}% \def\@tempb{\@tempa\csname adjbox@equal@\romannumeral\the\catcode`\,\endcsname}% \fi \fi \edef\@tempa{\@tempa\@tempb}% \expandafter\adjbox@replacecatcodes\expandafter=\@tempa\@nnil \edef#2{\the\XKV@tempa@toks}% } \gdef\adjbox@replacecatcodes#1#2{% \ifx\@nnil#2\relax\else \def\@tempa##1#2{% \ifx\@nnil##1\relax\else \XKV@tempa@toks{##1}% \expandafter\@tempb \fi }% \def\@tempb##1#2{% \ifx\@nnil##1\relax\else \XKV@tempa@toks\expandafter{\the\XKV@tempa@toks#1##1}% \expandafter\@tempb \fi }% \expandafter\@tempa\the\XKV@tempa@toks#2\@nnil#2\relax \expandafter\adjbox@replacecatcodes\expandafter#1% \fi } \endgroup \def\adjustbox@content{% \usebox\collectedbox } \def\smallestside{\ifdim\width<\totalheight \width\else\totalheight\fi}% \def\largestside{\ifdim\width>\totalheight \width\else\totalheight\fi}% \def\Smallestside{\ifdim\Width<\Totalheight \Width\else\Totalheight\fi}% \def\Largestside{\ifdim\Width>\Totalheight \Width\else\Totalheight\fi}% \newdimen\adjbox@Width \newdimen\adjbox@Height \newdimen\adjbox@Depth \newdimen\adjbox@Totalheight \newdimen\adjbox@pwidth \newdimen\adjbox@pheight \newdimen\adjbox@pdepth \newdimen\adjbox@ptotalheight \def\adjbox@parentdims{% \let\pwidth\adjbox@pwidth \let\pheight\adjbox@pheight \let\pdepth\adjbox@pdepth \let\ptotalheight\adjbox@ptotalheight \pwidth\width \pheight\height \pdepth\depth \ptotalheight\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} \newcommand*\newadjustboxenv{% \begingroup \@ifstar{% \let\@@@newadjustboxenv\@@@newadjustboxenv@ \def\new@adjustbox{\newenvironment}% \newadjustboxenv@ }{% \def\new@adjustbox{\newcommand}% \newadjustboxenv@ }% } \newcommand*\renewadjustboxenv{% \begingroup \@ifstar{% \let\@@@newadjustboxenv\@@@newadjustboxenv@ \def\new@adjustbox{\renewenvironment}% \newadjustboxenv@ }{% \def\new@adjustbox{\renewcommand}% \newadjustboxenv@ }% } \newcommand*\provideadjustboxenv{% \begingroup \@ifstar{% \let\@@@newadjustboxenv\@@@newadjustboxenv@ \def\new@adjustbox{\@star@or@long\adjustbox@provideenvironment}% \newadjustboxenv@ }{% \def\new@adjustbox{\providecommand}% \newadjustboxenv@ }% } \newcommand*\declareadjustboxenv{% \begingroup \@ifstar{% \let\@@@newadjustboxenv\@@@newadjustboxenv@ \def\new@adjustbox##1{% \expandafter\let\csname ##1\endcsname\@undefined \newenvironment{##1}% }% \newadjustboxenv@ }{% \def\new@adjustbox##1{% \let##1\@undefined \newcommand{##1}% }% \newadjustboxenv@ }% } \newcommand*\newadjustboxcmd{% \begingroup \let\@@@newadjustboxenv\@@@newadjustboxcmd \def\new@adjustbox{\newcommand}% \newadjustboxenv@ } \newcommand*\renewadjustboxcmd{% \begingroup \let\@@@newadjustboxenv\@@@newadjustboxcmd \def\new@adjustbox{\renewcommand}% \newadjustboxenv@ } \newcommand*\provideadjustboxcmd{% \begingroup \let\@@@newadjustboxenv\@@@newadjustboxcmd \def\new@adjustbox{\providecommand}% \newadjustboxenv@ } \newcommand*\declareadjustboxcmd{% \begingroup \let\@@@newadjustboxenv\@@@newadjustboxcmd \def\new@adjustbox##1{\let##1\@undefined\newcommand{##1}}% \newadjustboxenv@ } \def\adjustbox@provideenvironment#1{% \@ifundefined{#1}% {\new@environment{#1}}% {\adjustbox@gobble@oomm}% } \newcommand*\adjustbox@gobble@oomm[1][]{% \adjustbox@gobble@@oomm } \newcommand*\adjustbox@gobble@@oomm[3][]{% } \def\newadjustboxenv@#1{% \@ifnextchar{[}% {\@newadjustboxenv{#1}}% {\@@@newadjustboxenv{#1}{[0]}}% } \def\@newadjustboxenv#1[#2]{% \@ifnextchar{[}% {\@@newadjustboxenv{#1}{#2}}% {\@@@newadjustboxenv{#1}{[#2]}}% } \def\@@newadjustboxenv#1#2[#3]{% \@@@newadjustboxenv{#1}{[#2][#3]}% } \def\@@@newadjustboxenv@#1#2#3{% \expandafter \endgroup \new@adjustbox{#1}#2{% \begingroup \@collectboxisenv{#1}% \@adjustbox{#3}% }{% \collectboxenvend }% } \def\@@@newadjustboxenv#1#2#3{% \expandafter \endgroup \expandafter \expandafter\new@adjustbox\csname #1\endcsname#2{% \begingroup \collectboxcheckenv{#1}% \@adjustbox{#3}% }% } \def\@@@newadjustboxcmd#1#2#3{% \expandafter \endgroup \new@adjustbox{#1}#2{% \begingroup \@adjustbox{#3}% }% } \newcommand*\newadjustimage{% \begingroup \let\@@@newadjustboxenv\@@@newadjustimage \def\new@adjustbox{\newcommand}% \newadjustboxenv@ } \newcommand*\renewadjustimage{% \begingroup \let\@@@newadjustboxenv\@@@newadjustimage \def\new@adjustbox{\renewcommand}% \newadjustboxenv@ } \newcommand*\provideadjustimage{% \begingroup \let\@@@newadjustboxenv\@@@newadjustimage \def\new@adjustbox{\providecommand}% \newadjustboxenv@ } \newcommand*\declareadjustimage{% \begingroup \let\@@@newadjustboxenv\@@@newadjustimage \def\new@adjustbox##1{\let##1\@undefined\newcommand{##1}}% \newadjustboxenv@ } \def\@@@newadjustimage#1#2#3{% \expandafter \endgroup \new@adjustbox{#1}#2{% \begingroup \def\@tempa####1{% \def\IMAGEFILENAME{####1}% \@adjustbox{#3}{\Gin@clipfalse\expandafter\Gin@i\expandafter{\IMAGEFILENAME}}% }% \@tempa }% } \newcommand*\adjustbox@NewAdjustImage[4]{% \adjustbox@checkforxparse #1{#2}{#3}{% \begingroup \def\@tempa####1{% \def\IMAGEFILENAME{####1}% \@adjustbox{#4}{\Gin@clipfalse\expandafter\Gin@i\expandafter{\IMAGEFILENAME}}% }% \@tempa }% } \newcommand*\NewAdjustImage{% \adjustbox@NewAdjustImage\NewDocumentCommand } \newcommand*\RenewAdjustImage{% \adjustbox@NewAdjustImage\RenewDocumentCommand } \newcommand*\ProvideAdjustImage{% \adjustbox@NewAdjustImage\ProvideDocumentCommand } \newcommand*\DeclareAdjustImage{% \adjustbox@NewAdjustImage\ProvideDocumentCommand } \def\adjustbox@checkforxparse{% \begingroup \expandafter\ifx\csname ver@xparse.sty\endcsname\relax \PackageError{adjustbox}{% The 'xparse' package must be loaded separately in\MessageBreak order to use the following macros: \MessageBreak \string\NewAdjustImage, \string\RenewAdjustImage, \MessageBreak \string\ProvideAdjustImage, \string\DeclareAdjustImage}{} \fi \endgroup \let\adjustbox@checkforxparse\relax } \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 } \def\adjbox@copy@key#1{% \expandafter\let \csname KV@ADJBOX@#1\expandafter\endcsname \csname KV@Gin@#1\endcsname \expandafter\let \csname KV@ADJBOX@#1@default\expandafter\endcsname \csname KV@Gin@#1@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{rndcorners}{\rndcornersbox@{#1}} \define@adjboxkey{rndframe}{% \@ifnextchar\bgroup{% \adjbox@rndframe{sep=\z@}% }{% \adjbox@rndframe{sep=\z@}{}% }#1\@nnil } \define@adjboxkey{rndfbox}{% \@ifnextchar\bgroup{% \adjbox@rndframe{}% }{% \adjbox@rndframe{}{}% }#1\@nnil } \def\adjbox@rndframe#1#2#3\@nnil{% \rndfbox[{#1,#2}]{#3}% } \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*} \adjbox@copy@key{bbllx} \adjbox@copy@key{bblly} \adjbox@copy@key{bburx} \adjbox@copy@key{bbury} \adjbox@copy@key{bb} \adjbox@copy@key{command} \adjbox@copy@key{decodearray} \adjbox@copy@key{draft} \adjbox@copy@key{ext} \adjbox@copy@key{intent} \adjbox@copy@key{interpolate} \adjbox@copy@key{maskarray} \adjbox@copy@key{natheight} \adjbox@copy@key{natwidth} \adjbox@copy@key{ocobjnum} \adjbox@copy@key{ocobjref} \adjbox@copy@key{origin} \adjbox@copy@key{pagebox} \adjbox@copy@key{page} \adjbox@copy@key{quiet} \adjbox@copy@key{read} \adjbox@copy@key{resetcolor} \adjbox@copy@key{resolution} \adjbox@copy@key{type} \adjbox@copy@key{xmpfile} \newcommand\rndcornersbox{% \collectboxcheckenv{rndcornersbox}% \rndcornersbox@ } \def\rndcornersbox@#1{% \collectbox{\@trimclip\@clipcornersofbox{#1}}% } \newcommand\rndframebox{% \collectboxcheckenv{rndframebox}% \rndframebox@ } \newcommand*\rndframebox@[2][]{% \collectbox{\@trimclip{\rndframearoundbox@{sep=\z@,#1}}{#2}}% } \newcommand\rndfbox{% \collectboxcheckenv{rndfbox}% \rndfbox@ } \newcommand*\rndfbox@[2][]{% \collectbox{\@trimclip{\rndframearoundbox@{#1}}{#2}}% } \newif\ifadjbox@rndframe@clip \def\rndframearoundbox@#1#2#3#4#5#6{% \setkeys{adjbox@rndframe}{#1}% \@rndframearoundbox{#2}{#3}{#4}{#5}{#6}{\ifadjbox@rndframe@clip\relax\fi}% } \define@key{adjbox@rndframe}{width}{% \adjsetlength\fboxrule{#1}% } \define@key{adjbox@rndframe}{sep}{% \adjsetlength\fboxsep{#1}% } \define@key{adjbox@rndframe}{color}{% \def\adjbox@rndframe@color{\color{#1}}% } \define@key{adjbox@rndframe}{color*}{% \def\adjbox@rndframe@color{#1}% } \let\adjbox@rndframe@color\relax \define@key{adjbox@rndframe}{clip}[true]{% \csname adjbox@rndframe@clip#1\endcsname } \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]{% \collectboxcheckenv{centerbox}% \noindent \adjbox@halign{#1}\hss\hss } \newcommand\leftalignbox[1][\linewidth]{% \collectboxcheckenv{leftalignbox}% \noindent \adjbox@halign{#1}\relax\hss } \newcommand\rightalignbox[1][\linewidth]{% \collectboxcheckenv{rightalignbox}% \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}% \noindent \adjbox@halign{#1}{% \checkoddpage \ifoddpageoroneside \hss \else \relax \fi }{% \ifoddpageoroneside \relax \else \hss \fi }% } \newcommand\innersidebox[1][\linewidth]{% \collectboxcheckenv{innersidebox}% \noindent \adjbox@halign{#1}{% \checkoddpage \ifoddpageoroneside \relax \else \hss \fi }{% \ifoddpageoroneside \hss \else \relax \fi }% } \define@key\adjbox@fam{pagecenter}[\linewidth]{% \noindent\leavevmode \adjbox@Gin@Add{\pagecenterbox[{#1}]}% }% \define@key\adjbox@fam{pageleftalign}[\linewidth]{% \noindent\leavevmode \adjbox@Gin@Add{\pageleftalignbox[{#1}]}% }% \define@key\adjbox@fam{pagerightalign}[\linewidth]{% \noindent\leavevmode \adjbox@Gin@Add{\pagerightalignbox[{#1}]}% }% \define@key\adjbox@fam{pageinner}[\linewidth]{% \noindent\leavevmode \adjbox@Gin@Add{\pageinnerbox[{#1}]}% } \define@key\adjbox@fam{pageouter}[\linewidth]{% \noindent\leavevmode \adjbox@Gin@Add{\pageouterbox[{#1}]}% } \define@key\adjbox@fam{textareacenter}[\linewidth]{% \noindent\leavevmode \adjbox@Gin@Add{\textareacenterbox[{#1}]}% }% \define@key\adjbox@fam{textarealeftalign}[\linewidth]{% \noindent\leavevmode \adjbox@Gin@Add{\textarealeftalignbox[{#1}]}% }% \define@key\adjbox@fam{textarearightalign}[\linewidth]{% \noindent\leavevmode \adjbox@Gin@Add{\textarearightalignbox[{#1}]}% }% \define@key\adjbox@fam{textareainner}[\linewidth]{% \noindent\leavevmode \adjbox@Gin@Add{\textareainnerbox[{#1}]}% } \define@key\adjbox@fam{textareaouter}[\linewidth]{% \noindent\leavevmode \adjbox@Gin@Add{\textareaouterbox[{#1}]}% } \newcommand\pagecenterbox[1][\linewidth]{% \collectboxcheckenv{pagecenterbox}% \noindent\leavevmode\checkoddpage \@collectbox{\@pagecenterbox{#1}{-1in-\hoffset-\ifoddpage\oddsidemargin\else\evensidemargin\fi+.5\paperwidth-.5\@tempdimc-\@totalleftmargin}}% } \def\@pagecenterbox#1#2{% \adjsetlength\@tempdimc{#1}% \ifdim\@tempdimc<\z@ \@tempdimc=\z@ \fi \adjsetlength\@tempdima{#2}% \ifdim\@tempdima<\z@ \@tempdimb=-\@tempdima \else \@tempdimb=\@tempdima \fi \ifdim\@tempdima<\z@ \hb@xt@\@tempdimc{\hss\hb@xt@\@tempdimb{\hb@xt@\@tempdimc{\hss\usebox\collectedbox\hss}\hss}\hskip\@tempdimc}% \else \hb@xt@\@tempdimc{\hskip\@tempdimc\hb@xt@\@tempdimb{\hss\hb@xt@\@tempdimc{\hss\usebox\collectedbox\hss}}\hss}% \fi } \newcommand\textareacenterbox[1][\linewidth]{% \collectboxcheckenv{textareacenterbox}% \noindent\leavevmode \@collectbox{\@pagecenterbox{#1}{-\@totalleftmargin+.5\textwidth-.5\linewidth}}% } \newcommand\pageleftalignbox[1][\linewidth]{% \collectboxcheckenv{pageleftalignbox}% \noindent\leavevmode\checkoddpage \@collectbox{\@lapbox{#1}{-1in-\hoffset-\ifoddpage\oddsidemargin\else\evensidemargin\fi-\@totalleftmargin}}% } \newcommand\pagerightalignbox[1][\linewidth]{% \collectboxcheckenv{pagerightalignbox}% \noindent\leavevmode\checkoddpage \@collectbox{\@lapbox{#1}{-1in-\hoffset-\ifoddpage\oddsidemargin\else\evensidemargin\fi-\@totalleftmargin+\paperwidth-(#1)}}% } \newcommand\textarealeftalignbox[1][\linewidth]{% \collectboxcheckenv{textarealeftalignbox}% \noindent\leavevmode\checkoddpage \@collectbox{\@textarealeftalignbox{#1}}% } \def\@textarealeftalignbox#1{% \adjsetlength\@tempdima{\@totalleftmargin}% \adjsetlength\@tempdimc{#1}% \ifdim\@tempdimc<\z@ \@tempdimc=\z@ \fi \leavevmode \hb@xt@\@tempdimc{\hss\hb@xt@\@tempdima{\usebox\collectedbox\hss}\hskip\@tempdimc}% } \newcommand\textarearightalignbox[1][\linewidth]{% \collectboxcheckenv{textarearightalignbox}% \noindent\leavevmode\checkoddpage \@collectbox{\@textarearightalignbox{#1}{+\textwidth}}% } \def\@textarearightalignbox#1#2{% \adjsetlength\@tempdimc{#1}% \ifdim\@tempdimc<\z@ \@tempdimc=\z@ \fi \adjsetlength\@tempdima{-\@totalleftmargin+\textwidth-\@tempdimc}% \ifdim\@tempdima<\z@ \@tempdima=-\@tempdima \fi \leavevmode \hb@xt@\@tempdimc{\hskip\@tempdimc\hb@xt@\@tempdima{\hss\usebox\collectedbox}\hss}% } \newcommand\pageinnerbox{% \noindent\leavevmode\checkoddpage \ifoddpageoroneside \expandafter\pageleftalignbox \else \expandafter\pagerightalignbox \fi }% \newcommand\pageouterbox{% \noindent\leavevmode\checkoddpage \ifoddpageoroneside \expandafter\pagerightalignbox \else \expandafter\pageleftalignbox \fi }% \newcommand\textareainnerbox{% \noindent\leavevmode\checkoddpage \ifoddpageoroneside \expandafter\textarealeftalignbox \else \expandafter\textarearightalignbox \fi }% \newcommand\textareaouterbox{% \noindent\leavevmode\checkoddpage \ifoddpageoroneside \expandafter\textarearightalignbox \else \expandafter\textarealeftalignbox \fi }% \IfFileExists{ifoddpage.sty}{% \RequirePackage{ifoddpage}% }{% \def\checkoddpage{% \PackageError{adjustbox}{% The used key, macro or environment requires \MessageBreak the 'ifoddpage' package which is not installed!}{}% } }% \define@key\adjbox@fam{noindent}[]{% \noindent } \define@key\adjbox@fam{leavevmode}[]{% \leavevmode } \define@key\adjbox@fam{process}[]{% \sbox\collectedbox{\adjbox@esetsize\the\toks@}% \collectbox@setdims \def\adjustbox@content{\usebox\collectedbox}% \toks@{{\adjustbox@content}} } \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}% \ifx\@tempa\Gin@exclamation\else \adjsetlength\@tempdima{#3}% \fi \ifx\@tempb\Gin@exclamation\else \adjsetlength\@tempdimb{#4}% \fi \ifcase0% \ifx\@tempa\Gin@exclamation \ifx\@tempb\Gin@exclamation \else \ifdim\@tempdimb#1#2% 1% \fi \fi \else \ifx\@tempb\Gin@exclamation \ifdim\@tempdima#1\width 2% \fi \else \ifdim\@tempdima#1\width \ifdim\@tempdimb#1#2% 3% \else 2% \fi \else \ifdim\@tempdimb#1#2% 1% \fi \fi \fi \fi \relax% 0 \BOXCONTENT \or \Gscale@div\@tempa\@tempdimb#2% \Gscale@box\@tempa[\@tempa]\BOXCONTENT \or \Gscale@div\@tempa\@tempdima\width \Gscale@box\@tempa[\@tempa]\BOXCONTENT \or \Gscale@div\@tempa\@tempdima\width \Gscale@div\@tempb\@tempdimb#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{% \leavevmode \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={}{}'!}% \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}{color}{% \adjbox@checkcolor \@ifnextchar\bgroup{% \adjbox@color }{% \adjbox@color{}{#1}% }#1\@nnil } \def\adjbox@color#1#2#3\@nnil{% \ifx\@nnil#1\@nnil \color{#2}% \else \color[{#1}]{#2}% \fi } \define@key{ADJBOX}{color*}{% #1% } \define@key{ADJBOX}{fgcolor}{% \adjbox@checkcolor \@ifnextchar\bgroup{% \adjbox@fgcolor }{% \adjbox@fgcolor{}{#1}% }#1\@nnil } \def\adjbox@fgcolor#1#2#3\@nnil{% \ifx\@nnil#1\@nnil \adjbox@innercode{\color{#2}}{}% \else \adjbox@innercode{\color[{#1}]{#2}}{}% \fi } \define@key{ADJBOX}{fgcolor*}{% \adjbox@checkcolor \adjbox@innercode{#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{\@bgcolorbox{\color{#2}}}}% \else \adjbox@Gin@add{\@Collectbox{\@bgcolorbox{\color[#1]{#2}}}}% \fi } \define@key\adjbox@fam{bgcolor*}{% \adjbox@checkcolor \adjbox@Gin@add{\@Collectbox{\@bgcolorbox{#1}}}% } \def\@bgcolorbox#1{% \leavevmode \hbox{% \hbox{% #1% \vrule\@width\width\@height\height\@depth\depth% }% \hskip-\width \BOXCONTENT }% }% \expandafter\newcommand\expandafter\bgcolorbox\expandafter{% \expandafter \@ifstar \csname bgcolorbox*\endcsname \bgcolorbox@ } \newcommand\bgcolorbox@[2][\@nnil]{% \collectboxcheckenv{bgcolorbox}% \ifx\@nnil#1\relax \expandafter\@firstoftwo \else \expandafter\@secondoftwo \fi {\@collectbox{\@bgcolorbox{\color{#2}}}}% {\@collectbox{\@bgcolorbox{\color[#1]{#2}}}}% } \@namedef{bgcolorbox*}#1{% \collectboxcheckenv{bgcolorbox*}% \@collectbox{\@bgcolorbox{#1}}% } \expandafter\newcommand\expandafter\fgimagebox\expandafter{% \expandafter \@ifstar \csname fgimagebox*\endcsname \fgimagebox@ } \newcommand\fgimagebox@[2][]{% \collectboxcheckenv{fgimagebox}% \@collectbox{\@foregroundbox\adjustimage{#1,width=\pwidth,totalheight=\ptotalheight,raise=-\pdepth}{#2}}% } \expandafter\newcommand\csname fgimagebox*\endcsname[2][]{% \collectboxcheckenv{fgimagebox*}% \@collectbox{\@foregroundbox\adjustimage{#1}{#2}}% } \define@key{adjbox}{fgimage}{% \@ifnextchar\bgroup{% \adjbox@fgimage }{% \adjbox@fgimage{}{#1}% }#1{}\@nnil {,width=\pwidth,totalheight=\ptotalheight,raise=-\pdepth}% } \define@key{adjbox}{fgimage*}{% \@ifnextchar\bgroup{% \adjbox@fgimage }{% \adjbox@fgimage{}{#1}% }#1{}\@nnil{}% } \def\adjbox@fgimage#1#2#3\@nnil#4{% \adjbox@Gin@Add{\@Collectbox{\@foregroundbox\adjustimage{#1#4}{#2}}}% } \expandafter\newcommand\expandafter\bgimagebox\expandafter{% \expandafter \@ifstar \csname bgimagebox*\endcsname \bgimagebox@ } \newcommand\bgimagebox@[2][]{% \collectboxcheckenv{bgimagebox}% \@collectbox{\@backgroundbox\adjustimage{#1,width=\pwidth,totalheight=\ptotalheight,raise=-\pdepth}{#2}}% } \expandafter\newcommand\csname bgimagebox*\endcsname[2][]{% \collectboxcheckenv{bgimagebox*}% \@collectbox{\@backgroundbox\adjustimage{#1}{#2}}% } \define@key{adjbox}{bgimage}{% \@ifnextchar\bgroup{% \adjbox@bgimage }{% \adjbox@bgimage{}{#1}% }#1{}\@nnil {,width=\pwidth,totalheight=\ptotalheight,raise=-\pdepth}% } \define@key{adjbox}{bgimage*}{% \@ifnextchar\bgroup{% \adjbox@bgimage }{% \adjbox@bgimage{}{#1}% }#1{}\@nnil{}% } \def\adjbox@bgimage#1#2#3\@nnil#4{% \adjbox@Gin@Add{\@Collectbox{\@backgroundbox\adjustimage{#1#4}{#2}}}% } \define@key{adjbox}{foreground}{% \@ifnextchar\bgroup{% \adjbox@foreground }{% \adjbox@foreground{}{#1}% }#1{}{}\@nnil {,width=\pwidth,totalheight=\ptotalheight,raise=\depth-\pdepth}% } \define@key{adjbox}{foreground*}{% \@ifnextchar\bgroup{% \adjbox@foreground }{% \adjbox@foreground{}{#1}% }#1{}{}\@nnil{}% } \def\adjbox@foreground#1#2#3\@nnil#4{% \adjbox@Gin@Add{\@Collectbox{\@foregroundbox\adjustbox{#1#4}{#2}}}% } \def\@foregroundbox#1#2#3{% \leavevmode \hbox to \width{% \BOXCONTENT \hskip-\width \hss \adjbox@parentdims #1{#2}{#3}% \hss }% } \expandafter\newcommand\expandafter\foregroundbox\expandafter{% \expandafter \@ifstar \csname foregroundbox*\endcsname \foregroundbox@ } \newcommand\foregroundbox@[2][]{% \collectboxcheckenv{foregroundbox}% \@collectbox{\@foregroundbox\adjustbox{#1,width=\pwidth,totalheight=\ptotalheight,raise=-\pdepth}{#2}}% } \expandafter\newcommand\csname foregroundbox*\endcsname[2][]{% \collectboxcheckenv{foregroundbox*}% \@collectbox{\@foregroundbox\adjustbox{#1}{#2}}% } \define@key{adjbox}{background}{% \@ifnextchar\bgroup{% \adjbox@background }{% \adjbox@background{}{#1}% }#1{}{}\@nnil {,width=\pwidth,totalheight=\ptotalheight,raise=\depth-\pdepth}% } \define@key{adjbox}{background*}{% \@ifnextchar\bgroup{% \adjbox@background }{% \adjbox@background{}{#1}% }#1{}{}\@nnil{}% } \def\adjbox@background#1#2#3\@nnil#4{% \adjbox@Gin@Add{\@Collectbox{\@backgroundbox\adjustbox{#1#4}{#2}}}% } \def\@backgroundbox#1#2#3{% \leavevmode \hbox to \width{% \hss \adjbox@parentdims #1{#2}{#3}% \hss \hskip-\width% \BOXCONTENT }% } \expandafter\newcommand\expandafter\backgroundbox\expandafter{% \expandafter \@ifstar \csname backgroundbox*\endcsname \backgroundbox@ } \newcommand\backgroundbox@[2][]{% \collectboxcheckenv{backgroundbox}% \@collectbox{\@backgroundbox\adjustbox{#1,width=\pwidth,totalheight=\ptotalheight,raise=-\pdepth}{#2}}% } \expandafter\newcommand\csname backgroundbox*\endcsname[2][]{% \collectboxcheckenv{backgroundbox*}% \@collectbox{\@backgroundbox\adjustbox{#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}}% } \define@key\adjbox@fam{clap}[]{% \adjbox@Gin@Add{\lapbox[0pt]{-0.5\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{% \adjbox@innercode {\adjbox@set\begin{#1}#2\adjbox@reset\ignorespaces}% {\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\ignorespaces} \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{% \adjbox@innercode{% \begin{varwidth}[#2]{\linewidth}% \csname adjbox@halign@#1\endcsname#3% \ignorespaces }{% \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}{\adjbox@begininnercode}{##1}{\adjbox@endinnercode}}% \fi \chardef\adjbox@innerlevel\tw@ } \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}{\adjbox@begininnercode\(}{##1}{\)\adjbox@endinnercode}}% \fi \chardef\adjbox@innerlevel\tw@ } \define@key{ADJBOX}{innerenv}{% \@ifnextchar\bgroup{% \adjbox@@innerenv }{% \adjbox@innerenv{#1}\@nnil% \remove@to@nnil }#1\@nnil } \adjbox@let@key{ADJBOX}{inner env}{innerenv} \def\adjbox@innerenv#1#2\@nnil{% \adjbox@innercode {\begin{#1}#2}% {\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{}{}% }% \adjbox@let@key{ADJBOX}{inner code}{innercode} \def\adjbox@innercode{% \ifcase\adjbox@innerlevel \relax% 0: first inner code \def\adjbox@collectbox##1{\collectbox@{\adjbox@begininnercode\adjustbox@ignorespaces}{##1}{\adjustbox@unskip\adjbox@endinnercode}}% \chardef\adjbox@innerlevel\@ne \expandafter\adjbox@@innercode \or% 1 append inner code, no inner env \expandafter\adjbox@@innercode \else% 2 inner tabular exists, create warning and ignore content. \PackageWarning{adjustbox}{Further inner code or environment ignored\MessageBreak after "tabular"-like key}% \expandafter\@gobbletwo \fi }% \long\def\adjbox@@innercode#1#2{% \@temptokena\expandafter{\adjbox@begininnercode#1}% \edef\adjbox@begininnercode{\the\@temptokena}% \@temptokena{#2}% \@temptokena\expandafter\expandafter\expandafter{\expandafter\the\expandafter\@temptokena\adjbox@endinnercode}% \edef\adjbox@endinnercode{\the\@temptokena}% } \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{% \Gin@esetsize \@tempswatrue \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 }{}% }% } \def\adjbox@nofloatenv{minipage} \def\adjbox@nofloatcaptionsetup#1{% \@ifundefined{captionsetup}% {\def\@captype{#1}}% {\captionsetup{type={#1}}}% \csname capstart\endcsname } \newenvironment{adjnofloat}[1]{% \par\noindent \minipage{\linewidth}% \adjbox@nofloatcaptionsetup{#1}% }{% \endminipage\par } \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'.