From d429ad262261b593689d81ac6db8bdaf16c6b2b2 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 13 Aug 2011 22:19:43 +0000 Subject: adjustbox (13aug11) git-svn-id: svn://tug.org/texlive/trunk@23541 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/adjustbox/README | 22 + .../texmf-dist/doc/latex/adjustbox/adjustbox.pdf | Bin 533393 -> 258702 bytes Master/texmf-dist/source/latex/adjustbox/Makefile | 83 - Master/texmf-dist/source/latex/adjustbox/README | 47 - .../source/latex/adjustbox/adjustbox.dtx | 2914 ++++++++++++++++++-- .../source/latex/adjustbox/adjustbox.ins | 13 +- Master/texmf-dist/tex/latex/adjustbox/adjcalc.sty | 113 + Master/texmf-dist/tex/latex/adjustbox/adjgrfx.sty | 172 ++ Master/texmf-dist/tex/latex/adjustbox/adjpgf.def | 46 + .../texmf-dist/tex/latex/adjustbox/adjustbox.sty | 837 +++++- 10 files changed, 3753 insertions(+), 494 deletions(-) create mode 100644 Master/texmf-dist/doc/latex/adjustbox/README delete mode 100644 Master/texmf-dist/source/latex/adjustbox/Makefile delete mode 100644 Master/texmf-dist/source/latex/adjustbox/README create mode 100644 Master/texmf-dist/tex/latex/adjustbox/adjcalc.sty create mode 100644 Master/texmf-dist/tex/latex/adjustbox/adjgrfx.sty create mode 100644 Master/texmf-dist/tex/latex/adjustbox/adjpgf.def diff --git a/Master/texmf-dist/doc/latex/adjustbox/README b/Master/texmf-dist/doc/latex/adjustbox/README new file mode 100644 index 00000000000..9fae3a001e6 --- /dev/null +++ b/Master/texmf-dist/doc/latex/adjustbox/README @@ -0,0 +1,22 @@ +LaTeX package 'adjustbox' +~~~~~~~~~~~~~~~~~~~~~~~~~ +Copyright (c) 2011 by Martin Scharrer +WWW: https://bitbucket.org/martin_scharrer/adjustbox (incl. bug tracker) + +This package provides several macros to adjust boxed content. +One purpose is to supplement the standard 'graphics' package, which defines the macros +\resizebox, \scalebox and \rotatebox, with the macros \trimbox and \clipbox. +The main feature is the general \adjustbox macro which extends the key=value +interface of \includegraphics from the 'graphicx' package, and applies it to general text +content. +Additional provided box macros are \lapbox, \marginbox, \minsizebox, \maxsizebox and \phantombox. + +All macros use the authors other package 'collectbox' to read the content as box and not as +macro argument. This allows for all forms of content including special material like verbatim content. +A special feature of 'collectbox' is used to provide matching environments with the identical names as the +macros. + +The clipping operation is output driver dependend. At the moment the package provides +native support for 'pdflatex'. For other output drivers the 'pgf' package is used as a general +fall-back for all clipping operations. + diff --git a/Master/texmf-dist/doc/latex/adjustbox/adjustbox.pdf b/Master/texmf-dist/doc/latex/adjustbox/adjustbox.pdf index 5af7f86d5f0..30af267f008 100644 Binary files a/Master/texmf-dist/doc/latex/adjustbox/adjustbox.pdf and b/Master/texmf-dist/doc/latex/adjustbox/adjustbox.pdf differ diff --git a/Master/texmf-dist/source/latex/adjustbox/Makefile b/Master/texmf-dist/source/latex/adjustbox/Makefile deleted file mode 100644 index bdabf1310b8..00000000000 --- a/Master/texmf-dist/source/latex/adjustbox/Makefile +++ /dev/null @@ -1,83 +0,0 @@ -TEXMF=${HOME}/texmf -INSTALLDIR=${TEXMF}/tex/latex/adjustbox -DOCINSTALLDIR=${TEXMF}/doc/latex/adjustbox -CP=cp -RMDIR=rm -rf -PDFLATEX=pdflatex -interaction=batchmode -LATEXMK=latexmk -pdf -silent - -PACKEDFILES=adjustbox.sty -DOCFILES=adjustbox.pdf -#adjustbox-de.pdf -SRCFILES=adjustbox.dtx adjustbox.ins README Makefile - -all: unpack doc - -package: unpack -class: unpack - -${PACKEDFILES}: adjustbox.dtx adjustbox.ins - yes | pdflatex adjustbox.ins - -unpack: ${PACKEDFILES} - -doc: ${DOCFILES} - -pdfopt: doc - @-pdfopt adjustbox.pdf .temp.pdf && mv .temp.pdf adjustbox.pdf - @-pdfopt adjustbox-de.pdf .temp.pdf && mv .temp.pdf adjustbox-de.pdf - -adjustbox.pdf: adjustbox.dtx - ${LATEXMK} $< - -adjustbox-de.pdf: adjustbox-de.tex adjustbox.dtx - ${LATEXMK} $< - -adjustbox.tex: unpack - -.PHONY: test - -test: unpack - for T in test*.tex; do echo "$$T"; pdflatex -interaction=batchmode $$T && echo "OK" || echo "Failure"; done - -clean: - -latexmk -C adjustbox.dtx - -latexmk -C adjustbox-de.tex - ${RM} ${PACKEDFILES} *.zip *.log *.aux *.toc *.vrb *.nav *.pdf *.snm *.out *.fdb_latexmk *.glo *.gls *.hd *.sta *.stp *.cod - ${RMDIR} tds - -install: unpack doc ${INSTALLDIR} ${DOCINSTALLDIR} - ${CP} ${PACKEDFILES} ${INSTALLDIR} - ${CP} ${DOCFILES} ${DOCINSTALLDIR} - texhash ${TEXMF} - -${INSTALLDIR}: - mkdir -p $@ - -${DOCINSTALLDIR}: - mkdir -p $@ - -ctanify: ${SRCFILES} ${DOCFILES} adjustbox.tds.zip - ${RM} adjustbox.zip - zip adjustbox.zip $^ - unzip -t adjustbox.zip - unzip -t adjustbox.tds.zip - -zip: adjustbox.zip - -tdszip: adjustbox.tds.zip - -adjustbox.zip: ${SRCFILES} ${DOCFILES} | pdfopt - ${RM} $@ - zip $@ $^ - -adjustbox.tds.zip: ${SRCFILES} ${PACKEDFILES} ${DOCFILES} | pdfopt - ${RMDIR} tds - mkdir -p tds/tex/latex/adjustbox - mkdir -p tds/doc/latex/adjustbox - mkdir -p tds/source/latex/adjustbox - ${CP} ${DOCFILES} tds/doc/latex/adjustbox - ${CP} ${PACKEDFILES} tds/tex/latex/adjustbox - ${CP} ${SRCFILES} tds/source/latex/adjustbox - cd tds; zip -r ../$@ . - diff --git a/Master/texmf-dist/source/latex/adjustbox/README b/Master/texmf-dist/source/latex/adjustbox/README deleted file mode 100644 index a5557713eb6..00000000000 --- a/Master/texmf-dist/source/latex/adjustbox/README +++ /dev/null @@ -1,47 +0,0 @@ -LaTeX package 'adjustbox' -~~~~~~~~~~~~~~~~~~~~~~~~~ -Copyright (c) 2011 by Martin Scharrer -WWW: http://latex.scharrer-online.de/ - -Provides the macros \trimbox, \clipbox and \adjustbox as an addition -to the macros \resizebox, \scalebox and \rotatebox from the 'graphics' package. -It reuses the key=value interface of the 'graphicx' package. -The 'pgf' package is used to implement the trimming and clipping operations -as well as to parse the numeric values. -Environment versions of the macros are also provided. -Both macros and environments support verbatim content. - -Usage: -\trimbox{ }{} Trims given amount -\trimbox*{ }{} Trims to given viewport - -\clipbox{ }{} Clips given amount -\clipbox*{ }{} Clips to given viewport - -\adjustbox{}{} Like graphicx's \includegraphics, but for text -Supported options: width, height, totalheight, keepaspectratio, scale, angle, trim, viewport, clip -The options is mandatory but can be empty for the trivial case (=\mbox). - - -Environments: - -\begin{trimbox}{ } - -\end{trimbox} - -\begin{trimbox*}{ } - -\end{trimbox*} - -\begin{clipbox}{ } - -\end{clipbox} - -\begin{clipbox*}{ } - -\end{clipbox*} - -\begin{adjustbox}{} - -\end{adjustbox} - diff --git a/Master/texmf-dist/source/latex/adjustbox/adjustbox.dtx b/Master/texmf-dist/source/latex/adjustbox/adjustbox.dtx index 6913806e9e2..829459b6486 100644 --- a/Master/texmf-dist/source/latex/adjustbox/adjustbox.dtx +++ b/Master/texmf-dist/source/latex/adjustbox/adjustbox.dtx @@ -20,17 +20,12 @@ % This work consists of the files adjustbox.dtx, adjustbox.ins % and the derived file adjustbox.sty. % -% $Id: adjustbox.dtx 2372 2011-03-20 12:01:30Z martin $ +% $Id$ % \fi % % \iffalse -%\ProvidesPackage{adjustbox} -%\ProvidesFile{adjustbox-de.tex} -%<*driver> -\ProvidesFile{adjustbox.dtx} -% - [2011/03/20 v0.3 Adjusting TeX boxes (trim, clip, ...)] %<*driver> +\ProvidesFile{adjustbox.dtx}[2011/08/13 v0.5 DTX File] \expandafter\ifx\csname ifenglish\endcsname\relax \expandafter\newif\csname ifenglish\endcsname \englishtrue @@ -43,12 +38,31 @@ %\PassOptionsToPackage{ngerman}{hyperref} %\RequirePackage[ngerman]{babel} -\documentclass{ydoc}[2011/03/19] -\GetFileInfo{adjustbox.dtx} +\documentclass{ydoc}[2011/08/11] +\usepackage{amsmath} +\usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} -\usepackage{adjustbox}[\filedate] +\usepackage{fourier} +\GetFileInfo{adjustbox.dtx} +\usepackage{newverbs} +\MakeSpecialShortVerb\qverb\" +%\AtBeginDocument{\MakeShortMacroArgs\`\relax} +%\AtEndDocument{\DeleteShortVerb\`} +\usepackage{adjustbox} +\usepackage{tikz} \normalmarginpar +\renewenvironment{example}[1][Example:]{% + \subsubsection*{#1}% +}{% + \par +} +\newenvironment{examples}[1][Examples:]{% + \subsubsection*{#1}% +}{% + \par +} + \newcommand\babelfiledate{% \expandafter\babelfileDate\filedate\relax } @@ -60,21 +74,95 @@ \today \endgroup } +\optionaloff + +\lstdefinelanguage{none}{}% +\lstdefinelanguage{adjustbox}{% + moretexcs={% + begin,end,adjustbox + }, + emph={% + frame,fbox,cframe,cfbox,minipage,raise + }, +}% + +\lstdefinestyle{examplecode}{% + basicstyle=\ttfamily\small, + numbers=none,language=none, + classoffset=1, + morekeywords={begin,end}, + keywordstyle=\bfseries, + classoffset=0, + morekeywords={adjustbox,minsizebox,maxsizebox,lapbox,marginbox,phantombox}, + keywordstyle=\macrodescstyle, + emph={viewport, trim, Trim, Viewport, Clip, Clip*, frame, fbox, cframe, cfbox, reflect, lap, margin, margin*, dpi, + pxdim, execute, raise, valign, bgcolor, set, height, depth, width, totalheight, center, left, right, outer, inner, min, max, + size, totalsize, + minipage, innerenv, innercode, env, Addcode, addcode, precode, Precode, appcode, angle, scale, height, width, totalheight, resolution, + }, + emphstyle=\keydescstyle, +} + +\makeatletter +\def\PrintExample{% + \begingroup + \par\smallskip\noindent + \leavevmode + \BoxExample + \@tempdima=\textwidth + \advance\@tempdima by -\wd\examplecodebox\relax + \advance\@tempdima by -\wd\exampleresultbox\relax + \advance\@tempdima by -15pt\relax + \ifdim\@tempdima>\bigskipamount + \hbox to \textwidth{% + \null\hss + \minipage[c]{\wd\examplecodebox}\usebox\examplecodebox\endminipage + \hfill\hskip\bigskipamount\hfill + \minipage[c]{\wd\exampleresultbox}% + \EXAMPLERESULT + \endminipage + \hss\null + }% + \else + \vbox{% + \leftline{\usebox\examplecodebox}% + \vspace{\bigskipamount}% + \rightline{\EXAMPLERESULT}% + }% + \fi + \par\smallskip + \endgroup +} +\def\EXAMPLERESULT{% + \leavevmode\hbox{% + \textcolor{exampleborder}{% + \boxframe + {\dimexpr\wd\exampleresultbox+2\fboxrule\relax}% + {\dimexpr\ht\exampleresultbox+\fboxrule\relax}% + {\dimexpr\dp\exampleresultbox+\fboxrule\relax}% + \hskip-\wd\exampleresultbox + \hskip-2\fboxrule + }% + \usebox\exampleresultbox + }% +}% +\makeatother +\colorlet{exampleborder}{black!33} %\EnableCrossrefs %\CodelineIndex %\RecordChanges -%\OnlyDescription +\OnlyDescription \renewcommand{\bottomfraction}{0.5} \begin{document} - \DocInput{adjustbox.dtx} + \DocInput{adjustbox.dtx} \PrintChanges %\newpage\PrintIndex \end{document} % % \fi % -% \CheckSum{184} +% \CheckSum{1842} % % \CharacterTable % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -96,6 +184,8 @@ % \changes{v0.1}{2011/01/24}{First internal version} % \changes{v0.2}{2011/01/27}{First released version} % \changes{v0.3}{2011/03/20}{Bug fix for wrong baseline placed on the bottom} +% \changes{v0.4}{2011/07/xx}{Added pdftex driver} +% \changes{v0.5}{2011/08/13}{Added more macros and keys} % % \GetFileInfo{adjustbox.dtx} % @@ -116,11 +206,13 @@ % % \ifenglish % \begin{abstract} -% This package provides macros missing in \pkg{graphics} to trim, clip and generally adjust boxed \LaTeX{} material. -% The macros allow for verbatim content. Equivalent environments are also provided. The trim and clip operation -% are implemented using the \pkg{pgf} package, which supports both DVI/PS and PDF output. +% This package provides macros missing in \pkg{graphics} to trim, clip and generally adjust boxed \LaTeX{} material +% as well as further box modification macros and option keys usable for \Macro\adjustbox and \Macro\includegraphics. +% The macros use the \pkg{collectbox} package to allow for verbatim content. Equivalent environments are also provided. +% The trim operation is now implemented in \TeX\ and the clip operation uses |pdftex| primitives if available. +% Otherwise the \pkg{pgf} package is used for clipping, which supports both DVI/PS and PDF output. % \\ -% \textcolor{red}{This package is new and the implementation might change in upcoming releases!} +% \textcolor{yellow}{This package is still a little new and its implementation might not be fully stable yet.} % \end{abstract} % \else % \begin{abstract} @@ -142,10 +234,12 @@ % operation on \LATeX{} material, which is subsequently placed inside a \Macro\hbox. % However no macros are provided to trim or clip \LATeX{} material, most likely because this operations % are not done by \TeX{} but by the output format, i.e. using PostScript (PS) or PDF operations. -% +% % This package provides the missing macros \Macro\clipbox and \Macro\trimbox -% as well as the general \Macro\adjustbox macro. The clipping and trimming operations are implemented using -% a \env{pgfpicture} environment from the \pkg{pgf} package which supports both PS and PDF output. +% as well as the general \Macro\adjustbox macro. The trim operation is implemented as \TeX\ code +% and the clip operation either using a |pdftex| or a \env{pgfpicture} environment from the \pkg{pgf} package +% which supports both PS and PDF output. All \LaTeX\ compilers should be supported, but |pdflatex| is the main target of the +% author. % \else % \section{Einleitung} % Das \LaTeX{} Paket \pkg{graphicx} (die erweiterte Version von \pkg{graphics}) stellt das Macro \Macro\includegraphics[]{} zur Verfügung @@ -160,14 +254,73 @@ % Das \textsf{adjustbox} Paket definiert die Makros \Macro\clipbox und \Macro\trimbox, sowie das allgemeine \Macro\adjustbox Macro (engl.: \emph{adjust} = anpassen). % Das Beschneiden wird durch eine \env{pgfpicture} Umgebung des Pakets \pkg{pgf} verwirklicht, dass sowohl das PS und PDF Ausgabeformat unterstützt. % \fi -% \optionaloff +% +% \section{Package Option}\label{sec:options} +% Following v0.5 from 2011/08/13 this package accepts the following package options. Some of them can also be used as +% optional keys for macros. +% +% \begin{description}\def\oitem#1{\item[{\normalfont\opt{#1}}]} +% \oitem{minimal} Only define the minimal set of macros, i.e.\ \Macro\trimbox, \Macro\clipbox and \Macro\adjustbox as +% with previous versions before v0.5. +% \oitem{export} Export the now keys of \Macro\adjustbox also to \Macro\includegraphics so that they can be used for +% images as well. This option is meaningless if \opt{minimal} was used. +% \oitem{patch} Patch the internal \pkg{graphicx} code to allow the usage of size macros. +% This simply loads the small \pkg{adjgrfx} package which can also be used independently. +% (Not fully implemented and tested yet!) +% \oitem{pgf} Uses the \pkg{pgf} package for all clip operations. This overrides all automatically detected drivers. +% At the moment only a |pdftex| driver is provided, all other compilers and output formats use this option already. +% \oitem{PGF} Uses the \pkg{pgf} package for clip operations and configures the macros to parse lengths using +% \pkg{pgfmath} (compare with the \opt{pgf} option below). +% \end{description} +% +% The following options define the way length values are processed by the provided macros. +% They can be used either as package options and as keys for \Macro\adjustbox\relax (but not for \Macro\includegraphics +% even if the \opt{export} option was used) to change the settings locally. +% The only difference between these two usages is that they also load required packages when used as package options. +% Therefore all keys used in the document should be loaded as package options first or the required packages must be loaded +% manually. (It is also possible to disable the advanced parsing of lengths using the \opt{none} option, but this is not recommended.) +% +% \begin{description}\def\oitem#1{\item[{\normalfont\opt{#1}}]} +% \oitem{etex} Uses the $\epsilon$-\TeX\ primitive \Macro\glueexpr to parse length values. This allows for additions, +% subtractions as well as multiplications and devision by a numeric factor. See the official \pkg{etex\_man} document +% for more details. This setting is the default if $\epsilon$-\TeX\ is detected (which should be the case with all +% modern \LaTeX\ distributions). +% \oitem{calc} Uses the \pkg{calc} package to parse length values. It supports all operations mentioned for \opt{etex} and +% also some other operation like \Macro\widthof{}. +% See the \pkg{calc} package manual for more details. +% This is the default setting if $\epsilon$-TeX is not detected. +% \oitem{pgfmath} Uses the \pkg{pgfmath} package of the \pkg{pgf} bundle to parse length values. It supports all basic +% numeric operations and also advanced mathematical functions. +% See the \pkg{pgf} manual for more details. +% Because the \pkg{pgfmath} package can't be loaded +% independently in the current version (v2.10) the whole \pkg{pgf} package will be loaded. +% \end{description} +% +% One further option exists which can also be used as optional key for \Macro\adjustbox\relax (but not for +% \Macro\includegraphics): +% \begin{description}\def\oitem#1{\item[{\normalfont\opt{#1}}]} +% \oitem{defaultunit}\MacroArgs'='\relax +% This sets the default unit used for the values of \Macro\trimbox, \Macro\clipbox and \Macro\marginbox +% including there starred versions +% as well as all related keys like \Key{trim}, \Key{viewport}, \Key{margin}, \Key{trim}, \Key{viewport}, \Key{Clip} and \Key{Clip*}. +% The standard default unit is the same as for \Macro\includegraphics: "bp" (big points, PostScript points). +% However, for \LaTeX\ material \TeX\ normal unit "pt" (\TeX\ points) are better suited and will avoid rounding +% errors which otherwise get introduced by the internal conversion. +% The default unit is only used if the particular value is only a single number without unit, +% but not if any mathematical operations are used. +% If the special value |none| is used no default unit is applied and the internal check if the value is a single number +% is by-passed. This gives a small speed bonus and can be used to avoid potential issues with complex values. +% At this moment this setting will disable the default unit feature for the rest of the current group (i.e.\ all +% further \Macro\adjustbox keys or globally if used as a package option) and further usages of this option will +% have no affect. This might change in future versions of this package. +% \end{description} % % \ifenglish % \def\llx{llx} % \def\lly{lly} % \def\urx{urx} % \def\ury{ury} -% \def\text{text} +% \def\TEXT{content} % \def\height{height} % \def\width{width} % \def\totalheight{totalheight} @@ -182,7 +335,7 @@ % \def\lly{luy} % \def\urx{orx} % \def\ury{ory} -% \def\text{Text} +% \def\TEXT{Inhalt} % \def\height{Höhe} % \def\width{Weite} % \def\totalheight{Totale Höhe} @@ -196,32 +349,34 @@ % % \ifenglish % \section{Usage} -% This section describes the usage of the provided macros, which are outlined in \autoref{sec:boxmacros}. +% This section describes the usage of the provided macros, which are outlined in \autoref{sec:basicmacros}. % Possible advanced values for the macro arguments are mentioned in \autoref{sec:argval}. The existing verbatim support % is explained in \autoref{sec:verbatim}. Finally \autoref{sec:alternatives} compares the existing macros with the -% corresponding options of \Macro\djustbox. -% See the example \autoref{sec:example} for examples of this macros. +% corresponding options of \Macro\adjustbox. +% Further box modification macros and keys are described in \autoref{sec:moremacros} and \autoref{sec:newkeys}, respectively. % -% It is recommended to also read the \emph{Graphics Guide} (|grfguide|, i.e.~the manual of the |graphics|/|x| packages), +% It is recommended to also read the \emph{Graphics Guide} (\pkg{grfguide}, i.e.~the manual of the \pkg{graphics}/|x| packages), % to understand the existing options for \Macro\includegraphics. % \else % \newpage % \section{Anleitung} -% Dieser Abschnitt beschreibt die Verwendung der Makros dieses Pakets. Diese werden zuerst im \autoref{sec:boxmacros} beschrieben. +% Dieser Abschnitt beschreibt die Verwendung der Makros dieses Pakets. Diese werden zuerst im \autoref{sec:basicmacros} beschrieben. % \autoref{sec:argval} erklärt welche Werte in den Makroargumenten verwendet werden können. Die Makros unterstützen sogenannten % \emph{verbatim} (engl.: wortgetreu) Inhalt was im \autoref{sec:verbatim} erleutert wird. % Schlussendlich wird im \autoref{sec:alternatives} die exisitierenden Makros mit den entsprechendem Optionen von \Macro\adjustbox % verglichen. Beispiele für die beschriebenen Makros befinden sich im folgendem \autoref{sec:example}. % -% Dem Leser wird darüberhinaus die Lektüre der Anleitung der |graphic|/|x| Pakete, der \emph{Graphics Guide}, empfohlen wo +% Dem Leser wird darüberhinaus die Lektüre der Anleitung der \pkg{graphic}/|x| Pakete, der \emph{Graphics Guide}, empfohlen wo % die möglichen Optionen für das Makro \Macro\includegraphics gelistet sind, die auch für \Macro\adjustbox verwendet werden. % \fi % % \ifenglish % \Needspace*{7\baselineskip} -% \subsection{Box Modification Macros}\label{sec:boxmacros} +% \subsection{Basic Box Modification Macros}\label{sec:basicmacros} +% This section lists the provided macros \Macro\clipbox and \Macro\trimbox missing in the \pkg{graphicx} package +% as well as the general \Macro\adjustbox macro. If the package is loaded with the \opt{minimal} option no further macros or keys are defined. % \else -% \subsection{Makros zur Modifikation von {\LaTeX} Material}\label{sec:boxmacros} +% \subsection{Makros zur Modifikation von {\LaTeX} Material}\label{sec:basicmacros} % \fi % % \ifenglish @@ -230,17 +385,21 @@ % \subsubsection*{Rand beschneiden ohne Überhang auszublenden} % \fi % \vskip-\lastskip -% \DescribeMacro\trimbox*{<\llx>~<\lly>~<\urx>~<\ury>}{<\text>} +% \DescribeMacro\trimbox{}{<\TEXT>} +% \DescribeMacro\trimbox{~}{<\TEXT>} +% \DescribeMacro\trimbox{<\llx>~<\lly>~<\urx>~<\ury>}{<\TEXT>} +% \DescribeMacro\trimbox*{<\llx>~<\lly>~<\urx>~<\ury>}{<\TEXT>} % \ifenglish -% \subsubsection*{Trim Box Content} % The macro \Macro\trimbox trims the given amount from the lower left (ll) and the upper right (ur) corner of % the box. This means that the amount \meta{llx} is trimmed from the left side, \meta{lly} from the bottom and % \meta{urx} and \meta{ury} from the right and top of the box, respectively. +% If only one value is given it will be used for all four sites. +% If only two values are given the first one will be used for the left and right side (llx, urx) and the second for the bottom and top side (lly, ury). % Trimming means that the official size of the box is reduced, but no material % is actual removed. The material in the trimmed areas simply swaps over the official border. % -% If the starred version is used the four coordinates are taken as the |viewport| instead, i.e. the box -% is trimmed to the rectangle described by the coordinates. +% If the starred version is used the four coordinates are taken as the \Key{viewport} instead, i.e. the box +% is trimmed to the rectangle described by the coordinates. In this case using all four values must be specified. % \else % Das Makro \Macro\trimbox setzt den \meta{Text} in eine \TeX{} Box und reduziert dessen offizielle Größe % (\emph{bounding box}, engl.: begrenzende Box), so dass \TeX{} annimmt es wäre entsprechend kleiner. Überstehendes Material @@ -253,9 +412,9 @@ % \fi % % -% \DescribeEnv[<\text>]{trimbox}*{<\llx>~<\lly>~<\urx>~<\ury>} +% \DescribeEnv[<\TEXT>]{trimbox}{<1, 2 or 4 trim values>} % \vspace{-\baselineskip} -% \DescribeEnv[<\text>]{trimbox*}{<\llx>~<\lly>~<\urx>~<\ury>} +% \DescribeEnv[<\TEXT>]{trimbox*}{<\llx>~<\lly>~<\urx>~<\ury>} % \ifenglish % The \env{trimbox} and \env{trimbox*} environments do the same as the corresponding macros. % Special care is taken so that the macros and the environments can have the same name. @@ -277,14 +436,17 @@ % \subsubsection*{Rand beschneiden und Überhang ausblenden} % \fi % \vskip-\lastskip -% \DescribeMacro\clipbox*{<\llx>~<\lly>~<\urx>~<\ury>}{<\text>} +% \DescribeMacro\clipbox{}{<\TEXT>} +% \DescribeMacro\clipbox{~}{<\TEXT>} +% \DescribeMacro\clipbox{<\llx>~<\lly>~<\urx>~<\ury>}{<\TEXT>} +% \DescribeMacro\clipbox*{<\llx>~<\lly>~<\urx>~<\ury>}{<\TEXT>} % \ifenglish % The \Macro\clipbox macro works like the \Macro\trimbox and trims the given amounts from the \meta{text}. % However, in addition the trimmed material is also clipped, i.e. it is not shown in the final document. % Note that the material will still be part of the output file but is simply not shown. % It might be exported using special tools, so using \Macro\clipbox\relax (or \Macro\includegraphics[clip,trim=...]) % to censor classified information would be a bad idea. -% The starred version will again use the given coordinates as |viewport|. +% The starred version will again use the given coordinates as \Key{viewport}. % \else % Das \Macro\clipbox Makro arbeiten ähnlich wie \Macro\trimbox nur, dass der entfernte Rand auch wirklich % ausgeblendet wird. Allerdings bleibt dieses Material Teil der Ausgabedatei und könnte durch spezielle Software exportiert werden. @@ -293,9 +455,9 @@ % Die Sternvariante verwendet die angegebenen Werte als den zu darstellenden Bereich wie bei \Macro\trimbox'*'. % \fi % -% \DescribeEnv[<\text>]{clipbox}*{<\llx>~<\lly>~<\urx>~<\ury>} +% \DescribeEnv[<\TEXT>]{clipbox}{<1, 2 or 4 trim values>} % \vspace{-\baselineskip} -% \DescribeEnv[<\text>]{clipbox*}{<\llx>~<\lly>~<\urx>~<\ury>} +% \DescribeEnv[<\TEXT>]{clipbox*}{<\llx>~<\lly>~<\urx>~<\ury>} % \iffalse % The environment versions of \Macro\clipbox and \Macro\clipbox*. The same rules as for the trimming environments apply. % \else @@ -309,7 +471,7 @@ % \subsubsection*{Allgemeine Manipulationen von \LaTeX{} Material} % \fi % \vskip-\lastskip -% \DescribeMacro\adjustbox{}{<\text>} +% \DescribeMacro\adjustbox{}{<\TEXT>} % \ifenglish % The \Macro\adjustbox macro is the general form of all box modifying macros mentioned in the introduction. % It can be thought as an \Macro\includegraphics for \LATeX{} material. @@ -325,7 +487,7 @@ % Es kann dazu verwendet werden Kombinationen von anderen ähnlichen Makros zu ersetzen, was in \autoref{tab:alternatives} dargestellt wird. % \fi % -% \DescribeEnv[<\text>]{adjustbox}{} +% \DescribeEnv[<\TEXT>]{adjustbox}{} % \ifenglish % The environment version of \Macro\adjustbox. % \else @@ -333,21 +495,60 @@ % \fi % % \ifenglish +% \section*{Examples} +% The following examples show the application of the aforementioned macros on an example text. +% The result is placed in a tight, colored frame box to show the resulting dimensions. +% \else +% \section*{Beispiele} +% Die folgenden Beispiele zeigen die Anwendung der Makros dieses Packets auf einen Beispieltext (\Macro\example). +% Das Ergebnis wird mit einer engen, farbigen Umrandung dargestellt um die entgültigen Dimensionen sichtbar zu machen. +% \fi +% \begingroup +% \def\examplecontent{\begin{tabular}{@{}|c|c|@{}} +% \hline +% A & B \\ +% \hline +% C & D \\ +% \hline +% \end{tabular}^^A +% } +% \fboxsep=0pt% +% \def\Fbox{\fcolorbox{red}{white}}% +% \def\X{\vspace*{20pt}}% +% \par\bigskip\noindent +% \begin{tabular}{@{}lc} +% \X\Macro\example & \Fbox{\examplecontent} \\ +% \X\Macro\trimbox{10 5 10 5}{\AlsoMacro\example} & \Fbox{\trimbox{10 5 10 5}{\examplecontent}} \\ +% \X\Macro\clipbox{10 5 10 5}{\AlsoMacro\example} & \Fbox{\clipbox{10 5 10 5}{\examplecontent}} \\ +% \X\Macro\trimbox*{15 5 25 30}{\AlsoMacro\example} & \Fbox{\trimbox*{15 5 25 30}{\examplecontent}} \\ +% \X\Macro\clipbox*{15 5 25 30}{\AlsoMacro\example} & \Fbox{\clipbox*{15 5 25 30}{\examplecontent}} \\ +% \X\Macro\adjustbox{trim=10 5 10 5,angle=45}{\AlsoMacro\example} & \Fbox{\adjustbox{trim=10 5 10 5,angle=45}{\examplecontent}} \\ +% \X\Macro\adjustbox{scale=1.5}{\AlsoMacro\example} & \Fbox{\adjustbox{scale=1.5}{\examplecontent}} \\ +% \X\Macro\adjustbox{width=180pt,height=20pt}{\AlsoMacro\example} & \Fbox{\adjustbox{width=40pt,height=10pt}{\examplecontent}} \\ +% \X\Macro\adjustbox{width=180pt,height=20pt,keepaspectratio}{\AlsoMacro\example} & \Fbox{\adjustbox{width=40pt,height=10pt,keepaspectratio}{\examplecontent}} \\ +% \end{tabular} +% \endgroup +% +% \clearpage +% \ifenglish % \subsection{Argument Values}\label{sec:argval} -% The\marginpar{Parsing} argument values are parsed by versatile \Macro\pgfmathparse of the already used |pgf| package. -% This allows very complex arithmetic expressions as any of the trim/clip coordinates or other numeric options. -% See the |pgfmanual| for detailed information. -% Note\marginpar{Space=Separator} that the four values for \Macro\trimbox and \Macro\clipbox as well as for the |trim| and |viewport| option of \Macro\adjustbox -% are separated by spaces. If the expression of any of this values holds a space or ends with a macro (eats trailing spaces!) it must be wrapped into braces `|{ }|'. +% All\marginpar{Parsing} length values given in the arguments of all macros and keys provided by this package are parsed by and advanced version of +% \Macro\setlength (called \Macro\adjsetlength) which uses either $\epsilon$-\TeX\ expressions (default), the \pkg{calc} package (default fall-back) +% or the \Macro\pgfmathparse of the \pkg{pgf} package. +% This allows for arithmetic expressions in these arguments. See the package options in \autoref{sec:options} to learn how to change the used length parser. +% Note that early versions of this package used \Macro\pgfmathparse by default. Older documents therefore might need now use the \opt{pgfmath} option to compile correctly. +% +% Note\marginpar{Space=Separator} that the four values for \Macro\trimbox and \Macro\clipbox as well as for the \Key{trim} and \Key{viewport} option of \Macro\adjustbox +% are separated by spaces. If the expression of any of this values holds a space or ends with a macro (eats trailing spaces!) it must be wrapped into braces "{ }". % \else % \newpage % \subsection{Erlaubte Werte für Makroargumente}\label{sec:argval} % Die numerischen Werte für die Makros werden durch das vielseitige \Macro\pgfmathparse Makro des sowieso schon verwendeten \pkg{pgf} Paketes % eingelesen. Dies erlaubt die Verwendung von einfachen oder komplizierten Formeln. % Eine genaue Beschreibung der unterstützten mathematischen Operationen befindet sich im Handbuch des \pkg{pgf} Paketes. -% Dabei muss beachtet werden das die vier Werte für die \Macro\trimbox und \Macro\clipbox Makros sowie für die |trim| und |viewport| Optionen von \Macro\adjustbox +% Dabei muss beachtet werden das die vier Werte für die \Macro\trimbox und \Macro\clipbox Makros sowie für die \Key{trim} und \Key{viewport} Optionen von \Macro\adjustbox % durch Leerzeichen getrennt werden müssen. Komplizierte Angaben die ein Leerzeichen enthalten oder auf ein Makro enden (entfernt nachfolgende Leerzeichen) müssen -% deswegen in geschweifte Klammern `|{ }|' gesetzt werden. +% deswegen in geschweifte Klammern "{ }" gesetzt werden. % \fi % % @@ -355,32 +556,28 @@ % \hbox{\Macro\width~~~\Macro\height~~~\Macro\depth~~~\Macro\totalheight}% % \endDescribeMacros % \ifenglish -% This \LaTeX{} lengths hold the original dimension of \meta{text} and can be used as part of the arguments to \Macro\adjustbox, \Macro\trimbox and \Macro\clipbox. -% The totalheight is the height plus depth. +% These \LaTeX{} lengths hold the original dimension of \meta{text} and can be used as part of the arguments to \Macro\adjustbox, \Macro\trimbox and \Macro\clipbox. +% The totalheight is the height plus depth. With the \pkg{patch} option these lengths can also be used for \Macro\includegraphics. % \else -% Diese \LaTeX{} Längen enthalten die Weite, Höhe, Tiefe bzw.\ die totale Höhe (Höhe + Tiefe) des \meta{\text} Arguments bzw.\ des Inhalts der Umgebung. +% Diese \LaTeX{} Längen enthalten die Weite, Höhe, Tiefe bzw.\ die totale Höhe (Höhe + Tiefe) des \meta{\TEXT} Arguments bzw.\ des Inhalts der Umgebung. % Diese Längen können in den ersten Argument von \Macro\adjustbox, \Macro\trimbox und \Macro\clipbox verwendet werden um relative Änderungen vorzunehmen. % \fi % % If\marginpar{Default unit} no unit is provided for of the bounding box coordinates (\llx, \lly, \urx, \ury) then PostScript points % (\emph{big points}, bp, $72\,\text{bp}=1\,\text{inch}$) are used, as it is the default behaviour -% of the |trim| and |viewport| ptions of \pkg{graphicx}'s \Macro\includegraphics. Note that \pkg{graphicx} converts all values, independent if a unit is provided or not, +% of the \Key{trim} and \Key{viewport} options of \pkg{graphicx}'s \Macro\includegraphics. Note that \pkg{graphicx} converts all values, independent if a unit is provided or not, % internally to bp, because graphics where traditionally stored in Encapsulated PostScript (EPS) files. The more modern PDF files also use bp instead of pt. -% Because the |adjustbox| package macros target \LATeX{} material and users will mostly use pt values this internal conversion to bp got disabled for them to -% avoid unnecessary rounding errors. +% Because the \pkg{adjustbox} package macros target \LATeX{} material and users will mostly use pt values this internal conversion to bp got disabled for them to +% avoid unnecessary rounding errors. Since v0.5 the default unit can be changed using the |defaultunit|\MacroArgs'='\relax +% key (which is also usable as global package option). % % -% \subsubsection*{Examples for Argument Values} -% \codeline{\AlsoMacro\trimbox{'{.5\width} 10 {log10(10)/sin(45) + 1} 10pt'}{<\text>}} -% will trim half the original amount from the left, 10\,bp from the bottom and -% 2.42328\,bp from the right (bp, because no unit was used in the formula; change e.g. `|+ 1|' to `|+ 1pt|' to get 2.42328\,pt), -% as well as 10\,pt from the top. -% % \subsection{Verbatim Support}\label{sec:verbatim} % The macros read the \meta{text} as \TeX{} \Macro\hbox and not as an macro argument in order to support verbatim content. +% This functionality is now provided as dedicated package \pkg{collectbox} which can also be used independently. % This means that the braces around the content can also be written as \Macro\bgroup and \Macro\egroup: % \begin{macroquote} -% \trimbox{1 2 3 4}\AlsoMacro\bgroup~<\text>\AlsoMacro\egroup +% \trimbox{1 2 3 4}\AlsoMacro\bgroup~<\TEXT>\AlsoMacro\egroup % \end{macroquote} % Special care is taken to allow the \meta{text} to be a single macro (except \Macro\bgroup) without any braces: % \begin{macroquote} @@ -389,6 +586,7 @@ % This is to support the questionable habit of some \LaTeX{} users to drop the braces for single token arguments. % All environments support verbatim content. % +% \clearpage % \ifenglish % \subsection{Alternatives for existing Macros}\label{sec:alternatives} % The flexible \Macro\adjustbox can also be used as an alternative to existing macros from the \pkg{graphics} package as shown by Table~\ref{tab:alternatives}. @@ -418,273 +616,2451 @@ % \begin{tabular}{ll} % \toprule % \ifenglish -% Original Macro (w/o text argument) & Alternative (w/o text argument) \\ +% Original Macro (w/o content argument) & Alternative \Macro\adjustbox keys \\ % \else -% Originales Makro (ohne Text Argument) & Alternative (ohne Text argument) \\ +% Originales Makro (ohne Textargument) & Alternative \Macro\adjustbox Schlüssel \\ % \fi % \midrule -% \Macro\rotatebox{<\Angle>} & \Macro\adjustbox{'angle='<\Angle>} \\ -% \Macro\scalebox{<\factor>} & \Macro\adjustbox{'scale='<\factor>} \\ -% \Macro\scalebox{<\xfactor>}[<\yfactor>] & \Macro\adjustbox{'width='<\xfactor>\AlsoMacro\width',height='<\yfactor>\AlsoMacro\height} \\ -% \Macro\reflectbox & \Macro\adjustbox{'width=-'\AlsoMacro\width',height='\AlsoMacro\height} \\ -% \Macro\resizebox{<\width>}{<\height>} & \Macro\adjustbox{'width='<\width>',height='<\height>} \\ -% \Macro\resizebox*{<\width>}{<\totalheight>} & \Macro\adjustbox{'width='<\width>',totalheight='<\totalheight>} \\ -% \Macro\trimbox{<\llx>~<\lly>~<\urx>~<\ury>} & \Macro\adjustbox{'trim='<\llx>~<\lly>~<\urx>~<\ury>} \\ -% \Macro\trimbox*{<\llx>~<\lly>~<\urx>~<\ury>} & \Macro\adjustbox{'viewport='<\llx>~<\lly>~<\urx>~<\ury>} \\ -% \Macro\clipbox{<\llx>~<\lly>~<\urx>~<\ury>} & \Macro\adjustbox{'trim='<\llx>~<\lly>~<\urx>~<\ury>,clip} \\ -% \Macro\clipbox*{<\llx>~<\lly>~<\urx>~<\ury>} & \Macro\adjustbox{'viewport='<\llx>~<\lly>~<\urx>~<\ury>,clip} \\ +% \Macro\rotatebox{<\Angle>} & \MacroArgs'angle='<\Angle> \\ +% & \MacroArgs'rotate='<\Angle> \\ +% \Macro\scalebox{<\factor>} & \MacroArgs'scale='<\factor> \\ +% \Macro\scalebox{<\xfactor>}[<\yfactor>] & \MacroArgs'width='<\xfactor>\AlsoMacro\width',height='<\yfactor>\AlsoMacro\height \\ +% \Macro\reflectbox & \MacroArgs'reflect' \\ +% & \MacroArgs'width=-'\AlsoMacro\width',height='\AlsoMacro\height \\ +% \Macro\resizebox{<\width>}{<\height>} & \MacroArgs'width='<\width>',height='<\height> \\ +% \Macro\resizebox*{<\width>}{<\totalheight>} & \MacroArgs'width='<\width>',totalheight='<\totalheight> \\ +% \Macro\trimbox{<\llx>~<\lly>~<\urx>~<\ury>} & \MacroArgs'trim='<\llx>~<\lly>~<\urx>~<\ury> \\ +% & \MacroArgs'Trim='<\llx>~<\lly>~<\urx>~<\ury> \\ +% \Macro\trimbox*{<\llx>~<\lly>~<\urx>~<\ury>} & \MacroArgs'viewport='<\llx>~<\lly>~<\urx>~<\ury> \\ +% & \MacroArgs'Viewport='<\llx>~<\lly>~<\urx>~<\ury> \\ +% \Macro\clipbox{<\llx>~<\lly>~<\urx>~<\ury>} & \MacroArgs'trim='<\llx>~<\lly>~<\urx>~<\ury>,clip \\ +% & \MacroArgs'Clip='<\llx>~<\lly>~<\urx>~<\ury> \\ +% \Macro\clipbox*{<\llx>~<\lly>~<\urx>~<\ury>} & \MacroArgs'viewport='<\llx>~<\lly>~<\urx>~<\ury>,clip \\ +% & \MacroArgs'Clip*='<\llx>~<\lly>~<\urx>~<\ury> \\ % \bottomrule % \end{tabular}% % \hss}% % \end{table} % -% \clearpage -% \ifenglish -% \section{Examples}\label{sec:example} -% The following examples show the application of the package macros on an example text. -% The result is placed in a tight, colored frame box to show the resulting dimensions. -% \else -% \section{Beispiele}\label{sec:example} -% Die folgenden Beispiele zeigen die Anwendung der Makros dieses Packets auf einen Beispieltext (\Macro\example). -% Das Ergebnis wird mit einer engen, farbigen Umrandung dargestellt um die entgültigen Dimensionen sichtbar zu machen. -% \fi % -% \begingroup -% \def\examplecontent{\begin{tabular}{@{}|c|c|@{}} -% \hline -% A & B \\ -% \hline -% C & D \\ -% \hline -% \end{tabular}^^A -% } -% \fboxsep=0pt% -% \def\Fbox{\fcolorbox{red}{white}}% -% \def\X{\vspace*{20pt}}% -% \par\bigskip\noindent -% \begin{tabular}{@{}lc} -% \X\Macro\example & \Fbox{\examplecontent} \\ -% \X\Macro\trimbox{10 5 10 5}{\AlsoMacro\example} & \Fbox{\trimbox{10 5 10 5}{\examplecontent}} \\ -% \X\Macro\clipbox{10 5 10 5}{\AlsoMacro\example} & \Fbox{\clipbox{10 5 10 5}{\examplecontent}} \\ -% \X\Macro\trimbox*{15 5 25 30}{\AlsoMacro\example} & \Fbox{\trimbox*{15 5 25 30}{\examplecontent}} \\ -% \X\Macro\clipbox*{15 5 25 30}{\AlsoMacro\example} & \Fbox{\clipbox*{15 5 25 30}{\examplecontent}} \\ -% \X\Macro\adjustbox{trim=10 5 10 5,angle=45}{\AlsoMacro\example} & \Fbox{\adjustbox{trim=10 5 10 5,angle=45}{\examplecontent}} \\ -% \X\Macro\adjustbox{scale=1.5}{\AlsoMacro\example} & \Fbox{\adjustbox{scale=1.5}{\examplecontent}} \\ -% \X\Macro\adjustbox{width=180pt,height=20pt}{\AlsoMacro\example} & \Fbox{\adjustbox{width=40pt,height=10pt}{\examplecontent}} \\ -% \X\Macro\adjustbox{width=180pt,height=20pt,keepaspectratio}{\AlsoMacro\example} & \Fbox{\adjustbox{width=40pt,height=10pt,keepaspectratio}{\examplecontent}} \\ -% \end{tabular} % -% \ifenglish -% \subsubsection*{Environment example:} -% \else -% \subsubsection*{Beispiel mit Umgebung:} -% \fi -% \noindent -% \Macro\begin{adjustbox}{angle=2}:\\ -% \begin{adjustbox}{angle=2} -% | verbatim inside \begin{adjustbox}{angle=2} ... \end{adjustbox} | -% \end{adjustbox} +% \subsection{Further Box Modification Macros}\label{sec:moremacros} +% This section lists further macros which are also defined unless the package is loaded with the \opt{minimal} option. +% Note that the authors other package \pkg{realboxes} provides variants of existing box macros +% defined by the \LaTeX\ core or common packages like \pkg{graphicx}. Like the box macros here this variants allow for verbatim content +% because they read it as real box and not as macro arguments. +% +% \DescribeMacro\marginbox{}{<\TEXT>} +% \DescribeMacro\marginbox{~}{<\TEXT>} +% \DescribeMacro\marginbox{<\llx>~<\lly>~<\urx>~<\ury>}{<\TEXT>} +% This macro can be used to add a margin (white space) around the content. It can be seen as the opposite of \Macro\trim. +% The original baseline of the content is preserved because \meta{\lly} is added to the depth. +% It is also available as \env{marginbox} environment and also usable as \Key{margin} option (see below). +% +% \begin{example} +% \begin{examplecode} +% Before \fbox{\marginbox{1ex 2ex 3ex 4ex}{Text}} After +% \end{examplecode} +% \end{example} +% +% +% \DescribeMacro\marginbox'*'{}{<\TEXT>} +% \DescribeMacro\marginbox'*'{~}{<\TEXT>} +% \DescribeMacro\marginbox'*'{<\llx>~<\lly>~<\urx>~<\ury>}{<\TEXT>} +% This starred version is almost identical to the normal \Macro\marginbox, but also raises the content by the \MacroArgs<\lly> +% amount, so that the original depth instead of the original baseline is preserved. +% Note that while \Macro\marginbox is basically the opposite of \Macro\trim, \Macro\marginbox* is not the opposite of \Macro\trim*. +% Instead it also takes the same values as the normal value and not view port values like \Macro\trim*. +% +% \begin{example} +% \begin{examplecode} +% Before \fbox{\marginbox*{1ex 2ex 3ex 4ex}{Text}} After +% \end{examplecode} +% \end{example} +% +% +% \DescribeMacro\minsizebox{}{}{<\TEXT>} +% \DescribeMacro\minsizebox'*'{}{}{<\TEXT>} +% This macro is like \Macro\resizebox of the \pkg{graphics/x} package, but only resizes the content if its natural size is smaller +% than the given \meta{width} or \meta{height}. +% If only one value should be set the other one can be replaced by "!". +% If required the content is scaled up so that the width and height is equal or larger than the given values, but does not change +% the aspect ratio. +% The star variant uses the total height instead of only the height. +% This macro is used internally for the \Key{min width}, \Key{min height}, \Key{min totalheight} and \Key{min totalsize} options. +% +% \begin{examples} +% \begin{examplecode} +% \minsizebox{3cm}{2ex}{Some Text} which will be enlarged +% \end{examplecode} +% \begin{examplecode} +% \minsizebox{!}{4ex}{\fbox{Some Text}} which will be enlarged +% \end{examplecode} +% \begin{examplecode} +% \minsizebox*{!}{4ex}{\fbox{Some Text}} which will be enlarged +% \end{examplecode} +% \begin{examplecode} +% \minsizebox{3cm}{!}{Some Text} which will be enlarged +% \end{examplecode} +% \begin{examplecode} +% \minsizebox{1cm}{1ex}{Some Text}, already large enough +% \end{examplecode} +% \end{examples} +% +% +% +% \DescribeMacro\maxsizebox{}{}{<\TEXT>} +% \DescribeMacro\maxsizebox'*'{}{}{<\TEXT>} +% This macro is like \Macro\resizebox of the \pkg{graphics/x} package, but only resizes the content if its natural size is larger +% than the given \meta{width} or \meta{height}. +% If only one value should be set the other one can be replaced by "!". +% If required the content is scaled down so that the width and height is equal or smaller than the given values, but does not change +% the aspect ratio. +% The star variant uses the total height instead of only the height. +% This macro is used internally for the \Key{max width}, \Key{max height}, \Key{max totalheight} and \Key{max totalsize} options. +% +% \begin{examples} +% \begin{examplecode} +% \maxsizebox{1cm}{1ex}{Some Text} which will be reduced +% \end{examplecode} +% \begin{examplecode} +% \maxsizebox{!}{1ex}{\fbox{Some Text}} which will be reduced +% \end{examplecode} +% \begin{examplecode} +% \maxsizebox*{!}{1ex}{\fbox{Some Text}} which will be reduced +% \end{examplecode} +% \begin{examplecode} +% \maxsizebox{1cm}{!}{Some Text} which will be reduced +% \end{examplecode} +% \begin{examplecode} +% \maxsizebox{3cm}{1cm}{Some Text}, already small enough +% \end{examplecode} +% \end{examples} +% +% \DescribeMacro\lapbox[]{}{<\TEXT>} +% This macro is a generalisation of the \LaTeX\ core macros \Macro\rlap{<\TEXT>} and \Macro\llap{<\TEXT>} which lap the +% text to the right or left without taking any official space. The \Macro\lapbox macro can be used to only partially lap +% the content to the right (positive amount) or left (negative amount). As with all macros of this package the original width +% can be references using \Macro\width. The resulting official width of the box is normally the original width minus the absolute +% lap amount. However, it can also be set explicitly using the option argument. +% It is also possible to use lap amount which absolute values are larger than the original width. In this case the resulting +% official width will be zero by default and the content will padded with the required white space. +% Note that the lap amount always states the distance between the right side of the official box and the right side of the actual +% content for positive amounts or the distance between the left side of the official box and the left side of the actual content +% for negative values. +% +% \begin{examples} +% General lapping: +% \begin{examplecode} +% \lapbox{1cm}{Some Text} +% \end{examplecode} +% \vspace{-2\smallskipamount}% +% \begin{examplecode} +% \lapbox{-1cm}{Some Text} +% \end{examplecode} +% \vspace{-2\smallskipamount}% +% \begin{examplecode} +% \lapbox[4cm]{1cm}{Some Text} +% \end{examplecode} +% \vspace{-2\smallskipamount}% +% \begin{examplecode} +% \lapbox[3cm]{2cm}{Some Text} +% \end{examplecode} +% \vspace{\smallskipamount}% +% Like \Macro\rlap: +% \vspace{-\smallskipamount}% +% \begin{examplecode} +% \lapbox[0pt]{\width}{Some Text} +% \end{examplecode} +% \vspace{\smallskipamount}% +% Like \Macro\llap: +% \vspace{-\smallskipamount}% +% \begin{examplecode} +% \lapbox[0pt]{-\width}{Some Text} +% \end{examplecode} +% \vspace{\smallskipamount}% +% A centering \Macro\clap macro can be achieved using: +% \vspace{-\smallskipamount}% +% \begin{examplecode} +% \lapbox[0pt]{-.5\width}{Some Text} +% \end{examplecode} +% \vspace{-2\smallskipamount}% +% \begin{examplecode} +% \lapbox[0pt]{.5\width}{Some Text} +% \end{examplecode} +% +% \end{examples} +% +% +% \DescribeMacro\phantombox{}{}{} +% This macro produces an empty box with the given width, height and depth. +% It is equivalent to \Macro\phantom{\AlsoMacro\rule['-']{}{'+'}} but more efficient and more user friendly. +% +% \begin{example} +% \begin{examplecode} +% Before \fbox{\phantombox{1cm}{2ex}{1ex}} After +% \end{examplecode} +% \end{example} +% +% +% \subsection{New keys for \cs{adjustbox} and \cs{includegraphics}}\label{sec:newkeys} +% This section lists provided keys usable as \Macro\adjustbox options and, if the \opt{export} package option was used, also as \Macro\includegraphics options. +% If the package is loaded with the \opt{minimal} option this code is skipped. +% +% \subsubsection{Trimming and Clipping} +% +% \DescribeKey{Trim}'=' +% \DescribeKey{Trim}'='~ +% \DescribeKey{Trim}'='~~~ +% \DescribeKey{Viewport}'='~~~ +% The normal \Key{trim} and \Key{viewport} keys +% as described earlier are applied on the original content before any resizing +% or other effects. This is because for \Macro\includegraphics the trimming is done by the internal graphic driver, +% while the effects can be applied later (but can also be driver dependent). +% If the \Key{trim} and \Key{viewport} keys are used multiple times the last values will be used for the trimming, i.e. the content is only +% trimmed once. The upper case variants \Key{trim} and \Key{viewport} will wrap the content internally in a \Macro\trimbox or \Macro\trimbox*\relax +% macro which can be applied multiple times, e.g.\ before and after the content is rotated. +% These two keys awaits the same format as the original keys. However, the \Key{clip} key has no effect on them. +% +% \DescribeKey{Clip}'=' +% \DescribeKey{Clip}'='~ +% \DescribeKey{Clip}'='~~~ +% \DescribeKey{Clip*}'='~~~ +% As stated above the \Key{clip} boolean key +% which will make the default \Key{trim} and \Key{viewport} keys clip the trimmed content, has no effect +% on the \Key{trim} and \Key{viewport} keys. Instead \Key{Clip} and \Key{Clip*} are provided which wrap the content internally in a \Macro\clipbox or +% \Macro\clipbox*\relax macro. They can be used several times. +% +% +% \subsubsection{Frame and Margin} +% +% \DescribeKey{frame} +% \DescribeKey{frame}'=' +% \DescribeKey{frame}'='~ +% This key will draw a black frame around the content. +% By default the frame lines will have a thickness of \Macro\fboxrule\relax +% (i.e.\ the same thickness like \Macro\fbox) and will be placed tightly around the content with zero separation. +% The line width and also the separation can be defined as the optional value. +% +% +% \DescribeKey{margin}'=' +% \DescribeKey{margin}'='~ +% \DescribeKey{margin}'='~~~ +% This key can be used to add a margin (white space) around the content (using \Macro\marginbox). +% It can be seen as the opposite of \Key{trim} (and in fact is implemented +% almost identical to it with negated signs). The four values are added to the left, bottom, right and top side of the content, respectively. +% The original baseline of the content is preserved by adding \meta{\lly} to the depth. +% If negative values are given the content is actually trimmed, but this will lead to wrong results if the absolute values are bigger +% than the available amount. This is particularly a problem with the depth. The \Key{trim} and \Key{trim} code will handle this case correctly, however. +% +% \DescribeKey{margin*}'=' +% \DescribeKey{margin*}'='~ +% \DescribeKey{margin*}'='~~~ +% Like \Key{margin} but also raises the content by \meta{\lly} and therefore preserves the original depth and not the original baseline. +% +% \subsubsection{Size/Scaling} +% +% \DescribeKey{min width}'=' +% \DescribeKey{max width}'=' +% \DescribeKey{min height}'=' +% \DescribeKey{max height}'=' +% \DescribeKey{min totalheight}'=' +% \DescribeKey{max totalheight}'=' +% These keys allow to set the minimum and maximum width, height or totalheight of the content. +% The current size of the content is measured and the content is resized if the constraint is not already met, +% otherwise the content is unchanged. Multiple usages of these keys are checked one after each other, and therefore +% it is possible that a later one is undoing the size changes of an earlier one. +% A good example is \Key{max width}'='\AlsoMacro\textwidth which will limit large content to the text width but will not affect smaller +% content. +% +% \DescribeKey{min size}'='{}{} +% \DescribeKey{max size}'='{}{} +% \DescribeKey{min totalsize}'='{}{} +% \DescribeKey{max totalsize}'='{}{} +% These keys allow to specify the minimum or maximum width and (total)height of the content together, +% which is more efficient than using the width and (total)height keys described earlier. +% +% \DescribeKey{scale}'=' +% \DescribeKey{scale}'='{}{} +% The normal \Key{scale} key of \pkg{graphicx} only allows for one scale factor which is used for both the horizontal and vertical scaling. +% With \pkg{adjustbox} it is also possible to provide the horizontal and vertical scale factors separately. +% +% \DescribeKey{reflect} +% This reflects the content by using \Macro\reflectbox internally, which is identical to \Macro\scalebox{-1}[1], +% i.e.\ this key is identical to \Key{scale}'='{-1}{1}. +% +% +% \begin{examples} +% \begin{examplecode} +% \adjustbox{reflect}{\sffamily OTTO} +% \end{examplecode} +% \begin{examplecode} +% \adjustbox{reflect}{\sffamily ANNA} +% \end{examplecode} +% \begin{examplecode} +% \adjustbox{reflect}{Some text!} +% \end{examplecode} +% \end{examples} +% +% \subsubsection{Positioning and Alignment} +% +% \DescribeKey{raise}'=' +% \DescribeKey{raise}'='{}{} +% \DescribeKey{raise}'='{}{}{} +% This key uses +% \Macro\raisebox{}{\ldots} to raise the content upwards for the given \meta{amount} (length). +% A negative length moves the content down. +% The two optional arguments of \Macro\raisebox{}[][]{\ldots}\relax are also available +% as optional brace arguments. They can be used to set the official height and depth of the content. +% This is also possible using the \Key{set height} and \Key{set depth} keys. +% +% \begin{examples} +% \begin{examplecode} +% Is \adjustbox{raise=1ex}{higher} +% than the normal text +% \end{examplecode} +% \begin{examplecode} +% Is \adjustbox{raise={1ex}{\height}}{higher} +% than the normal text but sill has +% its original official height +% \end{examplecode} +% \begin{examplecode} +% Is \adjustbox{raise={1ex}{1ex}{0pt}}{higher and +% \rotatebox{-90}{depth}} but with limited official +% height and no depth. +% \end{examplecode} +% \end{examples} +% +% \DescribeKey{valign}'=' +% This key allows to vertically align the content to the top, middle and bottom. The uppercase letters |T|, |M| and |B| +% align to the content top (i.e. all depth, no height), the geometric, vertical center (equal height and depth) and to +% the bottom (all height, no depth), respectively. This allows the alignment of content of different size, but will not +% result in good alignment with text. The lowercase letters |t|, |m| and |b| are aligning the content again to the top, +% center and bottom but take the current text size in account. +% The |t| letter leaves a certain height given by the macro\footnote{A macro and not a length is used to allow for +% font size relative values like \texttt{1ex}.} \Macro\adjboxvtop\relax +% (by default set to the height of \Macro\strut\relax, i.e.\ |\ht\strutbox|, which is |.7\baselineskip|), +% while |b| sets a certain depth given (as negative length) by the macro \Macro\adjboxvbottom\relax +% (by default equal to the (negated) \Macro\strut depth, i.e.\ |-\dp\strutbox|, which is |.3\baselineskip|). +% The |m| letter will center towards the vertical center of the text line which is determined by the macro +% \Macro\adjboxvcenter\relax (by default \texttt{1ex}). +% +% The following table shows the different alignments for three different sized blocks: +% +% \bigskip +% \begingroup +% \def\vr{% +% \unskip +% \tikz [gray] {\useasboundingbox (0,0); +% \draw (-13.5em,0) -- (2.25em,0); +% \draw (-13.5em,\adjboxvcenter) -- (2.25em,\adjboxvcenter); +% }% +% \unskip\ignorespaces +% }% +% \centerline{% +% \begin{tabular}{cccm{2em}} +% \toprule +% \texttt{T} & \texttt{M} & \texttt{B} & Text \\ +% \adjustbox{valign=T}{\textcolor{red}{\rule{1em}{2em}\unskip}}\unskip +% \adjustbox{valign=T}{\textcolor{green}{\rule{1em}{3em}\unskip}}\unskip +% \adjustbox{valign=T}{\textcolor{blue}{\rule{1em}{1ex}\unskip}} & +% \adjustbox{valign=M}{\textcolor{red}{\rule{1em}{2em}\unskip}}\unskip +% \adjustbox{valign=M}{\textcolor{green}{\rule{1em}{3em}\unskip}}\unskip +% \adjustbox{valign=M}{\textcolor{blue}{\rule{1em}{1ex}\unskip}} & +% \adjustbox{valign=T}{\textcolor{red}{\rule{1em}{2em}\unskip}}\unskip +% \adjustbox{valign=T}{\textcolor{green}{\rule{1em}{3em}\unskip}}\unskip +% \adjustbox{valign=T}{\textcolor{blue}{\rule{1em}{1ex}\unskip}} & +% Mxy \newline \mbox{\vr Mxy}\newline Mxy \\ +% \midrule +% \texttt{t} & \texttt{m} & \texttt{b} & Text \\ +% \adjustbox{valign=t}{\textcolor{red}{\rule{1em}{2em}\unskip}}\unskip +% \adjustbox{valign=t}{\textcolor{green}{\rule{1em}{3em}\unskip}}\unskip +% \adjustbox{valign=t}{\textcolor{blue}{\rule{1em}{1ex}\unskip}} & +% \adjustbox{valign=m}{\textcolor{red}{\rule{1em}{2em}\unskip}}\unskip +% \adjustbox{valign=m}{\textcolor{green}{\rule{1em}{3em}\unskip}}\unskip +% \adjustbox{valign=m}{\textcolor{blue}{\rule{1em}{1ex}\unskip}} & +% \adjustbox{valign=t}{\textcolor{red}{\rule{1em}{2em}\unskip}}\unskip +% \adjustbox{valign=t}{\textcolor{green}{\rule{1em}{3em}\unskip}}\unskip +% \adjustbox{valign=t}{\textcolor{blue}{\rule{1em}{1ex}\unskip}} & +% Mxy \newline \mbox{\vr Mxy}\newline Mxy \\ +% \bottomrule +% \end{tabular}} % \endgroup % +% +% \DescribeKey{set height}'=' +% This sets the official height of the content without actual changing it. This can be seen as a form of trimming. +% It uses the same internal code as\\ +% \Macro\raisebox{'0pt'}[]{}. +% +% \begin{examples} +% \begin{examplecode} +% \adjustbox{set height=.5\height} +% {\shortstack{some stacked\\content}} +% \end{examplecode} +% \end{examples} +% +% \DescribeKey{set depth}'=' +% This sets the official depth of the content without actual changing it. This can be seen as a form of trimming. +% It uses the same internal code as\\ +% \Macro\raisebox{'0pt'}['\height'][]{}. +% +% \begin{examples} +% \begin{examplecode} +% \adjustbox{set depth=0pt} +% {\shortstack{some stacked\\content +% with \raisebox{-1ex}{depth}}} +% \end{examplecode} +% \end{examples} +% +% \DescribeKey{lap}'=' +% \DescribeKey{lap}'='{}{} +% This wraps the content into a +% \Macro\lapbox{}{\ldots} and +% \Macro\lapbox[]{}{\ldots}, respectively. Positive \meta{amounts} lap the content to the right +% and negative to the left. The optional \meta{length} argument allows to set the final width. +% +% \begin{examples} +% \begin{examplecode} +% \adjustbox{lap=.5\width}{Some content} +% \end{examplecode} +% \begin{examplecode} +% \adjustbox{lap=-.5\width}{Some content} +% \end{examplecode} +% \begin{examplecode} +% \adjustbox{lap=\width}{Some content} +% \end{examplecode} +% \begin{examplecode} +% \adjustbox{lap=-\width}{Some content} +% \end{examplecode} +% \begin{examplecode} +% \adjustbox{lap={\width}{\width}}{Some content} +% \end{examplecode} +% \begin{examplecode} +% \adjustbox{lap={\width}{-\width}}{Some content} +% \end{examplecode} +% \end{examples} +% +% +% \DescribeKey{center} +% \DescribeKey{center}'=' +% This key places +% the content in a horizontal box which is by default \Macro\linewidth wide (i.e.\ as wide as a normal text paragraph) +% and centers it in it. The effect is very similar to \Macro\centerline. The original content is unchanged, but simply identical +% white space is added as a left and right margin. This is useful if the content is a figure or table and can be used as a replacement +% for \Macro\centering. One important difference is that the content will then have the given width which might influence (sub-)caption +% placement. +% If the content is wider than the available width it will stick out on both sides equally without causing an overfull hbox warning. +% Note that when \Macro\adjustbox paragraph is used at the beginning of a paragraph the normal paragraph indention is added, which +% will push the while box to the right and might cause an overfull line. In such cases a \Macro\noindent must be added beforehand. +% The \env{adjustbox} environment already uses this macro. +% +% \begin{examples} +% \begin{examplecode} +% \adjustbox{center}{Some content} +% \end{examplecode} +% \begin{examplecode} +% \adjustbox{center=5cm}{Some content} +% \end{examplecode} +% \end{examples} +% +% \DescribeKey{right} +% \DescribeKey{right}'=' +% Like \Key{center} this key +% places the content in a box with the given width (by default \Macro\linewidth) but right aligns it. +% If the content is wider than the available width it will stick out into the left side without causing an overfull hbox warning. +% +% \begin{examples} +% \begin{examplecode} +% \adjustbox{right}{Some content} +% \end{examplecode} +% \begin{examplecode} +% \adjustbox{right=5cm}{Some content} +% \end{examplecode} +% \end{examples} +% +% +% \DescribeKey{left} +% \DescribeKey{left}'=' +% Like \Key{center} this key +% places the content in a box with the given width (by default \Macro\linewidth) but left aligns it. +% If the content is wider than the available width it will stick out into the right side without causing an overfull hbox warning. +% +% \begin{examples} +% \begin{examplecode} +% \adjustbox{left}{Some content} +% \end{examplecode} +% \begin{examplecode} +% \adjustbox{left=5cm}{Some content} +% \end{examplecode} +% \end{examples} +% +% +% +% \DescribeKey{inner} +% \DescribeKey{inner}'=' +% Like \Key{center}, \Key{left} and \Key{right} this key +% places the content in a box with the given width (by default \Macro\linewidth) but aligns it towards the inner margin. +% If the content is wider than the available width it will stick into the outer margin without causing an overfull hbox warning. +% In |twoside| mode this key is equal to \Key{left} for odd pages and equal to \Key{right} for even pages. +% For |oneside| mode it is always equal to \Key{center}, because there is no inner or outer margin. +% Note that the page-is-odd test might not always lead to correct results for some material close to a page boundary, because \TeX\ +% might not have decided on which page it will be placed. This can be improved by loading the \pkg{changepage} package with the +% \opt{strict} option, which uses a reference to determine the correct page number (and requires the usual additional compiler run). +% +% \DescribeKey{outer} +% \DescribeKey{outer}'=' +% Identical to \Key{inner} but aligns the content towards the outer margin. +% If the content is wider than the available width it will stick into the outer inner without causing an overfull hbox warning. +% +% +% \subsubsection{Pixel size} +% +% \DescribeKey{dpi}'=' +% The \Key{dpi} key provides a simple interface to set the pixel size to the given DPI (dots per inch) value. +% For |pdflatex| the length unit |px| can be used to specify pixels. However, the equivalent dimension (length) of one pixel must be +% set using the \Macro\pdfpxdimen length register. To set a specific DPI value this length must be set using +% \Macro\setlength\AlsoMacro\pdfpxdimen{'1in/'}, which is done by the \Key{dpi}'=' key. +% +% \begin{example} +% \begin{examplecode} +% \adjustbox{dpi=72,trim=10px,frame} +% {\textcolor{green}{\rule{50px}{50px}}} +% \end{examplecode} +% \end{example} +% +% \DescribeKey{pxdim}'=' +% Alternatively +% to the \Key{dpi} key the \Macro\pdfpxdimen length can be set directly to the given value. Afterwards |1px| will stand +% for the given \meta{length}. +% +% \begin{example} +% \begin{examplecode} +% \adjustbox{pxdim=2pt,trim=2px,frame} +% {\textcolor{green}{\rule{10px}{10px}}} +% \end{examplecode} +% \end{example} +% +% \subsection{Minipage or other inner Environment} +% The following keys will overwrite each other and only defined for \env{adjustbox} but do not apply for \Macro\includegraphics. +% Because they are therefore only used inside a mandatory argument and never in an optional these keys allow for optional bracket arguments. +% +% \DescribeKey{minipage}'=' +% \DescribeKey{minipage}'='[][][]{} +% This key wraps the inner content in a \env{minipage} with the given \meta{width} before it is stored as horizontal box. +% Its order relative to other keys is not meaningful (except that future keys of this sub-section will overwrite it). +% This allows for line breaks and footnotes in the \env{adjustbox}. +% All optional arguments of \env{minipage} are supported. I only the width is given it does not have to be enclosed in braces. +% The \meta{position} argument must be "t" for top baseline, "b" for bottom baseline and "c" for center alignment relative to other +% text, i.e.\ defines the resulting baseline. If a \meta{height} is defined the \meta{inner position} defaults to \meta{position} but +% can also be "s" to stretch the content over the whole height. This requires the content to include some vertical stretchable material. +% +% \begin{examples} +% \begin{examplecode} +% \adjustbox{minipage=5cm,angle=-10}{% +% Some example code which will +% be automatically broken or can include \\ +% line breaks\footnote{AND footnotes!!}\\ +% or verbatim \verb+@%^&}_+!% +% } +% \end{examplecode} +% \begin{examplecode} +% Before \begin{adjustbox}{minipage=[b][3cm][s]{5cm}} +% Some example code +% +% \vfill +% with line breaks\footnote{AND footnotes!!} +% +% \vfill +% or verbatim \verb+@%^&}_+!% +% \end{adjustbox} After +% \end{examplecode} +% \end{examples} +% +% \DescribeKey{innerenv}'=' +% \DescribeKey{innerenv}'='{} +% Wraps the inner content in the given \meta{environment} before it is stored as horizontal box. Only one inner environment can be used +% and further uses of this key will overwrite previous ones as well as any \Key{minipage} and \Key{innercode} key. +% It should be kept in mind that there is some internal code between the begin of the environment and the content. For this reason +% a \env{tabular}, \env{innerenv} or similar environment will not work here, because that code will be taken as part of the first cell. +% +% \begin{example} +% \begin{examplecode} +% \newenvironment{myenv}[2][]{Before [#1](#2)}{After} +% \adjustbox{innerenv={myenv}[ex]{amble}}{Content} +% \end{examplecode} +% \end{example} +% +% +% \DescribeKey{innercode}'='{}{} +% Places the given code before and after the inner content before it is stored as horizontal box. Only one set of inner code can be used +% and further uses of this key will overwrite previous ones as well as any \Key{minipage} and \Key{innerenv} key. +% +% \begin{example} +% \begin{examplecode} +% \adjustbox{innercode={\color{green}}{!}}{Content} +% \end{examplecode} +% \end{example} +% +% \subsection{Adding own Code or Environments} +% +% \DescribeKey{env}'=' +% \DescribeKey{env}'='{} +% Adds an \meta{environment} around the content and the already existing code around it which was added by other keys beforehand. +% Potential \meta{environment options} (or any other code) can follow the environment name if it was set inside braces. +% At this stage the content is already boxed and format macros won't have any effect on any included text. For this the \Key{innerenv} key needs to be used instead. +% +% \DescribeKey{addcode}'='{}{} +% Adds some \meta{code before} and some \meta{code after} the content and the +% already existing code around it which was added by other keys beforehand. +% At this stage the content is already boxed and format macros won't have any effect on any included text. +% +% \DescribeKey{appcode}'=' +% Appends come \meta{code after} the content and the already existing code around it which was added by other keys beforehand. +% More complex code should be enclosed in braces. +% +% \DescribeKey{precode}'=' +% Prepends come \meta{code afterwards} the content and the already existing code around it which was added by other keys beforehand. +% More complex code should be enclosed in braces. +% +% % \StopEventually{} % \clearpage -% \iffalse -%<*package> -% \fi % \section{Implementation} +% \setcounter{lstnumber}{1} % \ifenglish\else % Die Dokumentation des Quellcodes ist nur auf Englisch verfügbar. % \fi % +% \iffalse +%<*de> +%% Wrapper to set language to German and jobname to 'adjustbox-de'. +%% Does not have to be included in distributions or placed on CTAN. +\expandafter\newif\csname ifenglish\endcsname +\englishfalse +\input{adjustbox.dtx} +% +% \fi +% +% \iffalse +%<*adjustbox> +% \fi +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \subsection{Package header, options and dependencies} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % \begin{macrocode} -\RequirePackage{graphicx}[1999/02/16] -\RequirePackage{pgf} +\ProvidesPackage{adjustbox}[2011/08/07 v0.5 Adjusting TeX boxes (trim, clip, ...)] % \end{macrocode} % -% \begin{environment}{clipbox} -% \begin{macro}{\clipbox} % \begin{macrocode} -\newcommand\clipbox{% +\RequirePackage{xkeyval} + +\def\adjbox@defaultunit{bp} +\DeclareOptionX{defaultunit}{% + \def\adjbox@defaultunit{#1}% \begingroup - \def\adjustbox@name{clipbox}% - \@ifstar - {\adjustbox@{clip,viewport=}}% - {\adjustbox@{clip,trim=}}% -} -% \end{macrocode} -% \end{macro} -% \begin{macrocode} -\def\endclipbox{% - \endadjustbox + \def\@tempa{none}% + \expandafter\endgroup + \ifx\@tempa\adjbox@defaultunit + \def\adjbox@default{\adjsetlength}% + \fi } + +\def\adjbox@fam{adjbox} +\DeclareOptionX{export}{\def\adjbox@fam{Gin}} +\DeclareOptionX{patch}{\AtEndOfPackage{\RequirePackage{adjgrfx}}} +\DeclareOptionX{minimal}{\let\adjbox@maybeend\endinput} + +\def\adjbox@driver{adj\Gin@driver} +\DeclareOptionX{pgf}{\def\adjbox@driver{adjpgf.def}} +\DeclareOptionX{PGF}{\def\adjbox@driver{adjpgf.def}\adjcalc@pgfmath} +\DeclareOptionX*{\PassOptionsToPackage\CurrentOption{graphicx}} + +\let\adjbox@maybeend\relax +\input{adjcalc.sty} +\disable@keys{adjbox}{patch,export,PGF,minimal} % \end{macrocode} -% \end{environment} % -% \begin{environment}{clipbox*} % \begin{macrocode} -\newenvironment{clipbox*} - {\begin{clipbox}*} - {\end{clipbox}} +\RequirePackage{graphicx}[1999/02/16] +\RequirePackage{collectbox}[2011/08/06] % \end{macrocode} -% \end{environment} % -% \begin{environment}{trimbox} -% \begin{macro}{\trimbox} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \subsection{Basic commands} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% \begin{macro}{\adjbox@viewport} % \begin{macrocode} -\newcommand\trimbox{% - \begingroup - \def\adjustbox@name{trimbox}% - \@ifstar - {\adjustbox@{viewport=}}% - {\adjustbox@{trim=}}% +\define@key{adjbox}{viewport}{% + \let\Gin@viewport@code\adjbox@@viewport + \let\adjustbox@@@\adjustbox@@@trimclip + \adjbox@parse@v{#1}% } % \end{macrocode} % \end{macro} -% \begin{macrocode} -\def\endtrimbox{% - \endadjustbox -} -% \end{macrocode} -% \end{environment} % -% \begin{environment}{trimbox*} -% \begin{macrocode} -\newenvironment{trimbox*} - {\begin{trimbox}*} - {\end{trimbox}} -% \end{macrocode} -% \end{environment} % -% \begin{environment}{adjustbox} -% \begin{macro}{\adjustbox} +% \begin{macro}{\adjbox@trim} % \begin{macrocode} -\newcommand\adjustbox{% - \begingroup - \def\adjustbox@name{adjustbox}% - \adjustbox@{}% +\define@key{adjbox}{trim}{% + \let\Gin@viewport@code\adjbox@@trim + \let\adjustbox@@@\adjustbox@@@trimclip + \adjbox@parse@v{#1}% } % \end{macrocode} % \end{macro} -% \begin{macrocode} -\def\endadjustbox{% - \unskip - \egroup - \color@endgroup - \egroup - \adjustbox@@ -} -% \end{macrocode} -% \end{environment} % % -% \begin{macro}{\adjustbox@} +% \begin{macro}{\adjustbox@@@trimclip} % \begin{macrocode} -\def\adjustbox@#1#2{% - \def\adjustbox@setkeys{\setkeys{Gin}{#1#2}}% - \ifx\@currenvir\adjustbox@name - \edef\@currenvir{\@currenvir\noexpand\empty}% - \def\next{% - \setbox\@tempboxa\hbox\bgroup - \color@setgroup\bgroup - \ignorespaces - }% +\def\adjustbox@@@trimclip{% + \Gin@viewport@code + \ifGin@clip + \expandafter\@clipbox \else - \def\next{% - \setbox\@tempboxa\hbox\bgroup%0 - \color@setgroup\bgroup% - \aftergroup\color@endgroup - \aftergroup\egroup% - \aftergroup\adjustbox@@ - \@ifnextchar\bgroup - {\let\@let@token=}% - {\adjust@box}% - }% + \expandafter\@trimbox \fi - \next + \adjbox@tllx + \adjbox@tlly + \adjbox@turx + \adjbox@tury + \collectedbox + \usebox\collectedbox } % \end{macrocode} % \end{macro} % -% \begin{macro}{\adjust@box} +% +% +% \begin{macro}{\adjbox@parse@v} % \begin{macrocode} -\def\adjust@box#1{% - #1\egroup +\def\adjbox@parse@v#1{% + \adjbox@parse@@v#1 {} {} {} \\% } +\def\adjbox@parse@@v#1 #2 #3 #4 #5\\{% + \adjbox@default\adjbox@tllx{#1}% + \ifx\@nnil#2\@nnil + \adjbox@tlly\adjbox@tllx + \adjbox@turx\adjbox@tllx + \adjbox@tury\adjbox@tlly + \else + \adjbox@default\adjbox@tlly{#2}% + \ifx\@nnil#3\@nnil + \adjbox@turx\adjbox@tllx + \adjbox@tury\adjbox@tlly + \else + \adjbox@default\adjbox@turx{#3}% + \adjbox@default\adjbox@tury{#4}% + \fi + \fi +}% +%%\newdimen\adjbox@llx +%%\newdimen\adjbox@lly +%%\newdimen\adjbox@urx +%%\newdimen\adjbox@ury +\newdimen\adjbox@tllx +\newdimen\adjbox@tlly +\newdimen\adjbox@turx +\newdimen\adjbox@tury % \end{macrocode} % \end{macro} % -% \begin{macro}{\adjustbox@@} -% \begin{macrocode} -\def\adjustbox@@{% -% \end{macrocode} -% Set the box dimension macros. -% \begin{macrocode} - \def\width{\wd\@tempboxa}% - \def\height{\ht\@tempboxa}% - \def\depth{\dp\@tempboxa}% - \@tempdimc=\ht\@tempboxa - \advance\@tempdimc by \dp\@tempboxa\relax - \def\totalheight{\@tempdimc}% -% \end{macrocode} -% Locally redefine \Macro\Gin@defaultbp to use \Macro\pgfmathsetmacro -% with |bp| as the default unit. -% This should yield the same results (apart of smaller rounding errors) if values -% are given without unit but avoids the internal conversion to |bp| of values with -% units. -% \begin{macrocode} - \def\pgfmathresultunitscale{1bp}% - \let\pgfmathpostparse\pgfmathscaleresult - \let\Gin@defaultbp\pgfmathsetmacro - \let\setlength\pgfmathsetlength -% \end{macrocode} -% The rest of the code was adapted from the \Macro\Gin@ii macro from the |graphicx| package. -% The \emph{temp switch a} is set to |true| to indicate to |graphicx| that the -% scaling should be done internal, so this package doesn't have to do it. -% The content including macro \Macro\adjustbox@@@ is but into place, -% the saved options are activated and the final size is set. -% The typesetting of the content is finally done by executing the token register. +% +% +% \begin{macro}{\adjbox@@trim} % \begin{macrocode} - \@tempswatrue - \toks@{{\adjustbox@@@}}% - \adjustbox@setkeys - \Gin@esetsize - \the\toks@ - \endgroup -} +\let\adjbox@@trim\relax % \end{macrocode} % \end{macro} % -% \begin{macro}{\adjustbox@@@} +% +% \begin{macro}{\adjbox@@viewport} % \begin{macrocode} -\def\adjustbox@@@{% - \def\Gin@llx{0}% - \Gin@defaultbp\Gin@lly{+-\dp\@tempboxa}% - \Gin@defaultbp\Gin@urx{+\wd\@tempboxa}% - \Gin@defaultbp\Gin@ury{+\ht\@tempboxa}% - \Gin@viewport@code - \begin{pgfpicture}% - \pgfpathmoveto{\pgfqpoint{\Gin@llx pt}{\Gin@lly pt}}% - \pgfpathlineto{\pgfqpoint{\Gin@urx pt}{\Gin@lly pt}}% - \pgfpathlineto{\pgfqpoint{\Gin@urx pt}{\Gin@ury pt}}% - \pgfpathlineto{\pgfqpoint{\Gin@llx pt}{\Gin@ury pt}}% - \pgfpathclose - \expandafter\pgfusepath\ifGin@clip{clip}\else{use as bounding box}\fi\relax - \pgfset{inner sep=\z@,outer sep=\z@}% - \pgfnode{rectangle}{base west}{\box\@tempboxa}{ADJUSTBOX@NODE}{}% - \pgfsetbaselinepointnow{\pgfpointanchor{ADJUSTBOX@NODE}{base}}% - \end{pgfpicture}% +\def\adjbox@@viewport{% + %\advance\adjbox@tllx by -\z@ + \advance\adjbox@tlly by \dp\collectedbox + \advance\adjbox@turx by -\wd\collectedbox + \advance\adjbox@tury by -\ht\collectedbox + \adjbox@turx=-\adjbox@turx + \adjbox@tury=-\adjbox@tury } % \end{macrocode} % \end{macro} % -% \Finale -% \iffalse -% -%<*de> -%% Wrapper to set language to German and jobname to 'adjustbox-de'. -%% Does not have to be included in distributions or placed on CTAN. -\expandafter\newif\csname ifenglish\endcsname -\englishfalse -\input{adjustbox.dtx} -% +% +% \begin{macro}{\trimbox} +% \begin{macrocode} +\newcommand\trimbox{% + \collectboxcheckenv{trimbox}% + \@ifstar + \trimbox@s + \trimbox@ +} +\def\trimbox@#1{% + \collectbox{\trimbox@@\@trimbox{#1}}% +} +\def\trimbox@s#1{% + \collectbox{\trimbox@@{\adjbox@@viewport\@trimbox}{#1}}% +} +\def\trimbox@@#1#2{% + \adjbox@parse@v{#2}% + #1% + \adjbox@tllx + \adjbox@tlly + \adjbox@turx + \adjbox@tury + \collectedbox + \usebox\collectedbox +} +% \end{macrocode} +% \end{macro} +% +% \begin{environment}{trimbox*} +% \begin{macrocode} +\expandafter\newcommand\expandafter*\csname trimbox*\endcsname{% + \@collectboxisenv{trimbox*}% + \trimbox@s +} +% \end{macrocode} +% \end{environment} +% +% +% \begin{macro}{\clipbox} +% \begin{macrocode} +\newcommand\clipbox{% + \collectboxcheckenv{clipbox}% + \@ifstar + \clipbox@s + \clipbox@ +} +\def\clipbox@#1{% + \collectbox{\trimbox@@\@clipbox{#1}}% +} +\def\clipbox@s#1{% + \collectbox{\trimbox@@{\adjbox@@viewport\@clipbox}{#1}}% +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{environment}{clipbox*} +% \begin{macrocode} +\expandafter\newcommand\expandafter*\csname clipbox*\endcsname{% + \@collectboxisenv{clipbox*}% + \clipbox@s +} +% \end{macrocode} +% \end{environment} +% +% +% \begin{macro}{\adjustbox} +% Now processes the keys before the box is read to allow for parbox or similar modes. +% +% This code was originally adapted from the \Macro\Gin@ii macro from the |graphicx| package. +% The \emph{temp switch a} is set to |true| to indicate to |graphicx| that the +% scaling should be done internal, so this package doesn't have to do it. +% The content including macro \Macro\adjustbox@@@ is but into place, +% the saved options are activated and the final size is set. +% The typesetting of the content is finally done by executing the token register. +% \begin{macrocode} +\newcommand\adjustbox[1]{% + \collectboxcheckenv{adjustbox}% + \begingroup + \adjustbox@dimcmds + \let\Gin@esetsize\adjbox@esetsize + \@tempswatrue + \toks@{{\adjustbox@@@@}}% + \def\setlength{\adjsetlength}% + \setkeys{adjbox,Gin}{#1}% + \adjbox@esetsize + \adjbox@collectbox{\the\toks@\endgroup}% +} +\let\adjbox@collectbox\@collectbox +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\adjustbox@@@@} +% Content wrapper which might be redefined when the size is specified. +% \begin{macrocode} +\def\adjustbox@@@@{\adjustbox@@@}% +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\adjbox@esetsize} +% Replacement of \Macro\Gin@esetsize. +% Now always called in external mode. Checks if any size is set and, as an optimation, does nothing otherwise. +% +% OLD: +% When called in \emph{external} mode (switch is true) then the content is wrapped in +% the internal form of \Macro\resizebox. In \emph{internal} mode, i.e.\ resizing is done by the graphic driver, +% the same code is added around the inner macro. This ensures the same behaviour as \Macro\includegraphics. +% \begin{macrocode} +\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 +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\adjustbox@dimcmds} +% Inits the dimension macro in an unexpandedable way. They will be redefined to the correct +% values by \Macro\collectbox. +% \begin{macrocode} +\def\adjustbox@dimcmds{% + \let\width\relax + \let\height\relax + \let\depth\relax + \let\totalheight\relax +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\adjustbox@@@} +% \begin{macrocode} +\def\adjustbox@@@{% + \usebox\collectedbox +} +% \end{macrocode} +% \end{macro} +% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \subsubsection{Low-level trim and clip boxes} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% \begin{macro}{\@trimbox} +% \begin{macrocode} +\def\@trimbox#1#2#3#4#5{% + \setbox#5=\hbox{% + \adjsetlength\@tempdima{#1}% + \hskip-\@tempdima + \adjsetlength\@tempdima{\dp#5 - (#2)}% + \adjsetlength\@tempdimb{\wd#5 - (#3)}% + \adjsetlength\@tempdimc{\ht#5 - (#4)}% + \dp#5=\@tempdima + \wd#5=\@tempdimb + \ht#5=\@tempdimc + \ifdim\dp#5<\z@ + \raise\dp#5% + \else + \ifdim\ht#5<\z@ + \lower\ht#5% + \fi\fi + \box#5% + }% + \ifdim\dp#5<\z@ \dp#5=\z@ \fi + \ifdim\wd#5<\z@ \wd#5=\z@ \fi + \ifdim\ht#5<\z@ \ht#5=\z@ \fi +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\@clipbox} +% \begin{macrocode} +\def\@clipbox#1#2#3#4#5{% + \@trimbox{#1}{#2}{#3}{#4}{#5}% + \pdfxform#5% + \setbox#5=\hbox{% + \pdfrefxform\pdflastxform + }% +} +% \end{macrocode} +% \end{macro} +% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \subsection{Driver} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% The clipping support is output driver dependent. The driver selected by \pkg{graphics} is used and a definition file +% is used if its exists. Otherwise either the default \texttt{pdftex} implementation or the \pkg{pgf} fall-back driver +% is used. +% \begin{macrocode} +\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 +} +% \end{macrocode} +% +% +% Stop here if 'minimal' option was used. +% \begin{macrocode} +\adjbox@maybeend +% \end{macrocode} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \subsection{More box commands} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% \begin{macro}{\phantombox}[3]{width}{height}{depth} +% Produces an empty box with the given width, height and depth. +% \begin{macrocode} +\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 +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\minsizebox} +% \begin{macrocode} +\newcommand*\minsizebox{% + \collectboxcheckenv{minsizebox}% + \@ifstar{\@minsizebox\totalheight}{\@minsizebox\height}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{environment}{minsizebox*} +% \begin{macrocode} +\expandafter\newcommand\expandafter*\csname minsizebox*\endcsname{% + \@collectboxisenv{minsizebox*}% + \@minsizebox\totalheight +} +% \end{macrocode} +% \end{environment} +% +% +% \begin{macro}{\@minsizebox} +% \begin{macrocode} +\newcommand*\@minsizebox[3]{% + \@collectbox{\@minmaxsizebox>#1{#2}{#3}}% +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\maxsizebox} +% \begin{macrocode} +\newcommand*\maxsizebox{% + \collectboxcheckenv{maxsizebox}% + \@ifstar{\@maxsizebox\totalheight}{\@maxsizebox\height}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{environment}{maxsizebox*} +% \begin{macrocode} +\expandafter\newcommand\expandafter*\csname maxsizebox*\endcsname{% + \@collectboxisenv{maxsizebox*}% + \@maxsizebox\totalheight +} +% \end{macrocode} +% \end{environment} +% +% +% \begin{macro}{\@maxsizebox} +% \begin{macrocode} +\newcommand*\@maxsizebox[3]{% + \@collectbox{\@minmaxsizebox<#1{#2}{#3}}% +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\@minmaxsizebox}[4]{Compare sign \texttt{<} or \texttt{>}}{\cs{height} or \cs{totalheight}}{width}{height} +% Used for all min/max-size boxes including the starred version. The first two arguments determine the style. +% +% The width and height values are expanded to allow for \Macro\ifdim or similar conditionals. +% \begin{macrocode} +\newcommand*\@minmaxsizebox[4]{% + \edef\@tempa{#3}% + \edef\@tempb{#4}% + \ifcase0% +% \end{macrocode} +% Do nothing if both values are `|!|', otherwise use case 1 if the height is to large/small (|#1|) +% than the \Macro\height or \Macro\totalheight (|#2|). +% \begin{macrocode} + \ifx\@tempa\Gin@exclamation + \ifx\@tempb\Gin@exclamation + \else + \ifdim\@tempb#1#2% + 1% + \fi + \fi + \else +% \end{macrocode} +% If the width is given, but not the height, use case 2 if the width is to large/small (|#1|) than the native \Macro\width. +% \begin{macrocode} + \ifx\@tempb\Gin@exclamation + \ifdim\@tempa#1\width + 2% + \fi + \else +% \end{macrocode} +% If both values are given. +% Use case 0-3 depending if the width and/or height is to large/small. +% \begin{macrocode} + \ifdim\@tempa#1\width + \ifdim\@tempb#1#2% + 3% + \else + 2% + \fi + \else + \ifdim\@tempb#1#2% + 1% + \fi + \fi + \fi + \fi +% \end{macrocode} +% Case 0: no scaling is needed. Insert content unchanged. +% \begin{macrocode} + \relax% 0 + \BOXCONTENT +% \end{macrocode} +% Case 1: height needs scaling. Calculate factor and scale the content with it. +% \begin{macrocode} + \or + \adjsetlength\@tempdima\@tempb + \Gscale@div\@tempa\@tempdima#2% + \Gscale@box\@tempa[\@tempa]\BOXCONTENT +% \end{macrocode} +% Case 2: width needs scaling. Calculate factor and scale the content with it. +% \begin{macrocode} + \or + \adjsetlength\@tempdima\@tempa + \Gscale@div\@tempa\@tempdima\width + \Gscale@box\@tempa[\@tempa]\BOXCONTENT +% \end{macrocode} +% Case 3: both width and height need scaling. +% Both scale factors are calculated and the more extreme value is used. +% \begin{macrocode} + \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 +} +% \end{macrocode} +% \end{macro} +% +% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \subsection{New \cs{includegraphics} and \cs{adjustbox} options} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% \begin{key}{adjbox}{Trim} +% \begin{macrocode} +\define@key\adjbox@fam{Trim}{% + \adjbox@Gin@Add{\trimbox@{#1}}% +} +% \end{macrocode} +% \end{key} +% +% \begin{key}{adjbox}{Viewport} +% \begin{macrocode} +\define@key\adjbox@fam{Viewport}{% + \adjbox@Gin@Add{\trimbox@s{#1}}% +} +% \end{macrocode} +% \end{key} +% +% \begin{key}{adjbox}{Clip} +% \begin{macrocode} +\define@key\adjbox@fam{Clip}{% + \adjbox@Gin@Add{\clipbox@{#1}}% +} +% \end{macrocode} +% \end{key} +% +% \begin{key}{adjbox}{Clip*} +% \begin{macrocode} +\define@key\adjbox@fam{Clip*}{% + \adjbox@Gin@Add{\clipbox@s{#1}}% +} +% \end{macrocode} +% \end{key} +% +% +% \begin{key}{adjbox}{frame} +% \begin{macrocode} +\define@key\adjbox@fam{frame}[{{\fboxrule}}]{% + \adjbox@frame{\fboxsep\z@}#1 {} {} \relax\relax\@nnil +} +% \end{macrocode} +% \end{key} +% +% +% \begin{key}{adjbox}{fbox} +% \begin{macrocode} +\define@key\adjbox@fam{fbox}[{{\fboxrule}}]{% + \adjbox@frame{}#1 {} {} {} \relax\relax\@nnil +} +% \end{macrocode} +% \end{key} +% +% +% \begin{macro}{\adjbox@frame} +% \begin{macrocode} +\def\adjbox@frame#1#2 #3 #4 #5\relax{% + \adjbox@Gin@Add{% + \@collectbox{#1\adjbox@@frame{}{#2}{#3}{#4}}% + }% + \remove@to@nnil +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{key}{adjbox}{cframe} +% \begin{macrocode} +\define@key\adjbox@fam{cframe}{% + \adjbox@cframe{\fboxsep\z@}#1 {} {} {} \relax\relax\@nnil +} +% \end{macrocode} +% \end{key} +% +% \begin{key}{adjbox}{cfbox} +% \begin{macrocode} +\define@key\adjbox@fam{cfbox}{% + \adjbox@cframe{}#1 {} {} {} \relax\relax\@nnil +} +% \end{macrocode} +% \end{key} +% +% \begin{macro}{\adjbox@cframe} +% \begin{macrocode} +\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 +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\adjbox@@frame} +% \begin{macrocode} +\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\adjbox@tllx{\fboxrule + \fboxsep}% + \@marginbox + \adjbox@tllx + \adjbox@tllx + \adjbox@tllx + \adjbox@tllx + \collectedbox + \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\adjbox@tllx{#4}% + \@marginbox + \adjbox@tllx + \adjbox@tllx + \adjbox@tllx + \adjbox@tllx + \collectedbox + \BOXCONTENT + \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\adjbox@boxframe} +% Tries to reuse the definition of the \pkg{xcolor} package. +% If it isn't loaded its definition is defined here. +% +% This code was taken from the \pkg{xcolor} package under the free LPPL license. +% \begin{macrocode} +\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 + }% + }% +} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{key}{adjbox}{scale} +% \begin{macrocode} +\define@key\adjbox@fam{scale}{% + \@ifnextchar\bgroup{% + \adjbox@scale@xy + }{% + \adjbox@scale@x + }#1\@nnil +} +% \end{macrocode} +% \end{key} +% +% \begin{macro}{\adjbox@scale@x} +% \begin{macrocode} +\def\adjbox@scale@x#1\@nnil{% + \adjbox@scale@xy{#1}{#1}\@nnil% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\adjbox@scale@xy} +% \begin{macrocode} +\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 +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{key}{adjbox}{reflect} +% Taken from the \Key{scale} key of the \pkg{graphicx} package. +% Open question: why is \Macro\Gin@esetsize not called? +% \begin{macrocode} +\define@key\adjbox@fam{reflect}[]{% + \adjbox@scale@xy{-1}{1}\@nnil +} +% \end{macrocode} +% \end{key} +% +% +% \begin{key}{adjbox}{rotate} +% New alias of existing |angle| key. +% \begin{macrocode} +\expandafter\let\csname KV@\adjbox@fam @rotate\endcsname\KV@Gin@angle +% \end{macrocode} +% \end{key} +% +% +% \begin{key}{adjbox}{lap} +% \begin{macrocode} +\define@key\adjbox@fam{lap}{% + \@ifnextchar\bgroup{% + \adjbox@lapbox + }{% + \adjbox@lapbox{#1}{}% + }#1{}{}\@nnil +} +% \end{macrocode} +% \end{key} +% +% +% \begin{macro}{\adjbox@lapbox} +% \begin{macrocode} +\def\adjbox@lapbox#1#2#3\@nnil{% + \ifx\@nnil#2\@nnil + \adjbox@Gin@Add{\lapbox{#1}}% + \else + \adjbox@Gin@Add{\lapbox[{#1}]{#2}}% + \fi +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{key}{adjbox}{margin} +% \begin{macrocode} +\define@key\adjbox@fam{margin}{% + \adjbox@Gin@Add{\marginbox@{#1}}% +} +% \end{macrocode} +% \end{key} +% +% \begin{key}{adjbox}{margin*} +% \begin{macrocode} +\define@key\adjbox@fam{margin*}{% + \adjbox@Gin@Add{\marginbox@s{#1}}% +} +% \end{macrocode} +% \end{key} +% +% +% \begin{key}{adjbox}{dpi} +% \begin{macrocode} +\define@key\adjbox@fam{dpi}{% + \adjsetlength\pdfpxdimen{1in/(#1)}% +} +% \end{macrocode} +% \end{key} +% +% +% \begin{key}{adjbox}{pxdim} +% \begin{macrocode} +\define@key\adjbox@fam{pxdim}{% + \adjsetlength\pdfpxdimen{#1}% +} +% \end{macrocode} +% \end{key} +% +% +% \begin{macrocode} +\define@key\adjbox@fam{execute}{% + #1% +} +% \end{macrocode} +% +% +% \begin{key}{adjbox}{raise} +% \begin{macrocode} +\define@key\adjbox@fam{raise}{% + \@ifnextchar\bgroup{% + \adjbox@raisebox + }{% + \adjbox@raisebox{#1}{}{}% + }#1{}{}{}\@nnil +} +% \end{macrocode} +% \end{key} +% +% +% \begin{macro}{\adjbox@raisebox} +% \begin{macrocode} +\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 +} +% \end{macrocode} +% \end{macro} +% +% \begin{key}{adjbox}{valign} +% \begin{macrocode} +\define@key\adjbox@fam{valign}{% + \csname adjbox@valign@#1\endcsname +} +% \end{macrocode} +% \end{key} +% +% +% \begin{macro}{\adjboxvtop} +% \begin{macrocode} +\def\adjboxvtop{\ht\strutbox} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\adjboxvcenter} +% \begin{macrocode} +\def\adjboxvcenter{1ex} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\adjboxvbottom} +% \begin{macrocode} +\def\adjboxvbottom{-\dp\strutbox} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\adjbox@valign@t} +% \begin{macrocode} +\def\adjbox@valign@t{% + \adjbox@Gin@Add{\@irsbox{\height+\adjboxvtop}[]}% +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\adjbox@valign@T} +% \begin{macrocode} +\def\adjbox@valign@T{% + \adjbox@Gin@Add{\@irsbox{-\height}[]}% +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\adjbox@valign@M} +% \begin{macrocode} +\def\adjbox@valign@M{% + \adjbox@Gin@Add{\@irsbox{.5\depth-.5\height}[]}% +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\adjbox@valign@m} +% \begin{macrocode} +\def\adjbox@valign@m{% + \adjbox@Gin@Add{\@irsbox{.5\depth-.5\height+\adjboxvcenter}[]}% +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\adjbox@valign@b} +% \begin{macrocode} +\def\adjbox@valign@b{% + \adjbox@Gin@Add{\@irsbox{\depth+\adjboxvbottom}[]}% +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\adjbox@valign@B} +% \begin{macrocode} +\def\adjbox@valign@B{% + \adjbox@Gin@Add{\@irsbox{\depth}[]}% +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{key}{adjbox}{bgcolor} +% \begin{macrocode} +\define@key\adjbox@fam{bgcolor}{% + \adjbox@Gin@add{\colorbox{#1}}% +} +% \end{macrocode} +% \end{key} +% +% +% \begin{key}{adjbox}{set height} +% \begin{macrocode} +\define@key\adjbox@fam{set height}{% + \adjbox@Gin@Add{\@irsbox\z@[{#1}]}% +} +% \end{macrocode} +% \end{key} +% +% +% \begin{key}{adjbox}{set depth} +% \begin{macrocode} +\define@key\adjbox@fam{set depth}{% + \adjbox@Gin@Add{\@iirsbox\z@[\height][{#1}]}% +} +% \end{macrocode} +% \end{key} +% +% +% \begin{macro}{\adjbox@Gin@add} +% \begin{macrocode} +\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 +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\adjbox@Gin@sizeadd} +% Checks if key-value is actually two arguments. If not it is doubled. +% E.g.: \verb+min size=\A+ is the same as \verb+min size={\A}{\A}+ +% \begin{macrocode} +\def\adjbox@Gin@sizeadd#1#2#3\relax{% + \ifx\@nnil#3\@nnil + \adjbox@Gin@add{#1{#2}{#2}}% + \else + \adjbox@Gin@add{#1{#2}{#3}}% + \fi +} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\adjbox@halign} +% \begin{macrocode} +\def\adjbox@halign#1#2#3{% + \Gin@esetsize + \@tempswatrue + \adjsetlength\@tempdima{#1}% + \edef\@tempa{\hb@xt@\the\@tempdima}% + \toks@\expandafter\expandafter\expandafter{\expandafter\@tempa\expandafter{\expandafter#2\the\toks@#3}}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{key}{adjbox}{center} +% \begin{macrocode} +\define@key\adjbox@fam{center}[\linewidth]{% + \adjbox@halign{#1}\hss\hss +} +% \end{macrocode} +% \end{key} +% +% \begin{key}{adjbox}{left} +% \begin{macrocode} +\define@key\adjbox@fam{left}[\linewidth]{% + \adjbox@halign{#1}\hss\relax +} +% \end{macrocode} +% \end{key} +% +% \begin{key}{adjbox}{right} +% \begin{macrocode} +\define@key\adjbox@fam{right}[\linewidth]{% + \adjbox@halign{#1}\relax\hss +} +% \end{macrocode} +% \end{key} +% +% \begin{key}{adjbox}{outer} +% \begin{macrocode} +\define@key\adjbox@fam{outer}[\linewidth]{% + \def\@tempa{\adjbox@halign{#1}}% + \if@twoside + \adjbox@ifoddpage + {\@tempa\hss\relax}% + {\@tempa\relax\hss}% + \else + \@tempa\hss\hss + \fi +} +% \end{macrocode} +% \end{key} +% +% \begin{key}{adjbox}{inner} +% \begin{macrocode} +\define@key\adjbox@fam{inner}[\linewidth]{% + \def\@tempa{\adjbox@halign{#1}}% + \if@twoside + \adjbox@ifoddpage + {\@tempa\relax\hss}% + {\@tempa\hss\relax}% + \else + \@tempa\hss\hss + \fi +} +% \end{macrocode} +% \end{key} +% +% \begin{macro}{\adjbox@ifoddpage} +% \begin{macrocode} +\def\adjbox@ifoddpage{% + \begingroup + \adjbox@checkoddpage + \expandafter\endgroup + \ifoddpage + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\adjbox@checkoddpage} +% \begin{macrocode} +\def\adjbox@checkoddpage{% + \ifodd\c@page + \oddpagetrue + \else + \oddpagefalse + \fi +}% +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +\newif\ifoddpage +\AtBeginDocument{% + \@ifpackageloaded{changepage}{\let\adjbox@checkoddpage\checkoddpage}% + {\@ifpackageloaded{chngpage}{\let\adjbox@checkoddpage\checkoddpage}{}}% +}% +% \end{macrocode} +% +% \begin{key}{adjbox}{min width} +% \begin{macrocode} +\define@key\adjbox@fam{min width}{% + \adjbox@Gin@Add{\@minsizebox\height{#1}!}% +} +% \end{macrocode} +% \end{key} +% +% +% \begin{key}{adjbox}{max width} +% \begin{macrocode} +\define@key\adjbox@fam{max width}{% + \adjbox@Gin@Add{\@maxsizebox\height{#1}!}% +} +% \end{macrocode} +% \end{key} +% +% +% \begin{key}{adjbox}{min height} +% \begin{macrocode} +\define@key\adjbox@fam{min height}{% + \adjbox@Gin@Add{\@minsizebox\height!{#1}}% +} +% \end{macrocode} +% \end{key} +% +% +% \begin{key}{adjbox}{max height} +% \begin{macrocode} +\define@key\adjbox@fam{max height}{% + \adjbox@Gin@Add{\@maxsizebox\height!{#1}}% +} +% \end{macrocode} +% \end{key} +% +% +% \begin{key}{adjbox}{min totalheight} +% \begin{macrocode} +\define@key\adjbox@fam{min totalheight}{% + \adjbox@Gin@Add{\@minsizebox\totalheight!{#1}}% +} +% \end{macrocode} +% \end{key} +% +% +% \begin{key}{adjbox}{max totalheight} +% \begin{macrocode} +\define@key\adjbox@fam{max totalheight}{% + \adjbox@Gin@Add{\@maxsizebox\totalheight!{#1}}% +} +% \end{macrocode} +% \end{key} +% +% +% \begin{key}{adjbox}{min size} +% \begin{macrocode} +\define@key\adjbox@fam{min size}{% + \adjbox@Gin@sizeadd{\@minsizebox\height}#1\relax +} +% \end{macrocode} +% \end{key} +% +% +% \begin{key}{adjbox}{max size} +% \begin{macrocode} +\define@key\adjbox@fam{max size}{% + \adjbox@Gin@sizeadd{\@maxsizebox\height}#1\relax +} +% \end{macrocode} +% \end{key} +% +% +% \begin{key}{adjbox}{min totalsize} +% \begin{macrocode} +\define@key\adjbox@fam{min totalsize}{% + \adjbox@Gin@sizeadd{\@minsizebox\totalheight}#1\relax +} +% \end{macrocode} +% \end{key} +% +% +% \begin{key}{adjbox}{max totalsize} +% \begin{macrocode} +\define@key\adjbox@fam{max totalsize}{% + \adjbox@Gin@sizeadd{\@maxsizebox\totalheight}#1\relax +} +% \end{macrocode} +% \end{key} +% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \subsubsection{Lap box} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% \begin{macro}{\lapbox} +% \begin{macrocode} +\newcommand*\lapbox[2][\width-\@tempdimb]{% + \collectboxcheckenv{lapbox}% + \@collectbox{\@lapbox{#1}{#2}}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@lapbox} +% \begin{macrocode} +\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 +} +% \end{macrocode} +% \end{macro} +% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \subsubsection{Margin box} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% \begin{macro}{\marginbox}[1]{Margins as space separated values (like for 'trim')} +% Collect box first. +% \begin{macrocode} +\newcommand\marginbox{% + \collectboxcheckenv{marginbox}% + \@ifstar + \marginbox@s + \marginbox@ +} +\def\marginbox@#1{% + \@collectbox{\marginbox@@{#1}}% +} +\def\marginbox@s#1{% + \@collectbox{\marginbox@@s{#1}}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{environment}{marginbox*}[1]{Margins as space separated values (like for 'trim')} +% \begin{macrocode} +\expandafter\newcommand\expandafter*\csname marginbox*\endcsname{% + \@collectboxisenv{marginbox*}% + \marginbox@s +} +% \end{macrocode} +% \end{environment} +% +% +% \begin{macro}{\marginbox@@} +% (1) Parse margins (must be done here to allow the user to use the original box dimensions). +% (2) Change box margins and (3) place the box. +% \begin{macrocode} +\def\marginbox@@#1{% + \adjbox@parse@v{#1}% + \@marginbox + \adjbox@tllx + \adjbox@tlly + \adjbox@turx + \adjbox@tury + \collectedbox + \usebox\collectedbox +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\marginbox@@s} +% (1) Parse margins (must be done here to allow the user to use the original box dimensions). +% (2) Change box margins and (3) raise the box by the bottom margin to preserve original depth. +% \begin{macrocode} +\def\marginbox@@s#1{% + \adjbox@parse@v{#1}% + \@marginbox + \adjbox@tllx + \adjbox@tlly + \adjbox@turx + \adjbox@tury + \collectedbox + \raise\adjbox@tlly\copy\collectedbox +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\@marginbox} +% Adds the given margins to the depth, width and height. +% The left margin is created by an horizontal skip. +% This implementation assumes that the margins are positive and no special checks are added. +% While negative margins will trim some margin off, this will not lead to correct results if this amounts +% are larger than the existing dimensions. For this the \Macro\trimbox macro should be used. +% \begin{macrocode} +\def\@marginbox#1#2#3#4#5{% + \setbox#5=\hbox{% + \adjsetlength\@tempdima{#1}% + \hskip\@tempdima + \adjsetlength\@tempdima{\dp#5 + #2}% + \adjsetlength\@tempdimb{\wd#5 + #3}% + \adjsetlength\@tempdimc{\ht#5 + #4}% + \dp#5=\@tempdima + \wd#5=\@tempdimb + \ht#5=\@tempdimc + \box#5% + }% +} +% \end{macrocode} +% \end{macro} +% +% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \subsubsection{Minibox and other Environments Keys} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% \begin{key}{adjbox}{minipage} +% \begin{macrocode} +\define@key{adjbox}{minipage}{% + \@ifnextchar[{% + \adjbox@innerenv{minipage}% + }{% + \adjbox@innerenv{minipage}{{#1}}\@nnil% + \remove@to@nnil + }#1\@nnil +} +% \end{macrocode} +% \end{key} +% +% +% \begin{key}{adjbox}{innerenv} +% \begin{macrocode} +\define@key{adjbox}{innerenv}{% + \@ifnextchar\bgroup{% + \adjbox@innerenv + }{% + \adjbox@innerenv{#1}\@nnil% + \remove@to@nnil + }#1\@nnil +} +% \end{macrocode} +% \end{key} +% +% \begin{macro}{\adjbox@innerenv} +% \begin{macrocode} +\def\adjbox@innerenv#1#2\@nnil{% + \def\adjbox@collectbox##1{\collectbox@{\begin{#1}#2}{##1}{\end{#1}}}% +}% +% \end{macrocode} +% \end{macro} +% +% +% \begin{key}{adjbox}{innercode} +% \begin{macrocode} +\define@key{adjbox}{innercode}{% + \adjbox@innercode#1{}{}% +} +% \end{macrocode} +% \end{key} +% +% \begin{macro}{\adjbox@innerenv} +% \begin{macrocode} +\def\adjbox@innerenv#1#2\@nnil{% + \def\adjbox@collectbox##1{\collectbox@{\begin{#1}#2}{##1}{\end{#1}}}% +}% +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\adjbox@innercode} +% \begin{macrocode} +\def\adjbox@innercode#1#2{% + \def\adjbox@collectbox##1{\collectbox@{#1}{##1}{#2}}% +}% +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{key}{adjbox}{env} +% \begin{macrocode} +\define@key{adjbox}{env}{% + \@ifnextchar\bgroup{% + \adjbox@addenv + }{% + \adjbox@addenv{#1}\@nnil% + \remove@to@nnil + }#1\@nnil +} +% \end{macrocode} +% \end{key} +% +% +% \begin{macro}{\adjust@addenv} +% \begin{macrocode} +\def\adjbox@addenv#1#2\@nnil{% + \def\@tempa{\begin{#1}#2}% + \toks@\expandafter\expandafter\expandafter{\expandafter\@tempa\the\toks@\end{#1}}% +}% +% \end{macrocode} +% \end{macro} +% +% \begin{key}{adjbox}{addcode} +% \begin{macrocode} +\define@key{adjbox}{Addcode}{% + \adjust@@addcode#1{}\@nnil% +} +\define@key{adjbox}{addcode}{% + \Gin@esetsize + \@tempswatrue + \adjust@@addcode#1{}\@nnil% +} +\def\adjust@@addcode#1#2#3\@nnil{% + \ifx\@nnil#3\@nnil + \adjust@addcode{#1}{#2}% + \else + \PackageError{adjustbox}{Incorrect input for key 'addcode={}{}'!}% + \fi +} +% \end{macrocode} +% \end{key} +% +% \begin{key}{adjbox}{precode} +% \begin{macrocode} +\define@key{adjbox}{precode}{% + \Gin@esetsize + \@tempswatrue + \adjust@addcode{#1}{}% +} +% \end{macrocode} +% \end{key} +% +% \begin{key}{adjbox}{Precode} +% \begin{macrocode} +\define@key{adjbox}{Precode}{% + \adjust@addcode{#1}{}% +} +% \end{macrocode} +% \end{key} +% +% \begin{key}{adjbox}{appcode} +% \begin{macrocode} +\define@key{adjbox}{appcode}{% + \toks@\expandafter{\the\toks@#1}% +} +% \end{macrocode} +% \end{key} +% +% \begin{macro}{\adjust@addcode} +% \begin{macrocode} +\def\adjust@addcode#1#2{% + \def\@tempa{#1}% + \toks@\expandafter\expandafter\expandafter{\expandafter\@tempa\expandafter{\the\toks@}#2}% +}% +% \end{macrocode} +% \end{macro} +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \iffalse +% +% \fi +% +% +% \iffalse +%<*adjgrfx> +% \fi +% \begin{macrocode} +\ProvidesPackage{adjgrfx}[2011/07/28 v0.1 Patches to graphicx used by adjustbox] +\RequirePackage{graphicx} +% \end{macrocode} +% +% +%%^^A \width, \height, \totalheight, \depth = size current at option execution (changes after every option) (initial: natural size) +%%^^A \Width, \Height, \Totalheight, \Depth = requested size of image (height/totalheight and width) (initial: natural size) +%%^^A \WIDTH, \HEIGHT, \TOTALHEIGHT, \DEPTH = natural size of image +%% +%% +% +% \begin{macro}{\Gin@adj@adddim} +% \begin{macrocode} +\newcommand*\Gin@adj@adddim{% + \let\height\Gin@nat@height + \let\width\Gin@nat@width + \let\totalheight\height + \let\depth\z@ + \let\adjbox@HEIGHT\HEIGHT + \let\adjbox@WIDTH\WIDTH + \let\adjbox@TOTALHEIGHT\TOTALHEIGHT + \let\adjbox@DEPTH\DEPTH + \global\let\HEIGHT\Gin@nat@height + \global\let\WIDTH\Gin@nat@width + \global\let\TOTALHEIGHT\HEIGHT + \global\let\DEPTH\z@ + \let\adjbox@Height\Height + \let\adjbox@Width\Width + \let\adjbox@Totalheight\Totalheight + \let\adjbox@Depth\Depth + \global\let\Height\Gin@nat@height + \global\let\Width\Gin@nat@width + \global\let\Totalheight\Height + \global\let\Depth\z@ + \edef\adjbox@restore@dims{% + \global\adjbox@nat@height\the\adjbox@nat@height\relax + \global\adjbox@nat@width \the\adjbox@nat@width\relax + \global\adjbox@req@height\the\adjbox@req@height\relax + \global\adjbox@req@width \the\adjbox@req@width\relax + }% +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\Gin@adj@remdim} +% \begin{macrocode} +\newcommand*\Gin@adj@remdim{% + \global\let\HEIGHT\adjbox@HEIGHT + \global\let\WIDTH\adjbox@WIDTH + \global\let\TOTALHEIGHT\adjbox@TOTALHEIGHT + \global\let\DEPTH\adjbox@DEPTH + \global\let\Height\adjbox@Height + \global\let\Width\adjbox@Width + \global\let\Totalheight\adjbox@Totalheight + \global\let\Depth\adjbox@Depth + \adjbox@restore@dims +} +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +\newdimen\adjbox@nat@width +\newdimen\adjbox@nat@height +\newdimen\adjbox@req@width +\newdimen\adjbox@req@height +% \end{macrocode} +% +% \begin{macro}{\Gin@adj@keepdim} +% \begin{macrocode} +\newcommand*\Gin@adj@keepdim{% + \global\adjbox@nat@height\Gin@nat@height + \global\adjbox@nat@width \Gin@nat@width + \global\adjbox@req@height\Gin@req@height + \global\adjbox@req@width \Gin@req@width + \global\let\HEIGHT\adjbox@nat@height + \global\let\WIDTH\adjbox@nat@width + \global\let\TOTALHEIGHT\adjbox@nat@height + \global\let\DEPTH\z@ + \global\let\Height\adjbox@req@height + \global\let\Width\adjbox@req@width + \global\let\Totalheight\adjbox@req@height + \global\let\Depth\z@ +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\Gin@ii} +% \begin{macrocode} +\def\Gin@ii[#1]#2{% + \def\@tempa{[}\def\@tempb{#2}% + \ifx\@tempa\@tempb + \def\@tempa{\Gin@iii[#1][}% + \expandafter\@tempa + \else + \begingroup + \Gin@adj@adddim + \@tempswafalse + \toks@{\Ginclude@graphics{#2}}% + \setkeys{Gin}{#1}% + \Gin@esetsize + \the\toks@ + \Gin@adj@remdim + \endgroup + \fi} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\Gin@iii} +% \begin{macrocode} +\def\Gin@iii[#1,#2][#3,#4]#5{% + \begingroup + \Gin@adj@adddim + \Gin@bboxtrue + \Gin@defaultbp\Gin@llx{#1}% + \Gin@defaultbp\Gin@lly{#2}% + \Gin@defaultbp\Gin@urx{#3}% + \Gin@defaultbp\Gin@ury{#4}% + \Ginclude@graphics{#5}% + \Gin@adj@remdim + \endgroup} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\Gin@setfile} +% \begin{macrocode} +\def\Gin@setfile#1#2#3{% + \ifx\\#2\\\Gread@false\fi + \ifGin@bbox\else + \ifGread@ + \csname Gread@% + \expandafter\ifx\csname Gread@#1\endcsname\relax + eps% + \else + #1% + \fi + \endcsname{\Gin@base#2}% + \else + \Gin@nosize{#3}% + \fi + \fi + \Gin@viewport@code + \Gin@nat@height\Gin@ury bp% + \advance\Gin@nat@height-\Gin@lly bp% + \Gin@nat@width\Gin@urx bp% + \advance\Gin@nat@width-\Gin@llx bp% + \Gin@req@sizes + \Gin@adj@keepdim + \expandafter\ifx\csname Ginclude@#1\endcsname\relax + \Gin@drafttrue + \expandafter\ifx\csname Gread@#1\endcsname\relax + \@latex@error{Can not include graphics of type: #1}\@ehc + \global\expandafter\let\csname Gread@#1\endcsname\@empty + \fi + \fi + \leavevmode + \ifGin@draft + \hb@xt@\Gin@req@width{% + \vrule\hss + \vbox to \Gin@req@height{% + \hrule \@width \Gin@req@width + \vss + \edef\@tempa{#3}% + \rlap{ \ttfamily\expandafter\strip@prefix\meaning\@tempa}% + \vss + \hrule}% + \hss\vrule}% + \else + \@addtofilelist{#3}% + \ProvidesFile{#3}[Graphic file (type #1)]% + \setbox\z@\hbox{\csname Ginclude@#1\endcsname{#3}}% + \dp\z@\z@ + \ht\z@\Gin@req@height + \wd\z@\Gin@req@width + \box\z@ + \fi} +% \end{macrocode} +% \end{macro} +% +% \iffalse +% +% \fi +% +% +% \iffalse +%<*adjcalc> +% \fi +% Test if this package was loaded as package or as file (as part of 'adjustbox'): +% \begin{macrocode} +\begingroup +\def\@tempa{adjcalc} +\expandafter +\endgroup +\ifx\@tempa\@currname + \ProvidesPackage{adjcalc}[2011/08/07 v1.0 Provides advanced setlength with multiple back-ends (calc, etex, pgfmath)] + \RequirePackage{xkeyval} +\fi +% \end{macrocode} +% +% +% +% Use e-TeX by default if available, otherwise LaTeX (maybe with \pkg{calc}) +% \begin{macrocode} +\AtEndOfPackage{\adjcalc@atend} +\def\adjcalc@atend{% +\begingroup +\expandafter\ifx\csname eTeXversion\endcsname\relax + \endgroup + \RequirePackage{calc}% + \adjcalc@calc + \def\adjcalc@etex{\PackageError{adjcalc}{e-TeX not available for current compiler!}}% +\else + \endgroup + \adjcalc@etex +\fi +} +% \end{macrocode} +% +% Initial definitions for the package options. This macros are later redefined because the same keys +% can be used as macro options. +% \begin{macrocode} +\def\adjcalc@pgfmath{\AtEndOfPackage{\RequirePackage{pgf}}\def\adjcalc@atend{\adjcalc@pgfmath}} +\def\adjcalc@etex{\def\adjcalc@atend{\adjcalc@etex}} +\def\adjcalc@calc{\AtEndOfPackage{\RequirePackage{calc}}\def\adjcalc@atend{\adjcalc@calc}} +\def\adjcalc@overwrite{\AtEndOfPackage{\adjcalc@overwrite}} +% \end{macrocode} +% +% Options: +% \begin{macrocode} +\DeclareOptionX{pgfmath}{\adjcalc@pgfmath} +\DeclareOptionX{etex}{\adjcalc@etex} +\DeclareOptionX{calc}{\adjcalc@calc} +\DeclareOptionX{none}{\let\adjcalc@atend\relax\def\adjsetlength{\setlength}\let\adjcalc@overwrite\relax} +\DeclareOptionX{overwrite}{\adjcalc@overwrite} +\ProcessOptionsX* +\disable@keys{adjbox}{none} +% \end{macrocode} +% +% \begin{macro}{\adjcalc@etex} +% \begin{macrocode} +\def\adjcalc@etex{% + \protected\def\adjsetlength##1##2{% + ##1=\glueexpr(##2)\relax + }% + \protected\def\adjaddtolength##1##2{% + \advance##1 by \glueexpr(##2)\relax + }% + \protected\def\adjsetcounter##1##2{% + \@ifundefined{c@##1}% + {\@nocounterr{##1}}% + {\global\csname c@##1\endcsname\numexpr(##2)\relax}% + }% + \protected\def\adjaddtocounter##1##2{% + \@ifundefined{c@##1}% + {\@nocounterr{##1}}% + {\global\advance\csname c@##1\endcsname\numexpr(##2)\relax}% + }% + \def\adjbox@default##1##2{% + \@defaultunits##1=\glueexpr##2 \adjbox@defaultunit\relax\@nnil + }% +} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\adjcalc@calc} +% This uses the underlying (re-)definitions of the normal macros (\Macro\setlength, ...) done by the \pkg{calc} package. +% This allows to locally redefine \Macro\setlength to call \Macro\adjsetlength, etc., without causing an infinite loop. +% \begin{macrocode} +\def\adjcalc@calc{% + \DeclareRobustCommand\adjsetlength{\calc@assign@skip}% + \DeclareRobustCommand\adjaddtolength[1]{\calc@assign@skip{\advance ##1}}% + \DeclareRobustCommand\adjsetcounter[2]{\@ifundefined{c@##1}{\@nocounterr{##1}}{\calc@assign@count{\global\csname c@##1\endcsname}{##2}}}% + \DeclareRobustCommand\adjaddtocounter[2]{\@ifundefined{c@##1}{\@nocounterr{##1}}{\calc@assign@count{\global\advance\csname c@##1\endcsname}{##2}}}% + \def\adjbox@checkdefault##1\@nnil##2##3{% + \ifx\relax##1\relax\else + \calc@assign@skip{##2}{##3}% + \fi + }% +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\adjcalc@pgfmath} +% \begin{macrocode} +\def\adjcalc@pgfmath{% + \DeclareRobustCommand\adjsetlength{\pgfmathsetlength}% + \DeclareRobustCommand\adjaddtolength{\pgfmathaddtolength}% + \DeclareRobustCommand\adjsetcounter{\pgfmathsetcounter}% + \DeclareRobustCommand\adjaddtocounter{\pgfmathaddtocounter}% + \def\adjbox@default##1##2{% + \edef\pgfmathresultunitscale{1\adjbox@defaultunit}% + \let\pgfmathpostparse\pgfmathscaleresult + \pgfmathparse{##2}% + ##1=\pgfmathresult pt\relax + }% +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\adjcalc@overwrite} +% \begin{macrocode} +\def\adjcalc@overwrite{% + \let\setlength\adjsetlength + \let\addtolength\adjaddtolength + \let\setcounter\adjsetcounter + \let\addtocounter\adjaddtocounter +} +% \end{macrocode} +% \end{macro} +% +% \iffalse +% +% \fi +% +% +% \iffalse +%<*adjpgf.def> +% \fi +% \begin{macrocode} +\RequirePackage{pgf} +% \end{macrocode} +% +% \begin{macro}{\@trimbox} +% \begin{macrocode} +\def\@clipbox#1#2#3#4#5{% + \@trimbox{#1}{#2}{#3}{#4}{#5}% + \setbox#5\hbox{\begin{pgfpicture}% + \pgfpathmoveto{\pgfqpoint\z@{-\dp#5}}% + \pgfpathlineto{\pgfqpoint\z@{\ht#5}}% + \pgfpathlineto{\pgfqpoint{\wd#5}{\ht#5}}% + \pgfpathlineto{\pgfqpoint{\wd#5}{-\dp#5}}% + \pgfpathclose + \pgfusepathqclip + \pgfset{inner sep=\z@,outer sep=\z@,minimum size=\z@}% + \pgfnode{rectangle}{base west}{\usebox#5}{}{}% + \pgfsetbaselinepointnow{\pgfpoint\z@\z@}% + \end{pgfpicture}}% +} +% \end{macrocode} +% \end{macro} +% vim: ft=tex +% +% \iffalse +% % \fi +% +% +% \Finale +% \endinput diff --git a/Master/texmf-dist/source/latex/adjustbox/adjustbox.ins b/Master/texmf-dist/source/latex/adjustbox/adjustbox.ins index 96c8f8a718c..e458b4cbfcb 100644 --- a/Master/texmf-dist/source/latex/adjustbox/adjustbox.ins +++ b/Master/texmf-dist/source/latex/adjustbox/adjustbox.ins @@ -1,4 +1,4 @@ -%% $Id: adjustbox.ins 2095 2011-01-28 16:16:43Z martin $ +%% $Id$ \input docstrip.tex \preamble @@ -18,14 +18,19 @@ 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. +This work consists of the files adjustbox.dtx and adjustbox.ins +and the derived files adjustbox.sty, adjcalc.sty, adjpgf.def and +adjgrfx.sty. \endpreamble \keepsilent +\askforoverwritefalse \generate{% - \file{adjustbox.sty}{\from{adjustbox.dtx}{package}}% + \file{adjustbox.sty}{\from{adjustbox.dtx}{adjustbox}}% + \file{adjcalc.sty}{\from{adjustbox.dtx}{adjcalc}}% + \file{adjgrfx.sty}{\from{adjustbox.dtx}{adjgrfx}}% + \file{adjpgf.def}{\from{adjustbox.dtx}{adjpgf.def}}% \file{adjustbox-de.tex}{\nopreamble\nopostamble\from{adjustbox.dtx}{de}}% } diff --git a/Master/texmf-dist/tex/latex/adjustbox/adjcalc.sty b/Master/texmf-dist/tex/latex/adjustbox/adjcalc.sty new file mode 100644 index 00000000000..47e512f3aba --- /dev/null +++ b/Master/texmf-dist/tex/latex/adjustbox/adjcalc.sty @@ -0,0 +1,113 @@ +%% +%% This is file `adjcalc.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% adjustbox.dtx (with options: `adjcalc') +%% +%% Copyright (C) 2011 by Martin Scharrer +%% +%% 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 adjustbox.dtx and adjustbox.ins +%% and the derived files adjustbox.sty, adjcalc.sty, adjpgf.def and +%% adjgrfx.sty. +%% +\begingroup +\def\@tempa{adjcalc} +\expandafter +\endgroup +\ifx\@tempa\@currname + \ProvidesPackage{adjcalc}[2011/08/07 v1.0 Provides advanced setlength with multiple back-ends (calc, etex, pgfmath)] + \RequirePackage{xkeyval} +\fi +\AtEndOfPackage{\adjcalc@atend} +\def\adjcalc@atend{% +\begingroup +\expandafter\ifx\csname eTeXversion\endcsname\relax + \endgroup + \RequirePackage{calc}% + \adjcalc@calc + \def\adjcalc@etex{\PackageError{adjcalc}{e-TeX not available for current compiler!}}% +\else + \endgroup + \adjcalc@etex +\fi +} +\def\adjcalc@pgfmath{\AtEndOfPackage{\RequirePackage{pgf}}\def\adjcalc@atend{\adjcalc@pgfmath}} +\def\adjcalc@etex{\def\adjcalc@atend{\adjcalc@etex}} +\def\adjcalc@calc{\AtEndOfPackage{\RequirePackage{calc}}\def\adjcalc@atend{\adjcalc@calc}} +\def\adjcalc@overwrite{\AtEndOfPackage{\adjcalc@overwrite}} +\DeclareOptionX{pgfmath}{\adjcalc@pgfmath} +\DeclareOptionX{etex}{\adjcalc@etex} +\DeclareOptionX{calc}{\adjcalc@calc} +\DeclareOptionX{none}{\let\adjcalc@atend\relax\def\adjsetlength{\setlength}\let\adjcalc@overwrite\relax} +\DeclareOptionX{overwrite}{\adjcalc@overwrite} +\ProcessOptionsX* +\disable@keys{adjbox}{none} +\def\adjcalc@etex{% + \protected\def\adjsetlength##1##2{% + ##1=\glueexpr(##2)\relax + }% + \protected\def\adjaddtolength##1##2{% + \advance##1 by \glueexpr(##2)\relax + }% + \protected\def\adjsetcounter##1##2{% + \@ifundefined{c@##1}% + {\@nocounterr{##1}}% + {\global\csname c@##1\endcsname\numexpr(##2)\relax}% + }% + \protected\def\adjaddtocounter##1##2{% + \@ifundefined{c@##1}% + {\@nocounterr{##1}}% + {\global\advance\csname c@##1\endcsname\numexpr(##2)\relax}% + }% + \def\adjbox@default##1##2{% + \@defaultunits##1=\glueexpr##2 \adjbox@defaultunit\relax\@nnil + }% +} +\def\adjcalc@calc{% + \DeclareRobustCommand\adjsetlength{\calc@assign@skip}% + \DeclareRobustCommand\adjaddtolength[1]{\calc@assign@skip{\advance ##1}}% + \DeclareRobustCommand\adjsetcounter[2]{\@ifundefined{c@##1}{\@nocounterr{##1}}{\calc@assign@count{\global\csname c@##1\endcsname}{##2}}}% + \DeclareRobustCommand\adjaddtocounter[2]{\@ifundefined{c@##1}{\@nocounterr{##1}}{\calc@assign@count{\global\advance\csname c@##1\endcsname}{##2}}}% + \def\adjbox@checkdefault##1\@nnil##2##3{% + \ifx\relax##1\relax\else + \calc@assign@skip{##2}{##3}% + \fi + }% +} +\def\adjcalc@pgfmath{% + \DeclareRobustCommand\adjsetlength{\pgfmathsetlength}% + \DeclareRobustCommand\adjaddtolength{\pgfmathaddtolength}% + \DeclareRobustCommand\adjsetcounter{\pgfmathsetcounter}% + \DeclareRobustCommand\adjaddtocounter{\pgfmathaddtocounter}% + \def\adjbox@default##1##2{% + \edef\pgfmathresultunitscale{1\adjbox@defaultunit}% + \let\pgfmathpostparse\pgfmathscaleresult + \pgfmathparse{##2}% + ##1=\pgfmathresult pt\relax + }% +} +\def\adjcalc@overwrite{% + \let\setlength\adjsetlength + \let\addtolength\adjaddtolength + \let\setcounter\adjsetcounter + \let\addtocounter\adjaddtocounter +} +\endinput +%% +%% End of file `adjcalc.sty'. diff --git a/Master/texmf-dist/tex/latex/adjustbox/adjgrfx.sty b/Master/texmf-dist/tex/latex/adjustbox/adjgrfx.sty new file mode 100644 index 00000000000..215159e1fda --- /dev/null +++ b/Master/texmf-dist/tex/latex/adjustbox/adjgrfx.sty @@ -0,0 +1,172 @@ +%% +%% This is file `adjgrfx.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% adjustbox.dtx (with options: `adjgrfx') +%% +%% Copyright (C) 2011 by Martin Scharrer +%% +%% 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 adjustbox.dtx and adjustbox.ins +%% and the derived files adjustbox.sty, adjcalc.sty, adjpgf.def and +%% adjgrfx.sty. +%% +\ProvidesPackage{adjgrfx}[2011/07/28 v0.1 Patches to graphicx used by adjustbox] +\RequirePackage{graphicx} +%%^^A \width, \height, \totalheight, \depth = size current at option execution (changes after every option) (initial: natural size) +%%^^A \Width, \Height, \Totalheight, \Depth = requested size of image (height/totalheight and width) (initial: natural size) +%%^^A \WIDTH, \HEIGHT, \TOTALHEIGHT, \DEPTH = natural size of image +%% +%% +\newcommand*\Gin@adj@adddim{% + \let\height\Gin@nat@height + \let\width\Gin@nat@width + \let\totalheight\height + \let\depth\z@ + \let\adjbox@HEIGHT\HEIGHT + \let\adjbox@WIDTH\WIDTH + \let\adjbox@TOTALHEIGHT\TOTALHEIGHT + \let\adjbox@DEPTH\DEPTH + \global\let\HEIGHT\Gin@nat@height + \global\let\WIDTH\Gin@nat@width + \global\let\TOTALHEIGHT\HEIGHT + \global\let\DEPTH\z@ + \let\adjbox@Height\Height + \let\adjbox@Width\Width + \let\adjbox@Totalheight\Totalheight + \let\adjbox@Depth\Depth + \global\let\Height\Gin@nat@height + \global\let\Width\Gin@nat@width + \global\let\Totalheight\Height + \global\let\Depth\z@ + \edef\adjbox@restore@dims{% + \global\adjbox@nat@height\the\adjbox@nat@height\relax + \global\adjbox@nat@width \the\adjbox@nat@width\relax + \global\adjbox@req@height\the\adjbox@req@height\relax + \global\adjbox@req@width \the\adjbox@req@width\relax + }% +} +\newcommand*\Gin@adj@remdim{% + \global\let\HEIGHT\adjbox@HEIGHT + \global\let\WIDTH\adjbox@WIDTH + \global\let\TOTALHEIGHT\adjbox@TOTALHEIGHT + \global\let\DEPTH\adjbox@DEPTH + \global\let\Height\adjbox@Height + \global\let\Width\adjbox@Width + \global\let\Totalheight\adjbox@Totalheight + \global\let\Depth\adjbox@Depth + \adjbox@restore@dims +} +\newdimen\adjbox@nat@width +\newdimen\adjbox@nat@height +\newdimen\adjbox@req@width +\newdimen\adjbox@req@height +\newcommand*\Gin@adj@keepdim{% + \global\adjbox@nat@height\Gin@nat@height + \global\adjbox@nat@width \Gin@nat@width + \global\adjbox@req@height\Gin@req@height + \global\adjbox@req@width \Gin@req@width + \global\let\HEIGHT\adjbox@nat@height + \global\let\WIDTH\adjbox@nat@width + \global\let\TOTALHEIGHT\adjbox@nat@height + \global\let\DEPTH\z@ + \global\let\Height\adjbox@req@height + \global\let\Width\adjbox@req@width + \global\let\Totalheight\adjbox@req@height + \global\let\Depth\z@ +} +\def\Gin@ii[#1]#2{% + \def\@tempa{[}\def\@tempb{#2}% + \ifx\@tempa\@tempb + \def\@tempa{\Gin@iii[#1][}% + \expandafter\@tempa + \else + \begingroup + \Gin@adj@adddim + \@tempswafalse + \toks@{\Ginclude@graphics{#2}}% + \setkeys{Gin}{#1}% + \Gin@esetsize + \the\toks@ + \Gin@adj@remdim + \endgroup + \fi} +\def\Gin@iii[#1,#2][#3,#4]#5{% + \begingroup + \Gin@adj@adddim + \Gin@bboxtrue + \Gin@defaultbp\Gin@llx{#1}% + \Gin@defaultbp\Gin@lly{#2}% + \Gin@defaultbp\Gin@urx{#3}% + \Gin@defaultbp\Gin@ury{#4}% + \Ginclude@graphics{#5}% + \Gin@adj@remdim + \endgroup} +\def\Gin@setfile#1#2#3{% + \ifx\\#2\\\Gread@false\fi + \ifGin@bbox\else + \ifGread@ + \csname Gread@% + \expandafter\ifx\csname Gread@#1\endcsname\relax + eps% + \else + #1% + \fi + \endcsname{\Gin@base#2}% + \else + \Gin@nosize{#3}% + \fi + \fi + \Gin@viewport@code + \Gin@nat@height\Gin@ury bp% + \advance\Gin@nat@height-\Gin@lly bp% + \Gin@nat@width\Gin@urx bp% + \advance\Gin@nat@width-\Gin@llx bp% + \Gin@req@sizes + \Gin@adj@keepdim + \expandafter\ifx\csname Ginclude@#1\endcsname\relax + \Gin@drafttrue + \expandafter\ifx\csname Gread@#1\endcsname\relax + \@latex@error{Can not include graphics of type: #1}\@ehc + \global\expandafter\let\csname Gread@#1\endcsname\@empty + \fi + \fi + \leavevmode + \ifGin@draft + \hb@xt@\Gin@req@width{% + \vrule\hss + \vbox to \Gin@req@height{% + \hrule \@width \Gin@req@width + \vss + \edef\@tempa{#3}% + \rlap{ \ttfamily\expandafter\strip@prefix\meaning\@tempa}% + \vss + \hrule}% + \hss\vrule}% + \else + \@addtofilelist{#3}% + \ProvidesFile{#3}[Graphic file (type #1)]% + \setbox\z@\hbox{\csname Ginclude@#1\endcsname{#3}}% + \dp\z@\z@ + \ht\z@\Gin@req@height + \wd\z@\Gin@req@width + \box\z@ + \fi} +\endinput +%% +%% End of file `adjgrfx.sty'. diff --git a/Master/texmf-dist/tex/latex/adjustbox/adjpgf.def b/Master/texmf-dist/tex/latex/adjustbox/adjpgf.def new file mode 100644 index 00000000000..e4b3e3b6d94 --- /dev/null +++ b/Master/texmf-dist/tex/latex/adjustbox/adjpgf.def @@ -0,0 +1,46 @@ +%% +%% This is file `adjpgf.def', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% adjustbox.dtx (with options: `adjpgf.def') +%% +%% Copyright (C) 2011 by Martin Scharrer +%% +%% 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 adjustbox.dtx and adjustbox.ins +%% and the derived files adjustbox.sty, adjcalc.sty, adjpgf.def and +%% adjgrfx.sty. +%% +\RequirePackage{pgf} +\def\@clipbox#1#2#3#4#5{% + \@trimbox{#1}{#2}{#3}{#4}{#5}% + \setbox#5\hbox{\begin{pgfpicture}% + \pgfpathmoveto{\pgfqpoint\z@{-\dp#5}}% + \pgfpathlineto{\pgfqpoint\z@{\ht#5}}% + \pgfpathlineto{\pgfqpoint{\wd#5}{\ht#5}}% + \pgfpathlineto{\pgfqpoint{\wd#5}{-\dp#5}}% + \pgfpathclose + \pgfusepathqclip + \pgfset{inner sep=\z@,outer sep=\z@,minimum size=\z@}% + \pgfnode{rectangle}{base west}{\usebox#5}{}{}% + \pgfsetbaselinepointnow{\pgfpoint\z@\z@}% + \end{pgfpicture}}% +} +\endinput +%% +%% End of file `adjpgf.def'. diff --git a/Master/texmf-dist/tex/latex/adjustbox/adjustbox.sty b/Master/texmf-dist/tex/latex/adjustbox/adjustbox.sty index 254b98c087e..9cb704520bf 100644 --- a/Master/texmf-dist/tex/latex/adjustbox/adjustbox.sty +++ b/Master/texmf-dist/tex/latex/adjustbox/adjustbox.sty @@ -4,7 +4,7 @@ %% %% The original source files were: %% -%% adjustbox.dtx (with options: `package') +%% adjustbox.dtx (with options: `adjustbox') %% %% Copyright (C) 2011 by Martin Scharrer %% @@ -22,113 +22,768 @@ %% %% 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. +%% This work consists of the files adjustbox.dtx and adjustbox.ins +%% and the derived files adjustbox.sty, adjcalc.sty, adjpgf.def and +%% adjgrfx.sty. %% -\ProvidesPackage{adjustbox} - [2011/03/20 v0.3 Adjusting TeX boxes (trim, clip, ...)] +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\ProvidesPackage{adjustbox}[2011/08/07 v0.5 Adjusting TeX boxes (trim, clip, ...)] +\RequirePackage{xkeyval} + +\def\adjbox@defaultunit{bp} +\DeclareOptionX{defaultunit}{% + \def\adjbox@defaultunit{#1}% + \begingroup + \def\@tempa{none}% + \expandafter\endgroup + \ifx\@tempa\adjbox@defaultunit + \def\adjbox@default{\adjsetlength}% + \fi +} + +\def\adjbox@fam{adjbox} +\DeclareOptionX{export}{\def\adjbox@fam{Gin}} +\DeclareOptionX{patch}{\AtEndOfPackage{\RequirePackage{adjgrfx}}} +\DeclareOptionX{minimal}{\let\adjbox@maybeend\endinput} + +\def\adjbox@driver{adj\Gin@driver} +\DeclareOptionX{pgf}{\def\adjbox@driver{adjpgf.def}} +\DeclareOptionX{PGF}{\def\adjbox@driver{adjpgf.def}\adjcalc@pgfmath} +\DeclareOptionX*{\PassOptionsToPackage\CurrentOption{graphicx}} + +\let\adjbox@maybeend\relax +\input{adjcalc.sty} +\disable@keys{adjbox}{patch,export,PGF,minimal} \RequirePackage{graphicx}[1999/02/16] -\RequirePackage{pgf} +\RequirePackage{collectbox}[2011/08/06] +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\define@key{adjbox}{viewport}{% + \let\Gin@viewport@code\adjbox@@viewport + \let\adjustbox@@@\adjustbox@@@trimclip + \adjbox@parse@v{#1}% +} +\define@key{adjbox}{trim}{% + \let\Gin@viewport@code\adjbox@@trim + \let\adjustbox@@@\adjustbox@@@trimclip + \adjbox@parse@v{#1}% +} +\def\adjustbox@@@trimclip{% + \Gin@viewport@code + \ifGin@clip + \expandafter\@clipbox + \else + \expandafter\@trimbox + \fi + \adjbox@tllx + \adjbox@tlly + \adjbox@turx + \adjbox@tury + \collectedbox + \usebox\collectedbox +} +\def\adjbox@parse@v#1{% + \adjbox@parse@@v#1 {} {} {} \\% +} +\def\adjbox@parse@@v#1 #2 #3 #4 #5\\{% + \adjbox@default\adjbox@tllx{#1}% + \ifx\@nnil#2\@nnil + \adjbox@tlly\adjbox@tllx + \adjbox@turx\adjbox@tllx + \adjbox@tury\adjbox@tlly + \else + \adjbox@default\adjbox@tlly{#2}% + \ifx\@nnil#3\@nnil + \adjbox@turx\adjbox@tllx + \adjbox@tury\adjbox@tlly + \else + \adjbox@default\adjbox@turx{#3}% + \adjbox@default\adjbox@tury{#4}% + \fi + \fi +}% +%%\newdimen\adjbox@llx +%%\newdimen\adjbox@lly +%%\newdimen\adjbox@urx +%%\newdimen\adjbox@ury +\newdimen\adjbox@tllx +\newdimen\adjbox@tlly +\newdimen\adjbox@turx +\newdimen\adjbox@tury +\let\adjbox@@trim\relax +\def\adjbox@@viewport{% + %\advance\adjbox@tllx by -\z@ + \advance\adjbox@tlly by \dp\collectedbox + \advance\adjbox@turx by -\wd\collectedbox + \advance\adjbox@tury by -\ht\collectedbox + \adjbox@turx=-\adjbox@turx + \adjbox@tury=-\adjbox@tury +} +\newcommand\trimbox{% + \collectboxcheckenv{trimbox}% + \@ifstar + \trimbox@s + \trimbox@ +} +\def\trimbox@#1{% + \collectbox{\trimbox@@\@trimbox{#1}}% +} +\def\trimbox@s#1{% + \collectbox{\trimbox@@{\adjbox@@viewport\@trimbox}{#1}}% +} +\def\trimbox@@#1#2{% + \adjbox@parse@v{#2}% + #1% + \adjbox@tllx + \adjbox@tlly + \adjbox@turx + \adjbox@tury + \collectedbox + \usebox\collectedbox +} +\expandafter\newcommand\expandafter*\csname trimbox*\endcsname{% + \@collectboxisenv{trimbox*}% + \trimbox@s +} \newcommand\clipbox{% - \begingroup - \def\adjustbox@name{clipbox}% + \collectboxcheckenv{clipbox}% \@ifstar - {\adjustbox@{clip,viewport=}}% - {\adjustbox@{clip,trim=}}% + \clipbox@s + \clipbox@ } -\def\endclipbox{% - \endadjustbox +\def\clipbox@#1{% + \collectbox{\trimbox@@\@clipbox{#1}}% } -\newenvironment{clipbox*} - {\begin{clipbox}*} - {\end{clipbox}} -\newcommand\trimbox{% +\def\clipbox@s#1{% + \collectbox{\trimbox@@{\adjbox@@viewport\@clipbox}{#1}}% +} +\expandafter\newcommand\expandafter*\csname clipbox*\endcsname{% + \@collectboxisenv{clipbox*}% + \clipbox@s +} +\newcommand\adjustbox[1]{% + \collectboxcheckenv{adjustbox}% \begingroup - \def\adjustbox@name{trimbox}% - \@ifstar - {\adjustbox@{viewport=}}% - {\adjustbox@{trim=}}% + \adjustbox@dimcmds + \let\Gin@esetsize\adjbox@esetsize + \@tempswatrue + \toks@{{\adjustbox@@@@}}% + \def\setlength{\adjsetlength}% + \setkeys{adjbox,Gin}{#1}% + \adjbox@esetsize + \adjbox@collectbox{\the\toks@\endgroup}% +} +\let\adjbox@collectbox\@collectbox +\def\adjustbox@@@@{\adjustbox@@@}% +\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 +} +\def\adjustbox@dimcmds{% + \let\width\relax + \let\height\relax + \let\depth\relax + \let\totalheight\relax +} +\def\adjustbox@@@{% + \usebox\collectedbox } -\def\endtrimbox{% - \endadjustbox +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\def\@trimbox#1#2#3#4#5{% + \setbox#5=\hbox{% + \adjsetlength\@tempdima{#1}% + \hskip-\@tempdima + \adjsetlength\@tempdima{\dp#5 - (#2)}% + \adjsetlength\@tempdimb{\wd#5 - (#3)}% + \adjsetlength\@tempdimc{\ht#5 - (#4)}% + \dp#5=\@tempdima + \wd#5=\@tempdimb + \ht#5=\@tempdimc + \ifdim\dp#5<\z@ + \raise\dp#5% + \else + \ifdim\ht#5<\z@ + \lower\ht#5% + \fi\fi + \box#5% + }% + \ifdim\dp#5<\z@ \dp#5=\z@ \fi + \ifdim\wd#5<\z@ \wd#5=\z@ \fi + \ifdim\ht#5<\z@ \ht#5=\z@ \fi } -\newenvironment{trimbox*} - {\begin{trimbox}*} - {\end{trimbox}} -\newcommand\adjustbox{% +\def\@clipbox#1#2#3#4#5{% + \@trimbox{#1}{#2}{#3}{#4}{#5}% + \pdfxform#5% + \setbox#5=\hbox{% + \pdfrefxform\pdflastxform + }% +} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\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 +} +\adjbox@maybeend +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\newcommand*\phantombox[3]{% \begingroup - \def\adjustbox@name{adjustbox}% - \adjustbox@{}% -} -\def\endadjustbox{% - \unskip - \egroup - \color@endgroup - \egroup - \adjustbox@@ -} -\def\adjustbox@#1#2{% - \def\adjustbox@setkeys{\setkeys{Gin}{#1#2}}% - \ifx\@currenvir\adjustbox@name - \edef\@currenvir{\@currenvir\noexpand\empty}% - \def\next{% - \setbox\@tempboxa\hbox\bgroup - \color@setgroup\bgroup - \ignorespaces - }% + \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 +} +\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 - \def\next{% - \setbox\@tempboxa\hbox\bgroup%0 - \color@setgroup\bgroup% - \aftergroup\color@endgroup - \aftergroup\egroup% - \aftergroup\adjustbox@@ - \@ifnextchar\bgroup - {\let\@let@token=}% - {\adjust@box}% + \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{Trim}{% + \adjbox@Gin@Add{\trimbox@{#1}}% +} +\define@key\adjbox@fam{Viewport}{% + \adjbox@Gin@Add{\trimbox@s{#1}}% +} +\define@key\adjbox@fam{Clip}{% + \adjbox@Gin@Add{\clipbox@{#1}}% +} +\define@key\adjbox@fam{Clip*}{% + \adjbox@Gin@Add{\clipbox@s{#1}}% +} +\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@cframe{\fboxsep\z@}#1 {} {} {} \relax\relax\@nnil +} +\define@key\adjbox@fam{cfbox}{% + \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@@frame#1#2#3#4{% + \ifx\@nnil#2\@nnil\else + \adjsetlength\fboxrule{#2}% + \fi + \ifx\@nnil#3\@nnil\else + \adjsetlength\fboxsep{#3}% + \fi + \adjsetlength\adjbox@tllx{\fboxrule + \fboxsep}% + \@marginbox + \adjbox@tllx + \adjbox@tllx + \adjbox@tllx + \adjbox@tllx + \collectedbox + \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\adjbox@tllx{#4}% + \@marginbox + \adjbox@tllx + \adjbox@tllx + \adjbox@tllx + \adjbox@tllx + \collectedbox + \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{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 +\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{margin}{% + \adjbox@Gin@Add{\marginbox@{#1}}% +} +\define@key\adjbox@fam{margin*}{% + \adjbox@Gin@Add{\marginbox@s{#1}}% +} +\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{raise}{% + \@ifnextchar\bgroup{% + \adjbox@raisebox + }{% + \adjbox@raisebox{#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 - \next -} -\def\adjust@box#1{% - #1\egroup -} -\def\adjustbox@@{% - \def\width{\wd\@tempboxa}% - \def\height{\ht\@tempboxa}% - \def\depth{\dp\@tempboxa}% - \@tempdimc=\ht\@tempboxa - \advance\@tempdimc by \dp\@tempboxa\relax - \def\totalheight{\@tempdimc}% - \def\pgfmathresultunitscale{1bp}% - \let\pgfmathpostparse\pgfmathscaleresult - \let\Gin@defaultbp\pgfmathsetmacro - \let\setlength\pgfmathsetlength +} +\define@key\adjbox@fam{valign}{% + \csname adjbox@valign@#1\endcsname +} +\def\adjboxvtop{\ht\strutbox} +\def\adjboxvcenter{1ex} +\def\adjboxvbottom{-\dp\strutbox} +\def\adjbox@valign@t{% + \adjbox@Gin@Add{\@irsbox{\height+\adjboxvtop}[]}% +} +\def\adjbox@valign@T{% + \adjbox@Gin@Add{\@irsbox{-\height}[]}% +} +\def\adjbox@valign@M{% + \adjbox@Gin@Add{\@irsbox{.5\depth-.5\height}[]}% +} +\def\adjbox@valign@m{% + \adjbox@Gin@Add{\@irsbox{.5\depth-.5\height+\adjboxvcenter}[]}% +} +\def\adjbox@valign@b{% + \adjbox@Gin@Add{\@irsbox{\depth+\adjboxvbottom}[]}% +} +\def\adjbox@valign@B{% + \adjbox@Gin@Add{\@irsbox{\depth}[]}% +} +\define@key\adjbox@fam{bgcolor}{% + \adjbox@Gin@add{\colorbox{#1}}% +} +\define@key\adjbox@fam{set height}{% + \adjbox@Gin@Add{\@irsbox\z@[{#1}]}% +} +\define@key\adjbox@fam{set depth}{% + \adjbox@Gin@Add{\@iirsbox\z@[\height][{#1}]}% +} +\def\adjbox@Gin@add#1{% + \def\@tempa{#1}% + \toks@\expandafter\expandafter\expandafter{\expandafter\@tempa\expandafter{\the\toks@}}% +} +\def\adjbox@Gin@Add{% + \Gin@esetsize \@tempswatrue - \toks@{{\adjustbox@@@}}% - \adjustbox@setkeys + \adjbox@Gin@add +} +\def\adjbox@Gin@sizeadd#1#2#3\relax{% + \ifx\@nnil#3\@nnil + \adjbox@Gin@add{#1{#2}{#2}}% + \else + \adjbox@Gin@add{#1{#2}{#3}}% + \fi +} +\def\adjbox@halign#1#2#3{% \Gin@esetsize - \the\toks@ - \endgroup + \@tempswatrue + \adjsetlength\@tempdima{#1}% + \edef\@tempa{\hb@xt@\the\@tempdima}% + \toks@\expandafter\expandafter\expandafter{\expandafter\@tempa\expandafter{\expandafter#2\the\toks@#3}}% } -\def\adjustbox@@@{% - \def\Gin@llx{0}% - \Gin@defaultbp\Gin@lly{+-\dp\@tempboxa}% - \Gin@defaultbp\Gin@urx{+\wd\@tempboxa}% - \Gin@defaultbp\Gin@ury{+\ht\@tempboxa}% - \Gin@viewport@code - \begin{pgfpicture}% - \pgfpathmoveto{\pgfqpoint{\Gin@llx pt}{\Gin@lly pt}}% - \pgfpathlineto{\pgfqpoint{\Gin@urx pt}{\Gin@lly pt}}% - \pgfpathlineto{\pgfqpoint{\Gin@urx pt}{\Gin@ury pt}}% - \pgfpathlineto{\pgfqpoint{\Gin@llx pt}{\Gin@ury pt}}% - \pgfpathclose - \expandafter\pgfusepath\ifGin@clip{clip}\else{use as bounding box}\fi\relax - \pgfset{inner sep=\z@,outer sep=\z@}% - \pgfnode{rectangle}{base west}{\box\@tempboxa}{ADJUSTBOX@NODE}{}% - \pgfsetbaselinepointnow{\pgfpointanchor{ADJUSTBOX@NODE}{base}}% - \end{pgfpicture}% +\define@key\adjbox@fam{center}[\linewidth]{% + \adjbox@halign{#1}\hss\hss +} +\define@key\adjbox@fam{left}[\linewidth]{% + \adjbox@halign{#1}\hss\relax +} +\define@key\adjbox@fam{right}[\linewidth]{% + \adjbox@halign{#1}\relax\hss +} +\define@key\adjbox@fam{outer}[\linewidth]{% + \def\@tempa{\adjbox@halign{#1}}% + \if@twoside + \adjbox@ifoddpage + {\@tempa\hss\relax}% + {\@tempa\relax\hss}% + \else + \@tempa\hss\hss + \fi +} +\define@key\adjbox@fam{inner}[\linewidth]{% + \def\@tempa{\adjbox@halign{#1}}% + \if@twoside + \adjbox@ifoddpage + {\@tempa\relax\hss}% + {\@tempa\hss\relax}% + \else + \@tempa\hss\hss + \fi +} +\def\adjbox@ifoddpage{% + \begingroup + \adjbox@checkoddpage + \expandafter\endgroup + \ifoddpage + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi +} +\def\adjbox@checkoddpage{% + \ifodd\c@page + \oddpagetrue + \else + \oddpagefalse + \fi +}% +\newif\ifoddpage +\AtBeginDocument{% + \@ifpackageloaded{changepage}{\let\adjbox@checkoddpage\checkoddpage}% + {\@ifpackageloaded{chngpage}{\let\adjbox@checkoddpage\checkoddpage}{}}% +}% +\define@key\adjbox@fam{min width}{% + \adjbox@Gin@Add{\@minsizebox\height{#1}!}% +} +\define@key\adjbox@fam{max width}{% + \adjbox@Gin@Add{\@maxsizebox\height{#1}!}% +} +\define@key\adjbox@fam{min height}{% + \adjbox@Gin@Add{\@minsizebox\height!{#1}}% +} +\define@key\adjbox@fam{max height}{% + \adjbox@Gin@Add{\@maxsizebox\height!{#1}}% +} +\define@key\adjbox@fam{min totalheight}{% + \adjbox@Gin@Add{\@minsizebox\totalheight!{#1}}% +} +\define@key\adjbox@fam{max totalheight}{% + \adjbox@Gin@Add{\@maxsizebox\totalheight!{#1}}% +} +\define@key\adjbox@fam{min size}{% + \adjbox@Gin@sizeadd{\@minsizebox\height}#1\relax +} +\define@key\adjbox@fam{max size}{% + \adjbox@Gin@sizeadd{\@maxsizebox\height}#1\relax +} +\define@key\adjbox@fam{min totalsize}{% + \adjbox@Gin@sizeadd{\@minsizebox\totalheight}#1\relax +} +\define@key\adjbox@fam{max totalsize}{% + \adjbox@Gin@sizeadd{\@maxsizebox\totalheight}#1\relax +} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\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 +} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\newcommand\marginbox{% + \collectboxcheckenv{marginbox}% + \@ifstar + \marginbox@s + \marginbox@ +} +\def\marginbox@#1{% + \@collectbox{\marginbox@@{#1}}% +} +\def\marginbox@s#1{% + \@collectbox{\marginbox@@s{#1}}% +} +\expandafter\newcommand\expandafter*\csname marginbox*\endcsname{% + \@collectboxisenv{marginbox*}% + \marginbox@s +} +\def\marginbox@@#1{% + \adjbox@parse@v{#1}% + \@marginbox + \adjbox@tllx + \adjbox@tlly + \adjbox@turx + \adjbox@tury + \collectedbox + \usebox\collectedbox +} +\def\marginbox@@s#1{% + \adjbox@parse@v{#1}% + \@marginbox + \adjbox@tllx + \adjbox@tlly + \adjbox@turx + \adjbox@tury + \collectedbox + \raise\adjbox@tlly\copy\collectedbox +} +\def\@marginbox#1#2#3#4#5{% + \setbox#5=\hbox{% + \adjsetlength\@tempdima{#1}% + \hskip\@tempdima + \adjsetlength\@tempdima{\dp#5 + #2}% + \adjsetlength\@tempdimb{\wd#5 + #3}% + \adjsetlength\@tempdimc{\ht#5 + #4}% + \dp#5=\@tempdima + \wd#5=\@tempdimb + \ht#5=\@tempdimc + \box#5% + }% +} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\define@key{adjbox}{minipage}{% + \@ifnextchar[{% + \adjbox@innerenv{minipage}% + }{% + \adjbox@innerenv{minipage}{{#1}}\@nnil% + \remove@to@nnil + }#1\@nnil +} +\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}}}% +}% +\define@key{adjbox}{innercode}{% + \adjbox@innercode#1{}{}% +} +\def\adjbox@innerenv#1#2\@nnil{% + \def\adjbox@collectbox##1{\collectbox@{\begin{#1}#2}{##1}{\end{#1}}}% +}% +\def\adjbox@innercode#1#2{% + \def\adjbox@collectbox##1{\collectbox@{#1}{##1}{#2}}% +}% +\define@key{adjbox}{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}{Addcode}{% + \adjust@@addcode#1{}\@nnil% +} +\define@key{adjbox}{addcode}{% + \Gin@esetsize + \@tempswatrue + \adjust@@addcode#1{}\@nnil% +} +\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}% } +\def\adjust@addcode#1#2{% + \def\@tempa{#1}% + \toks@\expandafter\expandafter\expandafter{\expandafter\@tempa\expandafter{\the\toks@}#2}% +}% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \endinput %% %% End of file `adjustbox.sty'. -- cgit v1.2.3