% \iffalse meta-comment %<=*COPYRIGHT> %% Copyright (C) 2011-2022 by Martin Scharrer %% ------------------------------------------------------------------- %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 %% of this license or (at your option) any later version. %% The latest version of this license is in %% http://www.latex-project.org/lppl.txt %% and version 1.3 or later is part of all distributions of LaTeX %% version 2005/12/01 or later. %% %% This work has the LPPL maintenance status `maintained'. %% %% The Current Maintainer of this work is Martin Scharrer. %% %% This work consists of the files trimclip.dtx, adjustbox.ins %% and the derived files trimclip.sty, %% tc-dvips.def, tc-pdftex.def, tc-luatex.def, tc-pgf.def and tc-xetex.def. %% Further author information are located in the .def files. %% %<=/COPYRIGHT> % \fi % % \iffalse %<*driver> \ProvidesFile{trimclip.dtx}[% %<=*DATE> 2020/08/19 %<=/DATE> %<=*VERSION> v1.2 %<=/VERSION> DTX file for the trimclip package] \documentclass[a4paper]{ydoc}[2011/11/16] \GetFileInfo{trimclip.dtx} \usepackage{trimclip}[\filedate] \usepackage[utf8]{inputenc} \usepackage{standalone} %\AtBeginDocument{\MakeShortMacroArgs\`\relax} %\AtEndDocument{\DeleteShortVerb\`} % \normalmarginpar \usepackage{flafter} \usepackage{tikz} \usetikzlibrary{calc} \newsavebox\mybox \renewenvironment{example}[1][Example:]{% \subsubsection*{#1}% }{% \par } \newenvironment{examples}[1][Examples:]{% \subsubsection*{#1}% }{% \par } \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, } \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-\fboxrule \rule[-.25\fboxrule]{\wd\exampleresultbox}{.5\fboxrule}% \hskip-\wd\exampleresultbox }% \usebox\exampleresultbox }% }% \makeatother \colorlet{exampleborder}{black!33} \def\Descsep{\par\vskip-2.5ex\relax} \def\examplecontent{\raisebox{-4pt}{\begin{tabular}[b]{@{}|c|c|@{}} \hline A & B \\ \hline C & D \\ \hline \end{tabular}% }} %\EnableCrossrefs %\CodelineIndex %\RecordChanges \OnlyDescription \renewcommand\topfraction{.9} \renewcommand\bottomfraction{.9} \renewcommand\textfraction{.1} \renewcommand\floatpagefraction{.5} \renewcommand\dbltopfraction{.7} \renewcommand\dblfloatpagefraction{.5} \begin{document} \DocInput{trimclip.dtx} \PrintChanges %\newpage\PrintIndex \end{document} % % \fi % % \CheckSum{1124} % % \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 % Lower-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 % Digits \0\1\2\3\4\5\6\7\8\9 % Exclamation \! Double quote \" Hash (number) \# % Dollar \$ Percent \% Ampersand \& % Acute accent \' Left paren \( Right paren \) % Asterisk \* Plus \+ Comma \, % Minus \- Point \. Solidus \/ % Colon \: Semicolon \; Less than \< % Equals \= Greater than \> Question mark \? % Commercial at \@ Left bracket \[ Backslash \\ % Right bracket \] Circumflex \^ Underscore \_ % Grave accent \` Left brace \{ Vertical bar \| % Right brace \} Tilde \~} % % % \changes{v1.0}{2012/05/16}{First version after extraction from \pkg{adjustbox} package.} % \changes{v1.1}{2018/04/08}{Driver support for round corner clipping.} % \changes{v1.2}{2020/08/19}{Added explicit LuaTeX driver.} % % \GetFileInfo{trimclip.dtx} % % \DoNotIndex{\newcommand,\newenvironment,\def,\edef,\xdef,\gdef,\let} % \bundle{adjustbox} % \author{Martin Scharrer} % \email{martin.scharrer@web.de} % \ydocpdfsettings % \maketitle % % \makeatletter % \def\LATeX{\texorpdfstring{(L\kern -.36em{\sbox \z@ T\vbox to\ht \z@ {\hbox {\check@mathfonts % \fontsize \sf@size \z@ \math@fontsfalse \selectfont A}\vss }}\kern -.15em)\TeX}{(La)TeX}} % \makeatother % % \vspace{-\baselineskip} % \begin{abstract} % This package extends the standard \pkg{graphicx} package by providing the missing \Macro\trimbox and \Macro\clipbox % macros to trim and clip arbitrary \TeX\ material. % The macros allow for verbatim content. Equivalent environments are also provided. % The package comes with own clipping drivers for all common output formats as well as a \pkg{pgf} fall-back driver. % \end{abstract} % % \section{Introduction} % The standard \LaTeX{} package \pkg{graphicx}.^^A\footnote{Actually it is the \pkg{graphics} package, but % ^^Athis is assumed to be completely superseded by its extension \pkg{graphicx}.} % allows to scale, resize and rotate either images or text (i.e.\ any \TeX\ content). For text the macros % \Macro\scalebox, \Macro\resizebox and \Macro\rotatebox can be used, while equivalent keys exist for the % \Macro\includegraphics macro. However, while it is possible to trim and clip images using the \Key{trim}, \Key{viewport} % and \Key{clip} keys, no equivalent macros are provided. This package closes this gap by defining the macros % \Macro\trimbox and \Macro\clipbox. As an extra the macro \Macro\marginbox is also provided. It can be seen as an % inverted \Macro\trimbox, expanding the official size of the content instead of reducing it. % Originally these macros were included in the \pkg{adjustbox} package together with the general \Macro\adjustbox macro. % However, the fundamental clip and trim macros and their driver files are now packed into this minimalistic package, % so that other packages can reuse its functionality without the need to load the ever-growing \pkg{adjustbox} package. % % \enlargethispage{\baselineskip} % The macros provided by this package differ in three aspects from the macros defined by \pkg{graphicx}. The content % argument is actually read directly as a horizontal box and not as a macro argument, even when the syntax looks the % same. This allows for arbitrary content including special things like verbatim material. It is allowed to replace the % "{ }" around the content with \Macro\bgroup and \Macro\egroup. Furthermore, for every macro there is an equivalent % environment with the same name. Special care is taken to allow the same name for both, which is normally not allowed. % Finally, the lengths arguments of the macros can contain algebraic expressions to calculate the used length. This is % only possible with the \pkg{graphicx} macros if the \pkg{calc} package is loaded. However, the \pkg{trimclip} macros % use the \pkg{adjcalc} wrapper package which either uses $\epsilon$-\TeX\ primitives, \pkg{calc} or \pkg{pgfmath} to % provide this feature. % % % \section{Dependencies} % This package uses the author's other packages \pkg{collectbox} (to collect the content as a real box) and % \pkg{adjcalc} (to allow for math expressions for lengths). The latter is part of the same \pkg{adjustbox} bundle and % should have be installed together with \pkg{trimclip}. % % \section{Drivers} % The clip operation can not be implemented using general \TeX\ commands, but is rather output format specific. The % clipped material is actually included unclipped and the output file (i.e.\ PDF or PS file) contains format specific % instructions, so that the document viewer will clip the content when the document is displayed. Depending on the used % compilation work-flow (like |pdflatex|, |latex|+|dvips| or |latex|+|dvipdfm|, etc.) this clipping instructions must be % passed in a different way. In order to support all of these, dedicated driver files are provided which hold the % specific low-level instructions. This requirement should also be known to most users from the \pkg{graphics/x}, % \pkg{(x)color} or \pkg{hyperref} packages which also require output format specific low-level instructions to % implement their features. % % A set of driver files for the most common used \LaTeX\ compilers is provided with this package (see % \autoref{sec:options} for a list). If no suitable driver file is found, the \pkg{pgf} package is used instead to % implement the clip operation. This (large) package comes with its own set of driver files and should cover any other % \LaTeX\ compilers. The \pkg{trimclip} drivers were inspired by the \pkg{graphic/x} and \pkg{pgf} driver code and % were written by Joseph Wright of the \LaTeX3 project and Martin Scharrer (the author of this package). % % \section{Package Options}\label{sec:options} % Normally the package should be loaded without any options. A suitable driver will then automatically be selected. % However, the package accepts the following options to select the used driver manually. Any other option is passed to the % \pkg{graphicx} package and the driver selected by it is used. However, this does not work if \pkg{graphicx} or % \pkg{graphics} was already loaded before. In this case any unknown option is taken as driver and a file % `\MacroArgs'tc-'