diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/adjustbox/adjustbox.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/adjustbox/adjustbox.sty | 249 |
1 files changed, 181 insertions, 68 deletions
diff --git a/Master/texmf-dist/tex/latex/adjustbox/adjustbox.sty b/Master/texmf-dist/tex/latex/adjustbox/adjustbox.sty index 622fbb7995a..819c1cbbb99 100644 --- a/Master/texmf-dist/tex/latex/adjustbox/adjustbox.sty +++ b/Master/texmf-dist/tex/latex/adjustbox/adjustbox.sty @@ -1,7 +1,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% Copyright (C) 2011 by Martin Scharrer <martin@scharrer-online.de> -%% --------------------------------------------------------------------------- +%% Copyright (C) 2011 by Martin Scharrer <martin@scharrer.me> +%% ------------------------------------------------------------------ %% 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. @@ -18,8 +18,8 @@ %% and the derived file adjustbox.sty. %% \ProvidesPackage{adjustbox}[% - 2011/10/30 - v0.7 + 2011/11/14 + v0.8 Adjusting TeX boxes (trim, clip, ...)] \RequirePackage{xkeyval} \def\adjbox@defaultunit{bp} @@ -34,6 +34,7 @@ } \def\adjbox@fam{adjbox} \DeclareOptionX<adjbox>{export}{\def\adjbox@fam{Gin}} +\DeclareOptionX<adjbox>{Export}{\AtEndOfPackage{\let\includegraphics\adjincludegraphics}} \DeclareOptionX<adjbox>{patch}{\AtEndOfPackage{\RequirePackage{adjgrfx}}} \DeclareOptionX<adjbox>{minimal}{\let\adjbox@maybeend\endinput} \def\adjbox@driver{adj\Gin@driver} @@ -80,23 +81,20 @@ \fi } \let\adjbox@keysafter\@empty -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \define@key{adjbox}{viewport}{% - \def\adjustbox@@@{% + \def\adjustbox@content{% \adjbox@parse@v{#1}% \adjbox@@viewport \adjustbox@@@trimclip }% } \define@key{adjbox}{trim}{% - \def\adjustbox@@@{% + \def\adjustbox@content{% \adjbox@parse@v{#1}% \adjustbox@@@trimclip }% } \def\adjustbox@@@trimclip{% - \Gin@viewport@code \ifGin@clip \expandafter\@clipbox \else @@ -196,7 +194,7 @@ \expandafter \adjbox@collectbox\expandafter{\expandafter\adjustbox@\expandafter{\XKV@rm}}% } -\let\adjbox@collectbox\@collectbox +\def\adjbox@collectbox{\@collectbox} \def\adjbox@setkeys@ba{% \expandafter\expandafter \expandafter\adjbox@@setkeys@ba @@ -211,16 +209,29 @@ \setkeys*{ADJBOX}% } \def\adjustbox@#1{% - \adjustbox@dimcmds + \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 \@tempswatrue - \toks@{{\adjustbox@@@@}}% + \toks@{{\adjustbox@content}}% \def\setlength{\adjsetlength}% \setkeys{adjbox,Gin}{#1}% \adjbox@esetsize \the\toks@ } -\def\adjustbox@@@@{\adjustbox@@@}% +\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 @@ -235,17 +246,11 @@ \let\Gin@eheight\Gin@exclamation \fi } -\def\adjustbox@dimcmds{% - \let\width\relax - \let\height\relax - \let\depth\relax - \let\totalheight\relax -} -\def\adjustbox@@@{% - \usebox\collectedbox -} \newcommand*\adjustimage[2]{% - \adjustbox{#1}{\includegraphics{#2}}% + \adjustbox{#1}{\Gin@clipfalse\Gin@i{#2}}% +} +\newcommand*\adjincludegraphics[2][]{% + \adjustbox{#1}{\Gin@clipfalse\Gin@i{#2}}% } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -273,23 +278,15 @@ } \def\@clipbox#1#2#3#4#5{% \@trimbox{#1}{#2}{#3}{#4}{#5}% - \pdfxform#5% - \setbox#5=\hbox{% - \pdfrefxform\pdflastxform - }% + \@cliptoboxdim{#5}% } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\RequirePackage{ifpdf} \InputIfFileExists{\adjbox@driver}{% \PackageInfo{adjustbox}{Using driver '\adjbox@driver'.}% }{% - \ifpdf - \PackageInfo{adjustbox}{Using default pdftex driver.} - \else - \input{adjpgf.def}% - \PackageInfo{adjustbox}{Using fall-back PGF driver.} - \fi + \input{adjpgf.def}% + \PackageInfo{adjustbox}{Using fall-back PGF driver.} } \adjbox@maybeend %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -409,9 +406,11 @@ \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{% @@ -420,6 +419,17 @@ }% \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, envrionment 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}% @@ -518,6 +528,12 @@ \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{margin}{% \adjbox@Gin@Add{\marginbox@{#1}}% } @@ -533,45 +549,77 @@ \define@key\adjbox@fam{execute}{% #1% } +\define@key\adjbox@fam{@debug}[]{% + \showthe\toks@ +} +\define@key{ADJBOX}{Execute}{% + #1% +} \define@key\adjbox@fam{raise}{% \@ifnextchar\bgroup{% - \adjbox@raisebox + \adjbox@raise }{% - \adjbox@raisebox{#1}{}{}% + \adjbox@raise{#1}{}{}% }#1{}{}{}\@nnil } -\def\adjbox@raisebox#1#2#3#4\@nnil{% - \ifx\@nnil#3\@nnil - \adjbox@Gin@Add{\@irsbox{#1}[{#2}]}% - \else - \adjbox@Gin@Add{\@iirsbox{#1}[{#2}][{#3}]}% - \fi +\def\adjbox@raise#1#2#3#4\@nnil{% + \adjbox@Gin@Add{\adjbox@raisebox{#1}{#2}{#3}}% } \define@key\adjbox@fam{valign}{% \csname adjbox@valign@#1\endcsname } +\def\adjbox@raisebox#1#2#3{% + \collectbox{\adjbox@@raisebox{#1}{#2}{#3}}% +} +\def\adjbox@@raisebox#1#2#3{% + \ifx\@nnil#1\@nnil + \setbox\@tempboxa\box\collectedbox + \else + \adjsetlength\@tempdima{#1}% + \sbox\@tempboxa{\raise\@tempdima\box\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 + \box\@tempboxa +} \def\adjboxvtop{\ht\strutbox} \def\adjboxvcenter{1ex} \def\adjboxvbottom{-\dp\strutbox} \def\adjbox@valign@t{% - \adjbox@Gin@Add{\@irsbox{-\height+\adjboxvtop}[]}% + \adjbox@Gin@Add{\adjbox@raisebox{-\height+\adjboxvtop}{}{}}% } \def\adjbox@valign@T{% - \adjbox@Gin@Add{\@irsbox{-\height}[]}% + \adjbox@Gin@Add{\adjbox@raisebox{-\height}{}{}}% } \def\adjbox@valign@M{% - \adjbox@Gin@Add{\@irsbox{.5\depth-.5\height}[]}% + \adjbox@Gin@Add{\adjbox@raisebox{.5\depth-.5\height}{}{}}% } \def\adjbox@valign@m{% - \adjbox@Gin@Add{\@irsbox{.5\depth-.5\height+\adjboxvcenter}[]}% + \adjbox@Gin@Add{\adjbox@raisebox{.5\depth-.5\height+\adjboxvcenter}{}{}}% +} +\def\adjbox@valign@c{% + \adjbox@Gin@Add{\@collectbox\adjbox@vcenter}% +} +\def\adjbox@vcenter{% + \leavevmode + \hbox{% + $\vcenter{\hbox{\BOXCONTENT}}\m@th$ + }% } \def\adjbox@valign@b{% - \adjbox@Gin@Add{\@irsbox{\depth+\adjboxvbottom}[]}% + \adjbox@Gin@Add{\adjbox@raisebox{\depth+\adjboxvbottom}{}{}}% } \def\adjbox@valign@B{% - \adjbox@Gin@Add{\@irsbox{\depth}[]}% + \adjbox@Gin@Add{\adjbox@raisebox{\depth}{}{}}% } \define@key\adjbox@fam{bgcolor}{% + \adjbox@checkcolor \@ifnextchar\bgroup{% \adjbox@bgcolor }{% @@ -579,27 +627,34 @@ }#1\@nnil } \def\adjbox@bgcolor#1#2#3\@nnil{% - \adjbox@Gin@add{\@collectbox{\adjbox@@bgcolor{#1}{#2}}}% + \ifx\@nnil#1\@nnil + \adjbox@Gin@add{\@collectbox{\adjbox@@bgcolor{\color{#2}}}}% + \else + \adjbox@Gin@add{\@collectbox{\adjbox@@bgcolor{\color[#1]{#2}}}}% + \fi } -\def\adjbox@@bgcolor#1#2{% +\define@key\adjbox@fam{bgcolor*}{% + \adjbox@checkcolor + \adjbox@Gin@add{\@collectbox{\adjbox@@bgcolor{#1}}}% +} +\def\adjbox@@bgcolor#1{% \mbox{% \hbox{% - \ifx\@nnil#1\@nnil - \color{#2}% - \else - \color[#1]{#2}% - \fi - \vrule\@width\width\@height\height\@depth\depth + #1% + \vrule\@width\width\@height\height\@depth\depth% }% \hskip-\width \BOXCONTENT }% }% \define@key\adjbox@fam{set height}{% - \adjbox@Gin@Add{\@irsbox\z@[{#1}]}% + \adjbox@Gin@Add{\adjbox@raisebox{}{#1}{}}% } \define@key\adjbox@fam{set depth}{% - \adjbox@Gin@Add{\@iirsbox\z@[\height][{#1}]}% + \adjbox@Gin@Add{\adjbox@raisebox{}{}{#1}}% +} +\define@key\adjbox@fam{set vsize}{% + \adjbox@Gin@Add{\adjbox@raisebox{}#1}% } \def\adjbox@Gin@add#1{% \def\@tempa{#1}% @@ -783,15 +838,25 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \define@key{ADJBOX}{minipage}{% + \adjbox@page{minipage}{#1}% +} +\define@key{ADJBOX}{varwidth}{% + \adjbox@page{varwidth}{#1}% +} +\def\adjbox@page#1#2{% \@ifnextchar[{% - \adjbox@minipage% + \adjbox@@page{#1}% }{% - \adjbox@minipage{{#1}}\@nnil% - \remove@to@nnil - }#1\@nnil + \@ifnextchar\bgroup{% + \adjbox@@page{#1}% + }{% + \adjbox@@page{#1}{{#2}}\@nnil% + \remove@to@nnil + }% + }#2\@nnil } -\def\adjbox@minipage#1\@nnil{% - \def\adjbox@collectbox##1{\collectbox@{\adjbox@set\begin{minipage}#1\adjbox@reset}{##1}{\end{minipage}}}% +\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 @@ -800,6 +865,45 @@ \def\adjbox@reset{% \let\setlength\adjbox@origsetlength } +\newcommand*\stackbox[1][c]{% + \collectboxcheckenv{stackbox}% + \@testopt{\@stackbox{#1}}{b}% +} +\def\@stackbox#1[#2]{% + \collectbox@ + {\begin{varwidth}[#2]{\linewidth}\csname adjbox@halign@#1\endcsname} + \BOXCONTENT + {\end{varwidth}}% +} +\define@key{ADJBOX}{stack}[{}{}]{% + \adjbox@stack#1{}{}\@nnil +} +\def\adjbox@stack#1#2#3\@nnil{% + \ifx\@nnil#1\@nnil + \adjbox@@stack{c}{b}% + \else + \ifx\@nnil#2\@nnil + \adjbox@@stack{#1}{b}% + \else + \adjbox@@stack{#1}{#2}% + \fi\fi +} +\def\adjbox@@stack#1#2{% + \def\adjbox@collectbox##1{\collectbox@{\begin{varwidth}[#2]{\linewidth}\csname adjbox@halign@#1\endcsname}{##1}{\end{varwidth}}}% +} +\def\adjbox@halign@c{\centering} +\def\adjbox@halign@l{\raggedright} +\def\adjbox@halign@r{\raggedleft} +\def\adjbox@halign@j{\let\\\newline} +\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}% @@ -835,7 +939,7 @@ } \define@key{ADJBOX}{innerenv}{% \@ifnextchar\bgroup{% - \adjbox@innerenv + \adjbox@@innerenv }{% \adjbox@innerenv{#1}\@nnil% \remove@to@nnil @@ -844,6 +948,15 @@ \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{}{}% } @@ -900,8 +1013,8 @@ \def\@bgimagebox#1#2{% \mbox{% \lower\depth\hbox{% - \edef\@tempa{\noexpand\includegraphics% - [#1,width=\the\width,totalheight=\the\totalheight]% + \edef\@tempa{\noexpand\adjustimage + {#1,width=\the\width,totalheight=\the\totalheight}% {#2}% }% \@tempa @@ -920,7 +1033,7 @@ \def\adjbox@bgimage#1#2#3\@nnil{% \adjbox@Gin@add{\@collectbox{\@bgimagebox{#1}{#2}}}% } -\RequirePackage{storebox} +%%\RequirePackage{storebox} \newcommand\splitbox[2]{% \collectboxcheckenv{splitbox}% \@collectbox{\@splitbox{#1}{#2}}% |