| 1 |
% \iffalse meta-comment |
| 2 |
%<=*COPYRIGHT> |
| 3 |
%% Copyright (C) 2011-2025 by Martin Scharrer <[email protected]> |
| 4 |
%% ------------------------------------------------------------------- |
| 5 |
%% This work may be distributed and/or modified under the |
| 6 |
%% conditions of the LaTeX Project Public License, either version 1.3 |
| 7 |
%% of this license or (at your option) any later version. |
| 8 |
%% The latest version of this license is in |
| 9 |
%% http://www.latex-project.org/lppl.txt |
| 10 |
%% and version 1.3 or later is part of all distributions of LaTeX |
| 11 |
%% version 2005/12/01 or later. |
| 12 |
%% |
| 13 |
%% This work has the LPPL maintenance status `maintained'. |
| 14 |
%% |
| 15 |
%% The Current Maintainer of this work is Martin Scharrer. |
| 16 |
%% |
| 17 |
%% This work consists of the files trimclip.dtx, adjustbox.ins |
| 18 |
%% and the derived files trimclip.sty, |
| 19 |
%% tc-dvips.def, tc-pdftex.def, tc-luatex.def, tc-pgf.def and tc-xetex.def. |
| 20 |
%% Further author information are located in the .def files. |
| 21 |
%% |
| 22 |
%<=/COPYRIGHT> |
| 23 |
% \fi |
| 24 |
% |
| 25 |
% \iffalse |
| 26 |
%<*driver> |
| 27 |
\ProvidesFile{trimclip.dtx}[% |
| 28 |
%<=*DATE> |
| 29 |
2025/02/21 |
| 30 |
%<=/DATE> |
| 31 |
%<=*VERSION> |
| 32 |
v1.2a |
| 33 |
%<=/VERSION> |
| 34 |
DTX file for the trimclip package] |
| 35 |
\documentclass[a4paper]{ydoc}[2011/11/16] |
| 36 |
\GetFileInfo{trimclip.dtx} |
| 37 |
\usepackage{trimclip}[\filedate] |
| 38 |
|
| 39 |
\usepackage[utf8]{inputenc} |
| 40 |
\usepackage{standalone} |
| 41 |
|
| 42 |
%\AtBeginDocument{\MakeShortMacroArgs\`\relax} |
| 43 |
%\AtEndDocument{\DeleteShortVerb\`} |
| 44 |
% |
| 45 |
\normalmarginpar |
| 46 |
|
| 47 |
\usepackage{flafter} |
| 48 |
|
| 49 |
\usepackage{tikz} |
| 50 |
\usetikzlibrary{calc} |
| 51 |
\newsavebox\mybox |
| 52 |
|
| 53 |
\renewenvironment{example}[1][Example:]{% |
| 54 |
\subsubsection*{#1}% |
| 55 |
}{% |
| 56 |
\par |
| 57 |
} |
| 58 |
\newenvironment{examples}[1][Examples:]{% |
| 59 |
\subsubsection*{#1}% |
| 60 |
}{% |
| 61 |
\par |
| 62 |
} |
| 63 |
\optionaloff |
| 64 |
|
| 65 |
\lstdefinelanguage{none}{}% |
| 66 |
\lstdefinelanguage{adjustbox}{% |
| 67 |
moretexcs={% |
| 68 |
begin,end,adjustbox |
| 69 |
}, |
| 70 |
emph={% |
| 71 |
frame,fbox,cframe,cfbox,minipage,raise |
| 72 |
}, |
| 73 |
}% |
| 74 |
|
| 75 |
\lstdefinestyle{examplecode}{% |
| 76 |
basicstyle=\ttfamily\small, |
| 77 |
numbers=none,language=none, |
| 78 |
classoffset=1, |
| 79 |
morekeywords={begin,end}, |
| 80 |
keywordstyle=\bfseries, |
| 81 |
classoffset=0, |
| 82 |
morekeywords={adjustbox,minsizebox,maxsizebox,lapbox,marginbox,phantombox}, |
| 83 |
keywordstyle=\macrodescstyle, |
| 84 |
} |
| 85 |
|
| 86 |
\makeatletter |
| 87 |
\def\PrintExample{% |
| 88 |
\begingroup |
| 89 |
\par\smallskip\noindent |
| 90 |
\leavevmode |
| 91 |
\BoxExample |
| 92 |
\@tempdima=\textwidth |
| 93 |
\advance\@tempdima by -\wd\examplecodebox\relax |
| 94 |
\advance\@tempdima by -\wd\exampleresultbox\relax |
| 95 |
\advance\@tempdima by -15pt\relax |
| 96 |
\ifdim\@tempdima>\bigskipamount |
| 97 |
\hbox to \textwidth{% |
| 98 |
\null\hss |
| 99 |
\minipage[c]{\wd\examplecodebox}\usebox\examplecodebox\endminipage |
| 100 |
\hfill\hskip\bigskipamount\hfill |
| 101 |
\minipage[c]{\wd\exampleresultbox}% |
| 102 |
\EXAMPLERESULT |
| 103 |
\endminipage |
| 104 |
\hss\null |
| 105 |
}% |
| 106 |
\else |
| 107 |
\vbox{% |
| 108 |
\leftline{\usebox\examplecodebox}% |
| 109 |
\vspace{\bigskipamount}% |
| 110 |
\rightline{\EXAMPLERESULT}% |
| 111 |
}% |
| 112 |
\fi |
| 113 |
\par\smallskip |
| 114 |
\endgroup |
| 115 |
} |
| 116 |
\def\EXAMPLERESULT{% |
| 117 |
\leavevmode\hbox{% |
| 118 |
\textcolor{exampleborder}{% |
| 119 |
\boxframe |
| 120 |
{\dimexpr\wd\exampleresultbox+2\fboxrule\relax}% |
| 121 |
{\dimexpr\ht\exampleresultbox+\fboxrule\relax}% |
| 122 |
{\dimexpr\dp\exampleresultbox+\fboxrule\relax}% |
| 123 |
\hskip-\wd\exampleresultbox |
| 124 |
\hskip-\fboxrule |
| 125 |
\rule[-.25\fboxrule]{\wd\exampleresultbox}{.5\fboxrule}% |
| 126 |
\hskip-\wd\exampleresultbox |
| 127 |
}% |
| 128 |
\usebox\exampleresultbox |
| 129 |
}% |
| 130 |
}% |
| 131 |
\makeatother |
| 132 |
\colorlet{exampleborder}{black!33} |
| 133 |
\def\Descsep{\par\vskip-2.5ex\relax} |
| 134 |
|
| 135 |
\def\examplecontent{\raisebox{-4pt}{\begin{tabular}[b]{@{}|c|c|@{}} |
| 136 |
\hline |
| 137 |
A & B \\ |
| 138 |
\hline |
| 139 |
C & D \\ |
| 140 |
\hline |
| 141 |
\end{tabular}% |
| 142 |
}} |
| 143 |
|
| 144 |
%\EnableCrossrefs |
| 145 |
%\CodelineIndex |
| 146 |
%\RecordChanges |
| 147 |
\OnlyDescription |
| 148 |
\renewcommand\topfraction{.9} |
| 149 |
\renewcommand\bottomfraction{.9} |
| 150 |
\renewcommand\textfraction{.1} |
| 151 |
\renewcommand\floatpagefraction{.5} |
| 152 |
\renewcommand\dbltopfraction{.7} |
| 153 |
\renewcommand\dblfloatpagefraction{.5} |
| 154 |
\begin{document} |
| 155 |
\DocInput{trimclip.dtx} |
| 156 |
\PrintChanges |
| 157 |
%\newpage\PrintIndex |
| 158 |
\end{document} |
| 159 |
%</driver> |
| 160 |
% \fi |
| 161 |
% |
| 162 |
% \CheckSum{1124} |
| 163 |
% |
| 164 |
% \CharacterTable |
| 165 |
% {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 |
| 166 |
% 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 |
| 167 |
% Digits \0\1\2\3\4\5\6\7\8\9 |
| 168 |
% Exclamation \! Double quote \" Hash (number) \# |
| 169 |
% Dollar \$ Percent \% Ampersand \& |
| 170 |
% Acute accent \' Left paren \( Right paren \) |
| 171 |
% Asterisk \* Plus \+ Comma \, |
| 172 |
% Minus \- Point \. Solidus \/ |
| 173 |
% Colon \: Semicolon \; Less than \< |
| 174 |
% Equals \= Greater than \> Question mark \? |
| 175 |
% Commercial at \@ Left bracket \[ Backslash \\ |
| 176 |
% Right bracket \] Circumflex \^ Underscore \_ |
| 177 |
% Grave accent \` Left brace \{ Vertical bar \| |
| 178 |
% Right brace \} Tilde \~} |
| 179 |
% |
| 180 |
% |
| 181 |
% \changes{v1.0}{2012/05/16}{First version after extraction from \pkg{adjustbox} package.} |
| 182 |
% \changes{v1.1}{2018/04/08}{Driver support for round corner clipping.} |
| 183 |
% \changes{v1.2}{2020/08/19}{Added explicit LuaTeX driver.} |
| 184 |
% |
| 185 |
% \GetFileInfo{trimclip.dtx} |
| 186 |
% |
| 187 |
% \DoNotIndex{\newcommand,\newenvironment,\def,\edef,\xdef,\gdef,\let} |
| 188 |
% \bundle{adjustbox} |
| 189 |
% \author{Martin Scharrer} |
| 190 |
% \email{[email protected]} |
| 191 |
% \ydocpdfsettings |
| 192 |
% \maketitle |
| 193 |
% |
| 194 |
% \makeatletter |
| 195 |
% \def\LATeX{\texorpdfstring{(L\kern -.36em{\sbox \z@ T\vbox to\ht \z@ {\hbox {\check@mathfonts |
| 196 |
% \fontsize \sf@size \z@ \math@fontsfalse \selectfont A}\vss }}\kern -.15em)\TeX}{(La)TeX}} |
| 197 |
% \makeatother |
| 198 |
% |
| 199 |
% \vspace{-\baselineskip} |
| 200 |
% \begin{abstract} |
| 201 |
% This package extends the standard \pkg{graphicx} package by providing the missing \Macro\trimbox and \Macro\clipbox |
| 202 |
% macros to trim and clip arbitrary \TeX\ material. |
| 203 |
% The macros allow for verbatim content. Equivalent environments are also provided. |
| 204 |
% The package comes with own clipping drivers for all common output formats as well as a \pkg{pgf} fall-back driver. |
| 205 |
% \end{abstract} |
| 206 |
% |
| 207 |
% \section{Introduction} |
| 208 |
% The standard \LaTeX{} package \pkg{graphicx}.^^A\footnote{Actually it is the \pkg{graphics} package, but |
| 209 |
% ^^Athis is assumed to be completely superseded by its extension \pkg{graphicx}.} |
| 210 |
% allows to scale, resize and rotate either images or text (i.e.\ any \TeX\ content). For text the macros |
| 211 |
% \Macro\scalebox, \Macro\resizebox and \Macro\rotatebox can be used, while equivalent keys exist for the |
| 212 |
% \Macro\includegraphics macro. However, while it is possible to trim and clip images using the \Key{trim}, \Key{viewport} |
| 213 |
% and \Key{clip} keys, no equivalent macros are provided. This package closes this gap by defining the macros |
| 214 |
% \Macro\trimbox and \Macro\clipbox. As an extra the macro \Macro\marginbox is also provided. It can be seen as an |
| 215 |
% inverted \Macro\trimbox, expanding the official size of the content instead of reducing it. |
| 216 |
% Originally these macros were included in the \pkg{adjustbox} package together with the general \Macro\adjustbox macro. |
| 217 |
% However, the fundamental clip and trim macros and their driver files are now packed into this minimalistic package, |
| 218 |
% so that other packages can reuse its functionality without the need to load the ever-growing \pkg{adjustbox} package. |
| 219 |
% |
| 220 |
% \enlargethispage{\baselineskip} |
| 221 |
% The macros provided by this package differ in three aspects from the macros defined by \pkg{graphicx}. The content |
| 222 |
% argument is actually read directly as a horizontal box and not as a macro argument, even when the syntax looks the |
| 223 |
% same. This allows for arbitrary content including special things like verbatim material. It is allowed to replace the |
| 224 |
% "{ }" around the content with \Macro\bgroup and \Macro\egroup. Furthermore, for every macro there is an equivalent |
| 225 |
% environment with the same name. Special care is taken to allow the same name for both, which is normally not allowed. |
| 226 |
% Finally, the lengths arguments of the macros can contain algebraic expressions to calculate the used length. This is |
| 227 |
% only possible with the \pkg{graphicx} macros if the \pkg{calc} package is loaded. However, the \pkg{trimclip} macros |
| 228 |
% use the \pkg{adjcalc} wrapper package which either uses $\epsilon$-\TeX\ primitives, \pkg{calc} or \pkg{pgfmath} to |
| 229 |
% provide this feature. |
| 230 |
% |
| 231 |
% |
| 232 |
% \section{Dependencies} |
| 233 |
% This package uses the author's other packages \pkg{collectbox} (to collect the content as a real box) and |
| 234 |
% \pkg{adjcalc} (to allow for math expressions for lengths). The latter is part of the same \pkg{adjustbox} bundle and |
| 235 |
% should have be installed together with \pkg{trimclip}. |
| 236 |
% |
| 237 |
% \section{Drivers} |
| 238 |
% The clip operation can not be implemented using general \TeX\ commands, but is rather output format specific. The |
| 239 |
% clipped material is actually included unclipped and the output file (i.e.\ PDF or PS file) contains format specific |
| 240 |
% instructions, so that the document viewer will clip the content when the document is displayed. Depending on the used |
| 241 |
% compilation work-flow (like |pdflatex|, |latex|+|dvips| or |latex|+|dvipdfm|, etc.) this clipping instructions must be |
| 242 |
% passed in a different way. In order to support all of these, dedicated driver files are provided which hold the |
| 243 |
% specific low-level instructions. This requirement should also be known to most users from the \pkg{graphics/x}, |
| 244 |
% \pkg{(x)color} or \pkg{hyperref} packages which also require output format specific low-level instructions to |
| 245 |
% implement their features. |
| 246 |
% |
| 247 |
% A set of driver files for the most common used \LaTeX\ compilers is provided with this package (see |
| 248 |
% \autoref{sec:options} for a list). If no suitable driver file is found, the \pkg{pgf} package is used instead to |
| 249 |
% implement the clip operation. This (large) package comes with its own set of driver files and should cover any other |
| 250 |
% \LaTeX\ compilers. The \pkg{trimclip} drivers were inspired by the \pkg{graphic/x} and \pkg{pgf} driver code and |
| 251 |
% were written by Joseph Wright of the \LaTeX3 project and Martin Scharrer (the author of this package). |
| 252 |
% |
| 253 |
% \section{Package Options}\label{sec:options} |
| 254 |
% Normally the package should be loaded without any options. A suitable driver will then automatically be selected. |
| 255 |
% However, the package accepts the following options to select the used driver manually. Any other option is passed to the |
| 256 |
% \pkg{graphicx} package and the driver selected by it is used. However, this does not work if \pkg{graphicx} or |
| 257 |
% \pkg{graphics} was already loaded before. In this case any unknown option is taken as driver and a file |
| 258 |
% `\MacroArgs'tc-'<option>'.def'\relax' is loaded if it exits. If not, the default PGF fall-back driver is used. PGF |
| 259 |
% comes with a own set of drivers but is large and can be considered a significant overhead if used only for rectangular |
| 260 |
% clipping. |
| 261 |
% |
| 262 |
% \begin{description} |
| 263 |
% \def\Option#1{\item[{{\normalfont\opt{#1}}}]}% |
| 264 |
% \Option{pdftex} Use the |pdftex| driver. This driver is automatically selected for |pdflatex|. |
| 265 |
% \Option{luatex} Use the |luatex| driver, which uses the |pdftex| driver internally. |
| 266 |
% This driver is automatically selected for |lualatex|. |
| 267 |
% \Option{dvips} Use the |dvips| driver. This driver is automatically selected for |latex|. |
| 268 |
% \Option{xetex} Use the |xetex| driver. This driver is automatically selected for |xelatex|. |
| 269 |
% \Option{dvipdfm} Use the |xetex| driver which is also compatible with |dvipdfm|. |
| 270 |
% \Option{dvipdfmx} Use the |xetex| driver which is also compatible with |dvipdfmx|. |
| 271 |
% \Option{pgf} Use the fall-back PGF driver explicitly. This makes sense if issue with another driver are encountered. |
| 272 |
% \end{description} |
| 273 |
% |
| 274 |
% It should be noted that choosing an incorrect driver will lead to clip operation not being applied (they act like trim |
| 275 |
% operations) and may lead to a broken output file. |
| 276 |
% |
| 277 |
% |
| 278 |
% \section{Argument Values}\label{sec:argval} |
| 279 |
% All macros of this package and their matching environments require four length values which are used to change the |
| 280 |
% left, bottom, right and top side of the content. Because of the used \pkg{adjcalc} package complicated algebraic |
| 281 |
% expressions can be used to calculate these amounts. The used math engine can be changed by loading \pkg{adjcalc} |
| 282 |
% with the appropriate option before loading \pkg{trimclip}. Please see the \pkg{adjcalc} manual for more details |
| 283 |
% on this. |
| 284 |
% Like with the |trim| or |viewport| keys of \Macro\includegraphics the length values must be separated by spaces. |
| 285 |
% Note that if a previous length expression ends in a macro any trailing spaces will be removed by \TeX. Therefore it |
| 286 |
% is required to wrap this \emph{complete} length expression in braces. |
| 287 |
% Several examples of this are shown in the \emph{Usage} section. |
| 288 |
% It is also possible to only provide a single length which is used for all four |
| 289 |
% sides or only two lengths which are taken for the left/right as well as bottom/top side. This simplifies symmetric |
| 290 |
% operations and got inspired by Cascading Style Sheets (CSS) used to style websites. |
| 291 |
% |
| 292 |
% If a length value is a simple number without a unit, a default unit is substituted (usually `|bp|', \emph{big points}, |
| 293 |
% the standard PostScript and PDF unit). This default unit can be changed using \Macro\adjcalc{'defaultunit='<unit>} or |
| 294 |
% completely disabled (\MacroArgs'defaultunit=none'). See the \pkg{adjcalc} manual for more details. |
| 295 |
% |
| 296 |
% The length values can contain the following macros to refer to the original size of the content: |
| 297 |
% |
| 298 |
% \DescribeMacros |
| 299 |
% \hbox{\Macro\width~~~\Macro\height~~~\Macro\depth~~~\Macro\totalheight}% |
| 300 |
% \endDescribeMacros |
| 301 |
% These \LaTeX{} lengths hold the original dimensions of the content and can be used to make relative changes. Like any |
| 302 |
% other length registers they can be used with a factor, e.g.\ \MacroArgs'.5'\AlsoMacro\width to refer to half the |
| 303 |
% natural width of the content. |
| 304 |
% |
| 305 |
% |
| 306 |
% \section{Usage} |
| 307 |
% |
| 308 |
% \subsection{Trimming} |
| 309 |
% \vspace{-\medskipamount} |
| 310 |
% \DescribeMacro\trimbox{<llx>~<lly>~<urx>~<ury>}{<content>} |
| 311 |
% \DescribeMacro\trimbox{<all sites>}{<content>} |
| 312 |
% \DescribeMacro\trimbox{<left/right>~<top/bottom>}{<content>} |
| 313 |
% \DescribeMacro\trimbox*{<llx>~<lly>~<urx>~<ury>}{<content>} |
| 314 |
% The macro \Macro\trimbox trims the given amount from the lower left (ll) and the upper right (ur) corner of |
| 315 |
% the box. This means that the amount \meta{llx} is trimmed from the left side, \meta{lly} from the bottom and |
| 316 |
% \meta{urx} and \meta{ury} from the right and top of the box, respectively. |
| 317 |
% If only one value is given it will be used for all four sites. |
| 318 |
% 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). |
| 319 |
% |
| 320 |
% If the starred version is used the four coordinates are taken as the \Key{viewport} instead, i.e. the box |
| 321 |
% is trimmed to the rectangle described by the coordinates. In this case all four values must be specified explicitly. |
| 322 |
% |
| 323 |
% \begin{examples} |
| 324 |
% \begin{examplecode} |
| 325 |
% \examplecontent |
| 326 |
% \end{examplecode} |
| 327 |
% \begin{examplecode} |
| 328 |
% \trimbox{2pt 3pt 2pt 3pt}{\examplecontent} |
| 329 |
% \end{examplecode} |
| 330 |
% \begin{examplecode} |
| 331 |
% \trimbox{2pt 3pt}{\examplecontent} |
| 332 |
% \end{examplecode} |
| 333 |
% \begin{examplecode} |
| 334 |
% \trimbox{2pt}{\examplecontent} |
| 335 |
% \end{examplecode} |
| 336 |
% \begin{examplecode} |
| 337 |
% \trimbox{{.5\width} {.5\totalheight} 2pt 2pt} |
| 338 |
% {\examplecontent} |
| 339 |
% \end{examplecode} |
| 340 |
% \medskip |
| 341 |
% \begin{examplecode} |
| 342 |
% \trimbox*{5pt 0pt 3em 2em}{\examplecontent} |
| 343 |
% \end{examplecode} |
| 344 |
% \medskip |
| 345 |
% \begin{examplecode} |
| 346 |
% \trimbox*{5pt -2pt 3em 2em}{\examplecontent} |
| 347 |
% \end{examplecode} |
| 348 |
% \medskip |
| 349 |
% \begin{examplecode} |
| 350 |
% \trimbox*{5pt 10pt 3em 2em}{\examplecontent} |
| 351 |
% \end{examplecode} |
| 352 |
% \bigskip |
| 353 |
% \bigskip |
| 354 |
% \begin{examplecode} |
| 355 |
% \trimbox*{5pt -3pt 3em -1pt}{\examplecontent} |
| 356 |
% \end{examplecode} |
| 357 |
% \end{examples} |
| 358 |
% |
| 359 |
% |
| 360 |
% \DescribeEnv[<content>]{trimbox}{<1, 2 or 4 trim values>} |
| 361 |
% \vspace{-\baselineskip} |
| 362 |
% \DescribeEnv[<content>]{trimbox*}{<llx>~<lly>~<urx>~<ury>} |
| 363 |
% The \env{trimbox} and \env{trimbox*} environments do the same as the corresponding macros. |
| 364 |
% |
| 365 |
% |
| 366 |
% \Needspace*{10\baselineskip} |
| 367 |
% \subsection{Clipping} |
| 368 |
% \vspace{-\medskipamount} |
| 369 |
% \DescribeMacro\clipbox{<llx>~<lly>~<urx>~<ury>}{<content>} |
| 370 |
% \DescribeMacro\clipbox{<all sites>}{<content>} |
| 371 |
% \DescribeMacro\clipbox{<left/right>~<top/bottom>}{<content>} |
| 372 |
% \DescribeMacro\clipbox*{<llx>~<lly>~<urx>~<ury>}{<content>} |
| 373 |
% The \Macro\clipbox macro works like the \Macro\trimbox and trims the given amounts from the \meta{text}. |
| 374 |
% However, in addition the trimmed material is also clipped, i.e. it is not shown in the final document. |
| 375 |
% Note that the material will still be part of the output file but is simply not shown. |
| 376 |
% The full content can still be exported using special tools, so using \Macro\clipbox\relax (or \Macro\includegraphics[clip,trim=...]) |
| 377 |
% to censor classified information would be a bad idea. |
| 378 |
% The starred version will again use the given coordinates as viewport. |
| 379 |
% |
| 380 |
% \DescribeEnv[<content>]{clipbox}{<1, 2 or 4 trim values>} |
| 381 |
% \vspace{-\baselineskip} |
| 382 |
% \DescribeEnv[<content>]{clipbox*}{<llx>~<lly>~<urx>~<ury>} |
| 383 |
% The environment versions of \Macro\clipbox and \Macro\clipbox*. The same rules as for the trimming environments apply. |
| 384 |
% |
| 385 |
% \begin{examples} |
| 386 |
% \begin{examplecode} |
| 387 |
% \examplecontent |
| 388 |
% \end{examplecode} |
| 389 |
% \begin{examplecode} |
| 390 |
% \clipbox{2pt 3pt 2pt 3pt}{\examplecontent} |
| 391 |
% \end{examplecode} |
| 392 |
% \begin{examplecode} |
| 393 |
% \clipbox{2pt 3pt}{\examplecontent} |
| 394 |
% \end{examplecode} |
| 395 |
% \begin{examplecode} |
| 396 |
% \clipbox{2pt}{\examplecontent} |
| 397 |
% \end{examplecode} |
| 398 |
% \begin{examplecode} |
| 399 |
% \clipbox{{.5\width} {.5\totalheight} 2pt 2pt} |
| 400 |
% {\examplecontent} |
| 401 |
% \end{examplecode} |
| 402 |
% \medskip |
| 403 |
% \begin{examplecode} |
| 404 |
% \clipbox*{5pt 0pt 3em 2em}{\examplecontent} |
| 405 |
% \end{examplecode} |
| 406 |
% \medskip |
| 407 |
% \begin{examplecode} |
| 408 |
% \clipbox*{5pt -2pt 3em 2em}{\examplecontent} |
| 409 |
% \end{examplecode} |
| 410 |
% \begin{examplecode} |
| 411 |
% \clipbox*{5pt 10pt 3em 2em}{\examplecontent} |
| 412 |
% \end{examplecode} |
| 413 |
% \begin{examplecode} |
| 414 |
% \clipbox*{5pt -3pt 3em -1pt}{\examplecontent} |
| 415 |
% \end{examplecode} |
| 416 |
% \end{examples} |
| 417 |
% |
| 418 |
% \subsection{Margin} |
| 419 |
% \vspace{-\medskipamount} |
| 420 |
% \DescribeMacro\marginbox{<all sites>}{<content>} |
| 421 |
% \DescribeMacro\marginbox{<left/right>~<top/bottom>}{<content>} |
| 422 |
% \DescribeMacro\marginbox{<llx>~<lly>~<urx>~<ury>}{<content>} |
| 423 |
% \Descsep |
| 424 |
% \DescribeEnv[<content>]{marginbox*}{<1, 2 or 4 margin values>} |
| 425 |
% This macro and environment can be used to add a margin (white space) around the content. It can be seen as the opposite of \Macro\trimbox. |
| 426 |
% The original baseline of the content is preserved because \meta{lly} is added to the depth. |
| 427 |
% |
| 428 |
% \begin{example} |
| 429 |
% \begin{examplecode} |
| 430 |
% Before \fbox{\marginbox{1ex 2ex 3ex 4ex}{Text}} After |
| 431 |
% \end{examplecode} |
| 432 |
% \end{example} |
| 433 |
% |
| 434 |
% |
| 435 |
% \DescribeMacro\marginbox'*'{<all sites>}{<content>} |
| 436 |
% \DescribeMacro\marginbox'*'{<left/right>~<top/bottom>}{<content>} |
| 437 |
% \DescribeMacro\marginbox'*'{<llx>~<lly>~<urx>~<ury>}{<content>} |
| 438 |
% \Descsep |
| 439 |
% \DescribeEnv[<content>]{marginbox}{<1, 2 or 4 margin values>} |
| 440 |
% This starred version is almost identical to the normal \Macro\marginbox, but also raises the content by the \MacroArgs<lly> |
| 441 |
% amount, so that the original depth is preserved instead of the original baseline. |
| 442 |
% Note that while \Macro\marginbox is basically the opposite of \Macro\trimbox, \Macro\marginbox* is not the opposite of \Macro\trimbox*. |
| 443 |
% |
| 444 |
% \begin{example} |
| 445 |
% \begin{examplecode} |
| 446 |
% Before \fbox{\marginbox*{1ex 2ex 3ex 4ex}{Text}} After |
| 447 |
% \end{examplecode} |
| 448 |
% \end{example} |
| 449 |
% |
| 450 |
% |
| 451 |
% \clearpage |
| 452 |
% \section{Diagrams} |
| 453 |
% ^^A This section explains the details about the trim and clip implementations. |
| 454 |
% ^^A It should give the interested reader a deeper understanding of the operations and the behaviour in normal and edge cases. |
| 455 |
% The box dimensions, trim values and change of the baseline for different scenarios are visualized by the following diagrams. |
| 456 |
% |
| 457 |
% \begin{figure}[!bt] |
| 458 |
% \centering |
| 459 |
% {\catcode`\%=14\relax\input{box}} |
| 460 |
% \caption{Box dimensions. Shown are also the \LaTeX\ macros and the \TeX\ primitives. Here \cs{br} stands for a box register. |
| 461 |
% Note that the depth is a positive values on its own downwards pointed axes. |
| 462 |
% }\label{fig:boxdim} |
| 463 |
% \end{figure} |
| 464 |
% |
| 465 |
% \begin{figure}[!bt] |
| 466 |
% \centering |
| 467 |
% {\catcode`\%=14\relax\input{trim}} |
| 468 |
% \caption{Trimming. The four values are removed from each side.}\label{fig:trim} |
| 469 |
% \end{figure} |
| 470 |
% |
| 471 |
% \begin{figure} |
| 472 |
% \centering |
| 473 |
% {\catcode`\%=14\relax\input{trim2}} |
| 474 |
% \caption{Trimming with \texttt{lly}$>$depth. In this case the resulting box moves up to the original baseline.}\label{fig:trim2} |
| 475 |
% \end{figure} |
| 476 |
% |
| 477 |
% \begin{figure} |
| 478 |
% \centering |
| 479 |
% {\catcode`\%=14\relax\input{trim3}} |
| 480 |
% \caption{Trimming with \texttt{ury}$>$height. In this case the resulting box falls down to the original baseline}\label{fig:trim2} |
| 481 |
% \end{figure} |
| 482 |
% |
| 483 |
% \begin{figure} |
| 484 |
% \centering |
| 485 |
% {\catcode`\%=14\relax\input{viewport}} |
| 486 |
% \caption{Viewport with \texttt{lly}$>$0pt. The \texttt{ll} and \texttt{ur} values are taken from the origin. The baseline is the vertical zero reference.}\label{fig:viewport} |
| 487 |
% \end{figure} |
| 488 |
% |
| 489 |
% \begin{figure} |
| 490 |
% \centering |
| 491 |
% {\catcode`\%=14\relax\input{viewport2}} |
| 492 |
% \caption{Viewport with \texttt{lly}$<$0pt. In this case the viewport ranges into the depth of the original box.} |
| 493 |
% \end{figure} |
| 494 |
% |
| 495 |
% \begin{figure} |
| 496 |
% \centering |
| 497 |
% {\catcode`\%=14\relax\input{margin}} |
| 498 |
% \caption{Marginbox. The \texttt{llx} and \texttt{urx} are added to the left and right and increase the width. The \texttt{ury} is added to the height |
| 499 |
% and \texttt{lly} to the depth of the box. This keeps the baseline at the original position.} |
| 500 |
% \label{fig:margin} |
| 501 |
% \end{figure} |
| 502 |
% |
| 503 |
% \begin{figure} |
| 504 |
% \centering |
| 505 |
% {\catcode`\%=14\relax\input{margin2}} |
| 506 |
% \caption{Marginbox*. In addition to the normal margin the content |
| 507 |
% is also raised by \texttt{lly}, so that the original depth is preserved. |
| 508 |
% This effectively moves the baseline down.} |
| 509 |
% \label{fig:margin} |
| 510 |
% \end{figure} |
| 511 |
% |
| 512 |
% \StopEventually{} |
| 513 |
% \clearpage |
| 514 |
% \section{Implementation} |
| 515 |
% \setcounter{lstnumber}{1} |
| 516 |
% |
| 517 |
% |
| 518 |
% \iffalse |
| 519 |
%<*trimclip.sty> |
| 520 |
% \fi |
| 521 |
% \begin{macrocode} |
| 522 |
%<!COPYRIGHT> |
| 523 |
\ProvidesPackage{trimclip}[% |
| 524 |
%<!DATE> |
| 525 |
%<!VERSION> |
| 526 |
%<*DRIVER> |
| 527 |
2099/01/01 develop |
| 528 |
%</DRIVER> |
| 529 |
Trim and clip general TeX material] |
| 530 |
% \end{macrocode} |
| 531 |
% |
| 532 |
% |
| 533 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 534 |
% \subsection{Options} |
| 535 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 536 |
% \begin{macrocode} |
| 537 |
\def\tc@driver{tc-\Gin@driver} |
| 538 |
\DeclareOption{pgf}{\def\tc@driver{tc-pgf.def}\AtEndOfPackage{\RequirePackage{pgf}}} |
| 539 |
\DeclareOption{pdftex}{\def\tc@driver{tc-pdftex.def}\PassOptionsToPackage{pdftex}{graphicx}} |
| 540 |
\DeclareOption{luatex}{\def\tc@driver{tc-luatex.def}\PassOptionsToPackage{luatex}{graphicx}} |
| 541 |
\DeclareOption{xetex}{\def\tc@driver{tc-xetex.def}\PassOptionsToPackage{xetex}{graphicx}} |
| 542 |
\DeclareOption{dvips}{\def\tc@driver{tc-dvips.def}\PassOptionsToPackage{dvips}{graphicx}} |
| 543 |
\DeclareOption{dvipdfm}{\def\tc@driver{tc-xetex.def}\PassOptionsToPackage{xetex}{graphicx}} |
| 544 |
\DeclareOption{dvipdf}{\def\tc@driver{tc-xetex.def}\PassOptionsToPackage{xetex}{graphicx}} |
| 545 |
\DeclareOption*{% |
| 546 |
\@ifpackageloaded{graphics}{% |
| 547 |
\edef\tc@driver{tc-\CurrentOption.def}% |
| 548 |
\begingroup |
| 549 |
\edef\@tempa{\CurrentOption.def}% |
| 550 |
\ifx\@tempa\Gin@driver\else |
| 551 |
\let\on@line\@gobble |
| 552 |
\PackageWarning{trimclip}{% |
| 553 |
A different clipping driver was requested than the\MessageBreak |
| 554 |
one used for 'graphics/x'! This is not recommended\MessageBreak |
| 555 |
and can lead to defect output files.% |
| 556 |
}% |
| 557 |
\fi |
| 558 |
\endgroup |
| 559 |
}{% |
| 560 |
\def\tc@driver{tc-\Gin@driver}% |
| 561 |
\PassOptionsToPackage\CurrentOption{graphicx}% |
| 562 |
}% |
| 563 |
} |
| 564 |
\ProcessOptions*\relax |
| 565 |
% \end{macrocode} |
| 566 |
% |
| 567 |
% \begin{macrocode} |
| 568 |
\RequirePackage{graphicx}[1999/02/16] |
| 569 |
\RequirePackage{collectbox}[2011/08/22] |
| 570 |
\RequirePackage{adjcalc} |
| 571 |
% \end{macrocode} |
| 572 |
% |
| 573 |
% |
| 574 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 575 |
% \subsection{User level and auxiliary macros} |
| 576 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 577 |
% |
| 578 |
% \begin{macro}{\tc@readvalues} |
| 579 |
% Reads the four values for trim, viewport and clip. |
| 580 |
% Valid inputs are: |
| 581 |
% 4 values directly, |
| 582 |
% 1 value which is taken four times, |
| 583 |
% 2 values which is taken for left/right and top/bottom. |
| 584 |
% \begin{macrocode} |
| 585 |
\def\tc@readvalues#1{% |
| 586 |
\tc@@readvalues#1 {} {} {} \\% |
| 587 |
} |
| 588 |
% \end{macrocode} |
| 589 |
% \end{macro} |
| 590 |
% |
| 591 |
% |
| 592 |
% \begin{macro}{\tc@@readvalues} |
| 593 |
% \begin{macrocode} |
| 594 |
\def\tc@@readvalues#1 #2 #3 #4 #5\\{% |
| 595 |
\adjsetlengthdefault\tc@llx{#1}% |
| 596 |
\ifx\@nnil#2\@nnil |
| 597 |
\tc@lly\tc@llx |
| 598 |
\tc@urx\tc@llx |
| 599 |
\tc@ury\tc@llx |
| 600 |
\else |
| 601 |
\adjsetlengthdefault\tc@lly{#2}% |
| 602 |
\ifx\@nnil#3\@nnil |
| 603 |
\tc@urx\tc@llx |
| 604 |
\tc@ury\tc@lly |
| 605 |
\else |
| 606 |
\adjsetlengthdefault\tc@urx{#3}% |
| 607 |
\adjsetlengthdefault\tc@ury{#4}% |
| 608 |
\fi |
| 609 |
\fi |
| 610 |
}% |
| 611 |
% \end{macrocode} |
| 612 |
% \end{macro} |
| 613 |
% |
| 614 |
% |
| 615 |
% \begin{macro}{\tc@llx} |
| 616 |
% \begin{macro}{\tc@lly} |
| 617 |
% \begin{macro}{\tc@urx} |
| 618 |
% \begin{macro}{\tc@ury} |
| 619 |
% Dimension registers for the four trim/viewport values. |
| 620 |
% Legend: ll = lower left, ur = upper right. |
| 621 |
% \begin{macrocode} |
| 622 |
\newdimen\tc@llx |
| 623 |
\newdimen\tc@lly |
| 624 |
\newdimen\tc@urx |
| 625 |
\newdimen\tc@ury |
| 626 |
% \end{macrocode} |
| 627 |
% \end{macro} |
| 628 |
% \end{macro} |
| 629 |
% \end{macro} |
| 630 |
% \end{macro} |
| 631 |
% |
| 632 |
% |
| 633 |
% \begin{macro}{\trimbox} |
| 634 |
% \begin{macrocode} |
| 635 |
\newcommand\trimbox{% |
| 636 |
\collectboxcheckenv{trimbox}% |
| 637 |
\@ifstar |
| 638 |
\trimbox@s |
| 639 |
\trimbox@ |
| 640 |
} |
| 641 |
\def\trimbox@#1{% |
| 642 |
\collectbox{\@trimclip\@trimbox{#1}}% |
| 643 |
} |
| 644 |
\def\trimbox@s#1{% |
| 645 |
\collectbox{\@trimclip\@viewportbox{#1}}% |
| 646 |
} |
| 647 |
% \end{macrocode} |
| 648 |
% \end{macro} |
| 649 |
% |
| 650 |
% |
| 651 |
% \begin{environment}{trimbox*} |
| 652 |
% \begin{macrocode} |
| 653 |
\expandafter\newcommand\expandafter*\csname trimbox*\endcsname{% |
| 654 |
\@collectboxisenv{trimbox*}% |
| 655 |
\trimbox@s |
| 656 |
} |
| 657 |
% \end{macrocode} |
| 658 |
% \end{environment} |
| 659 |
% |
| 660 |
% |
| 661 |
% \begin{macro}{\clipbox} |
| 662 |
% \begin{macrocode} |
| 663 |
\newcommand\clipbox{% |
| 664 |
\collectboxcheckenv{clipbox}% |
| 665 |
\@ifstar |
| 666 |
\clipbox@s |
| 667 |
\clipbox@ |
| 668 |
} |
| 669 |
\def\clipbox@#1{% |
| 670 |
\collectbox{\@trimclip\@clipbox{#1}}% |
| 671 |
} |
| 672 |
\def\clipbox@s#1{% |
| 673 |
\collectbox{\@trimclip\@clipvpbox{#1}}% |
| 674 |
} |
| 675 |
% \end{macrocode} |
| 676 |
% \end{macro} |
| 677 |
% |
| 678 |
% |
| 679 |
% \begin{environment}{clipbox*} |
| 680 |
% \begin{macrocode} |
| 681 |
\expandafter\newcommand\expandafter*\csname clipbox*\endcsname{% |
| 682 |
\@collectboxisenv{clipbox*}% |
| 683 |
\clipbox@s |
| 684 |
} |
| 685 |
% \end{macrocode} |
| 686 |
% \end{environment} |
| 687 |
% |
| 688 |
% |
| 689 |
% \begin{macro}{\marginbox}[1]{Margins as space separated values (like for 'trim')} |
| 690 |
% Collect box first. |
| 691 |
% \begin{macrocode} |
| 692 |
\newcommand\marginbox{% |
| 693 |
\collectboxcheckenv{marginbox}% |
| 694 |
\@ifstar |
| 695 |
\marginbox@s |
| 696 |
\marginbox@ |
| 697 |
} |
| 698 |
\def\marginbox@#1{% |
| 699 |
\@collectbox{\@trimclip\@marginbox{#1}}% |
| 700 |
} |
| 701 |
\def\marginbox@s#1{% |
| 702 |
\@collectbox{\@trimclip\@marginraisebox{#1}}% |
| 703 |
} |
| 704 |
% \end{macrocode} |
| 705 |
% \end{macro} |
| 706 |
% |
| 707 |
% |
| 708 |
% \begin{environment}{marginbox*}[1]{Margins as space separated values (like for 'trim')} |
| 709 |
% \begin{macrocode} |
| 710 |
\expandafter\newcommand\expandafter*\csname marginbox*\endcsname{% |
| 711 |
\@collectboxisenv{marginbox*}% |
| 712 |
\marginbox@s |
| 713 |
} |
| 714 |
% \end{macrocode} |
| 715 |
% \end{environment} |
| 716 |
% |
| 717 |
% |
| 718 |
% \begin{macro}{\@trimclip}[2]{<trim/viewport/clip macro>}{<values>} |
| 719 |
% General macro which parses the values and feeds it to the given lower-level macro. |
| 720 |
% Finally the box is typeset. This macro will always be used inside a group |
| 721 |
% created by \Macro\@collectbox. |
| 722 |
% \begin{macrocode} |
| 723 |
\def\@trimclip#1#2{% |
| 724 |
\tc@readvalues{#2}% |
| 725 |
#1% |
| 726 |
\collectedbox |
| 727 |
\tc@llx |
| 728 |
\tc@lly |
| 729 |
\tc@urx |
| 730 |
\tc@ury |
| 731 |
\usebox\collectedbox |
| 732 |
} |
| 733 |
% \end{macrocode} |
| 734 |
% \end{macro} |
| 735 |
% |
| 736 |
% |
| 737 |
% |
| 738 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 739 |
% \subsection{Low-level commands} |
| 740 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 741 |
% |
| 742 |
% |
| 743 |
% \begin{macro}{\tc@correctbaseline} |
| 744 |
% Adjust baseline if required by negative depth or height. |
| 745 |
% \begin{macrocode} |
| 746 |
\def\tc@correctbaseline#1{% |
| 747 |
% \end{macrocode} |
| 748 |
% If depth is negative lower the box to get zero depth |
| 749 |
% \begin{macrocode} |
| 750 |
\ifdim\dp#1<\z@ |
| 751 |
\raise\dp#1% |
| 752 |
\else |
| 753 |
% \end{macrocode} |
| 754 |
% Else if height is negative lower the box to get zero height |
| 755 |
% \begin{macrocode} |
| 756 |
\ifdim\ht#1<\z@ |
| 757 |
\lower\ht#1% |
| 758 |
\fi\fi |
| 759 |
\box#1% |
| 760 |
}% |
| 761 |
% \end{macrocode} |
| 762 |
% \end{macro} |
| 763 |
% |
| 764 |
% |
| 765 |
% \begin{macro}{\tc@correctdims} |
| 766 |
% Ensure that all dimensions are non-negative. |
| 767 |
% \begin{macrocode} |
| 768 |
\def\tc@correctdims#1{% |
| 769 |
\ifdim\dp#1<\z@ \dp#1=\z@ \fi |
| 770 |
\ifdim\wd#1<\z@ \wd#1=\z@ \fi |
| 771 |
\ifdim\ht#1<\z@ \ht#1=\z@ \fi |
| 772 |
} |
| 773 |
% \end{macrocode} |
| 774 |
% \end{macro} |
| 775 |
% |
| 776 |
% |
| 777 |
% \begin{macro}{\@trimbox}[5]{<box register>}{<tllx>}{<tlly>}{<turx>}{<tury>} |
| 778 |
% Removes the four length for the left, bottom, right and top from the official size of the box register. |
| 779 |
% \begin{macrocode} |
| 780 |
\def\@trimbox#1#2#3#4#5{% |
| 781 |
\setbox#1=\hbox{% |
| 782 |
% |
| 783 |
\tc@llx=#2\relax |
| 784 |
\tc@lly=#3\relax |
| 785 |
\advance\tc@lly-\dp#1% |
| 786 |
\tc@urx=#4\relax |
| 787 |
\advance\tc@urx-\wd#1% |
| 788 |
\tc@ury=#5\relax |
| 789 |
\advance\tc@ury-\ht#1% |
| 790 |
% |
| 791 |
% Set dimensions now. |
| 792 |
% This allows that the arguments can refer |
| 793 |
% to the original dimensions without issues. |
| 794 |
\hskip-\tc@llx |
| 795 |
\dp#1-\tc@lly |
| 796 |
\wd#1-\tc@urx |
| 797 |
\ht#1-\tc@ury |
| 798 |
% |
| 799 |
\tc@correctbaseline{#1}% |
| 800 |
}% |
| 801 |
\tc@correctdims{#1}% |
| 802 |
} |
| 803 |
% \end{macrocode} |
| 804 |
% \end{macro} |
| 805 |
% |
| 806 |
% |
| 807 |
% |
| 808 |
% \begin{macro}{\@marginbox} |
| 809 |
% Adds the given margins to the depth, width and height. |
| 810 |
% The left margin is created by an horizontal skip. |
| 811 |
% This implementation assumes that the margins are positive and no special checks are added. |
| 812 |
% While negative margins will trim some margin off, this will not lead to correct results if this amounts |
| 813 |
% are larger than the existing dimensions. For this the \Macro\@trimbox macro should be used. |
| 814 |
% \begin{macrocode} |
| 815 |
\def\@marginbox#1#2#3#4#5{% |
| 816 |
\setbox#1=\hbox{% |
| 817 |
% |
| 818 |
\tc@llx=#2\relax |
| 819 |
\tc@lly=#3\relax |
| 820 |
\advance\tc@lly\dp#1% |
| 821 |
\tc@urx=#4\relax |
| 822 |
\advance\tc@urx\wd#1% |
| 823 |
\tc@ury=#5\relax |
| 824 |
\advance\tc@ury\ht#1% |
| 825 |
% |
| 826 |
% Set dimensions now. |
| 827 |
% This allows that the arguments can refer |
| 828 |
% to the original dimensions without issues. |
| 829 |
\hskip\tc@llx |
| 830 |
\dp#1\tc@lly |
| 831 |
\wd#1\tc@urx |
| 832 |
\ht#1\tc@ury |
| 833 |
% |
| 834 |
\box#1% |
| 835 |
}% |
| 836 |
\tc@correctdims{#1}% |
| 837 |
} |
| 838 |
% \end{macrocode} |
| 839 |
% \end{macro} |
| 840 |
% |
| 841 |
% \begin{macro}{\@marginraisebox} |
| 842 |
% Like \Macro\@marginbox but raises the box accordant to the bottom margin, |
| 843 |
% so that the original depth is kept. |
| 844 |
% \begin{macrocode} |
| 845 |
\def\@marginraisebox#1#2#3#4#5{% |
| 846 |
\setbox#1=\hbox{% |
| 847 |
% |
| 848 |
\tc@llx=#2\relax |
| 849 |
\tc@lly=#3\relax |
| 850 |
\tc@urx=#4\relax |
| 851 |
\advance\tc@urx\wd#1% |
| 852 |
\tc@ury=#5\relax |
| 853 |
\advance\tc@ury\ht#1% |
| 854 |
% |
| 855 |
% Set dimensions now. |
| 856 |
% This allows that the arguments can refer |
| 857 |
% to the original dimensions without issues. |
| 858 |
\hskip\tc@llx |
| 859 |
\wd#1\tc@urx |
| 860 |
\ht#1\tc@ury |
| 861 |
% Copy original tty values (ury is taken as temp dimension) |
| 862 |
\tc@ury=\tc@lly |
| 863 |
\advance\tc@lly\dp#1% |
| 864 |
\dp#1\tc@lly |
| 865 |
% Raise bu original tty value (now in ury) |
| 866 |
\raise\tc@ury\box#1% |
| 867 |
}% |
| 868 |
\tc@correctdims{#1}% |
| 869 |
} |
| 870 |
% \end{macrocode} |
| 871 |
% \end{macro} |
| 872 |
% |
| 873 |
% \begin{macro}{\@trimbox}[5]{<box register>}{<tllx>}{<tlly>}{<turx>}{<tury>} |
| 874 |
% Removes the four length for the left, bottom, right and top from the official size of the box register. |
| 875 |
% \begin{macrocode} |
| 876 |
\def\@viewportbox#1#2#3#4#5{% |
| 877 |
\setbox#1=\hbox{% |
| 878 |
% |
| 879 |
% Assign values |
| 880 |
\tc@llx=#2\relax |
| 881 |
\tc@lly=#3\relax |
| 882 |
\tc@urx=#4\relax |
| 883 |
\tc@ury=#5\relax |
| 884 |
% |
| 885 |
% Set dimensions now. |
| 886 |
% This allows that the arguments can refer |
| 887 |
% to the original dimensions without issues. |
| 888 |
\hskip-\tc@llx |
| 889 |
\dp#1-\tc@lly |
| 890 |
\wd#1\tc@urx |
| 891 |
\ht#1\tc@ury |
| 892 |
% |
| 893 |
\tc@correctbaseline{#1}% |
| 894 |
}% |
| 895 |
\tc@correctdims{#1}% |
| 896 |
} |
| 897 |
% \end{macrocode} |
| 898 |
% \end{macro} |
| 899 |
% |
| 900 |
% |
| 901 |
% \begin{macro}{\@clipbox} |
| 902 |
% Clips the box using the given trim amounts. |
| 903 |
% For this the box is first trimmed and then clipped to its official size using a driver dependent macro. |
| 904 |
% \begin{macrocode} |
| 905 |
\def\@clipbox#1#2#3#4#5{% |
| 906 |
\@trimbox{#1}{#2}{#3}{#4}{#5}% |
| 907 |
\@cliptoboxdim{#1}% |
| 908 |
} |
| 909 |
% \end{macrocode} |
| 910 |
% \end{macro} |
| 911 |
% |
| 912 |
% |
| 913 |
% |
| 914 |
% \begin{macro}{\@clipvpbox} |
| 915 |
% Clips the box using the given trim amounts. |
| 916 |
% For this the box is first trimmed and then clipped to its official size using a driver dependent macro. |
| 917 |
% \begin{macrocode} |
| 918 |
\def\@clipvpbox#1#2#3#4#5{% |
| 919 |
\@viewportbox{#1}{#2}{#3}{#4}{#5}% |
| 920 |
\@cliptoboxdim{#1}% |
| 921 |
} |
| 922 |
% \end{macrocode} |
| 923 |
% \end{macro} |
| 924 |
% |
| 925 |
% |
| 926 |
% |
| 927 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 928 |
% \subsection{Driver loading} |
| 929 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 930 |
% The clipping support is output driver dependent. The driver selected by \pkg{graphics} is used and a definition file |
| 931 |
% is used if its exists. Otherwise either the default \texttt{pdftex} implementation or the \pkg{pgf} fall-back driver |
| 932 |
% is used. |
| 933 |
% |
| 934 |
% |
| 935 |
% |
| 936 |
% \begin{macro}{\tc@bezfacn} |
| 937 |
% The Bezier factor required to draw rounded corners in same drivers. |
| 938 |
% \begin{macrocode} |
| 939 |
\def\tc@bezfacn{0.44771525}% |
| 940 |
% \end{macrocode} |
| 941 |
% \end{macro} |
| 942 |
% |
| 943 |
% \begin{macrocode} |
| 944 |
\InputIfFileExists{\tc@driver}{% |
| 945 |
{\let\on@line\@gobble |
| 946 |
\PackageInfo{trimclip}{Using driver '\tc@driver'.}}% |
| 947 |
}{% |
| 948 |
\input{tc-pgf.def}% |
| 949 |
{\let\on@line\@gobble |
| 950 |
\PackageInfo{trimclip}{No clipping driver '\tc@driver' available.\MessageBreak Using fall-back PGF driver.}}% |
| 951 |
} |
| 952 |
% \end{macrocode} |
| 953 |
% |
| 954 |
% |
| 955 |
% \iffalse |
| 956 |
%</trimclip.sty> |
| 957 |
% \fi |
| 958 |
% |
| 959 |
% \subsection{Driver files} |
| 960 |
% |
| 961 |
% \subsubsection{PGF fall-back driver} |
| 962 |
% \iffalse |
| 963 |
%<*tc-pgf.def> |
| 964 |
% \fi |
| 965 |
% \begin{macrocode} |
| 966 |
%<!COPYRIGHT> |
| 967 |
\ProvidesFile{tc-pgf.def}[2019/01/04 v2.2 trimclip fall-back clipping driver using PGF] |
| 968 |
% \end{macrocode} |
| 969 |
% |
| 970 |
% \begin{macrocode} |
| 971 |
\RequirePackage{pgf} |
| 972 |
% \end{macrocode} |
| 973 |
% |
| 974 |
% \begin{macro}{\@cliptoboxdim} |
| 975 |
% Clips to official box dimension. |
| 976 |
% \begin{macrocode} |
| 977 |
\def\@cliptoboxdim#1{% |
| 978 |
\setbox#1\hbox{\begin{pgfpicture}% |
| 979 |
\pgfpathmoveto{\pgfqpoint\z@{-\dp#1}}% |
| 980 |
\pgfpathlineto{\pgfqpoint\z@{\ht#1}}% |
| 981 |
\pgfpathlineto{\pgfqpoint{\wd#1}{\ht#1}}% |
| 982 |
\pgfpathlineto{\pgfqpoint{\wd#1}{-\dp#1}}% |
| 983 |
\pgfpathclose |
| 984 |
\pgfusepathqclip |
| 985 |
\pgfset{inner sep=\z@,outer sep=\z@,minimum size=\z@}% |
| 986 |
\pgfnode{rectangle}{base west}{\usebox#1}{}{}% |
| 987 |
\pgfsetbaselinepointnow{\pgfpoint\z@\z@}% |
| 988 |
\end{pgfpicture}}% |
| 989 |
} |
| 990 |
% \end{macrocode} |
| 991 |
% \end{macro} |
| 992 |
% |
| 993 |
% |
| 994 |
% \begin{macro}{\@clipcornersofbox}[5]{<box register}{<upper left>}{<upper right>}{<lower left>}{<lower right>} |
| 995 |
% Clips round corners off. |
| 996 |
% \begin{macrocode} |
| 997 |
\def\@clipcornersofbox#1#2#3#4#5{% |
| 998 |
\setbox#1\hbox{\begin{pgfpicture}% |
| 999 |
\pgfpathmoveto{\pgfpoint{\z@}{\ht#1-#2}}% |
| 1000 |
\pgfpatharc{180}{90}{#2}% |
| 1001 |
\pgfpathlineto{\pgfpoint{\wd#1-#3}{\ht#1}}% |
| 1002 |
\pgfpatharc{90}{0}{#3}% |
| 1003 |
\pgfpathlineto{\pgfpoint{\wd#1}{#5-\dp#1}}% |
| 1004 |
\pgfpatharc{0}{-90}{#5}% |
| 1005 |
\pgfpathlineto{\pgfpoint{#4}{-\dp#1}}% |
| 1006 |
\pgfpatharc{270}{180}{#4}% |
| 1007 |
\pgfpathlineto{\pgfpoint{\z@}{\ht#1-#2}}% |
| 1008 |
\pgfpathclose |
| 1009 |
\pgfusepathqclip |
| 1010 |
\pgfset{inner sep=\z@,outer sep=\z@,minimum size=\z@}% |
| 1011 |
\pgfnode{rectangle}{base west}{\usebox#1}{}{}% |
| 1012 |
\pgfsetbaselinepointnow{\pgfpoint\z@\z@}% |
| 1013 |
\end{pgfpicture}}% |
| 1014 |
} |
| 1015 |
% \end{macrocode} |
| 1016 |
% \end{macro} |
| 1017 |
% |
| 1018 |
% |
| 1019 |
% \begin{macro}{\@rndframearoundbox}[6]{<box register}{<upper left>}{<upper right>}{<lower left>}{<lower right>}{<clip>} |
| 1020 |
% Round frame around a box. |
| 1021 |
% \begin{macrocode} |
| 1022 |
\def\@rndframearoundbox#1#2#3#4#5#6{% |
| 1023 |
\setbox#1\hbox{\begin{pgfpicture}% |
| 1024 |
\adjsetlength\@tempdima{\fboxsep+.5\fboxrule}% |
| 1025 |
\@marginbox#1\@tempdima\@tempdima\@tempdima\@tempdima% |
| 1026 |
\edef\@tempa{#6}% |
| 1027 |
\ifx\@empty\@tempa\else |
| 1028 |
\@clipcornersofbox{#1}{#2}{#3}{#4}{#5}% |
| 1029 |
\fi |
| 1030 |
\pgfset{inner sep=\z@,outer sep=\z@,minimum size=\z@}% |
| 1031 |
\pgfnode{rectangle}{base west}{\usebox#1}{}{}% |
| 1032 |
\pgfusepath{}% |
| 1033 |
\adjbox@rndframe@color |
| 1034 |
\pgfpathmoveto{\pgfpoint{\z@}{\ht#1-#2}}% |
| 1035 |
\pgfpatharc{180}{90}{#2}% |
| 1036 |
\pgfpathlineto{\pgfpoint{\wd#1-#3}{\ht#1}}% |
| 1037 |
\pgfpatharc{90}{0}{#3}% |
| 1038 |
\pgfpathlineto{\pgfpoint{\wd#1}{#5-\dp#1}}% |
| 1039 |
\pgfpatharc{0}{-90}{#5}% |
| 1040 |
\pgfpathlineto{\pgfpoint{#4}{-\dp#1}}% |
| 1041 |
\pgfpatharc{270}{180}{#4}% |
| 1042 |
\pgfpathlineto{\pgfpoint{\z@}{\ht#1-#2}}% |
| 1043 |
\pgfpathclose |
| 1044 |
\pgfusepath{stroke}% |
| 1045 |
\pgfsetbaselinepointnow{\pgfpoint\z@\z@}% |
| 1046 |
\end{pgfpicture}}% |
| 1047 |
} |
| 1048 |
% \end{macrocode} |
| 1049 |
% \end{macro} |
| 1050 |
% |
| 1051 |
%^^A vim: ft=tex |
| 1052 |
% \iffalse |
| 1053 |
%</tc-pgf.def> |
| 1054 |
% \fi |
| 1055 |
% |
| 1056 |
% \subsubsection{pdftex driver} |
| 1057 |
% \iffalse |
| 1058 |
%<*tc-pdftex.def> |
| 1059 |
% \fi |
| 1060 |
% \begin{macrocode} |
| 1061 |
%<!COPYRIGHT> |
| 1062 |
\ProvidesFile{tc-pdftex.def}[2025/02/26 v2.3 Clipping driver for pdftex] |
| 1063 |
% \end{macrocode} |
| 1064 |
% |
| 1065 |
% \begin{macrocode} |
| 1066 |
\@ifundefined{clip@pdfliteral}{\let\clip@pdfliteral\pdfliteral}{} |
| 1067 |
\@ifundefined{clip@pdfsave}{\let\clip@pdfsave\pdfsave}{} |
| 1068 |
\@ifundefined{clip@pdfrestore}{\let\clip@pdfrestore\pdfrestore}{} |
| 1069 |
% \end{macrocode} |
| 1070 |
% |
| 1071 |
% \begin{macro}{\@cliptoboxdim} |
| 1072 |
% Clips to official box dimension. |
| 1073 |
% |
| 1074 |
% Uses now \Macro\pdfliteral because \Macro\pdfxform does not support |
| 1075 |
% transparencies and patterns with TikZ. |
| 1076 |
% \begin{macrocode} |
| 1077 |
\def\@cliptoboxdim#1{% |
| 1078 |
\setbox#1=\hbox{% |
| 1079 |
\adjcalc@settobp\WIDTH{\wd#1}% |
| 1080 |
\adjcalc@settobp\DEPTH{\dp#1}% |
| 1081 |
\adjcalc@settobp\TOTALHEIGHT{\ht#1+\dp#1}% |
| 1082 |
\clip@pdfsave |
| 1083 |
\clip@pdfliteral direct {% |
| 1084 |
0 -\DEPTH\space \WIDTH\space \TOTALHEIGHT\space re W n |
| 1085 |
}% |
| 1086 |
\hbox to 0pt{\copy#1\hss}% |
| 1087 |
\clip@pdfrestore |
| 1088 |
\hskip\wd#1 |
| 1089 |
}% |
| 1090 |
} |
| 1091 |
% \end{macrocode} |
| 1092 |
% \end{macro} |
| 1093 |
% |
| 1094 |
% |
| 1095 |
% \begin{macro}{\@clip@bpdimens}[5]{<box register}{<upper left>}{<upper right>}{<lower left>}{<lower right>} |
| 1096 |
% \begin{macrocode} |
| 1097 |
\def\@clip@bpdimens#1#2#3#4#5{% |
| 1098 |
\adjcalc@settobp\TOTALHEIGHT{\ht#1+\dp#1}% |
| 1099 |
\adjcalc@settobp\HEIGHT{\ht#1}% |
| 1100 |
\adjcalc@settobp\DEPTH{-\dp#1}% |
| 1101 |
\adjcalc@settobp\WIDTH{\wd#1}% |
| 1102 |
\adjcalc@settobp\RADIUSTL{#2}% |
| 1103 |
\adjcalc@settobp\RADIUSTR{#3}% |
| 1104 |
\adjcalc@settobp\RADIUSBR{#5}% |
| 1105 |
\adjcalc@settobp\RADIUSBL{#4}% |
| 1106 |
\adjcalc@settobp\RADIUSTLb{\tc@bezfacn#2}% |
| 1107 |
\adjcalc@settobp\HEIGHTmRADIUSTL{\ht#1-#2}% |
| 1108 |
\adjcalc@settobp\HEIGHTmRADIUSTLb{\ht#1-\tc@bezfacn#2}% |
| 1109 |
\adjcalc@settobp\HEIGHTmRADIUSTR{\ht#1-#3}% |
| 1110 |
\adjcalc@settobp\HEIGHTmRADIUSTRb{\ht#1-\tc@bezfacn#3}% |
| 1111 |
\adjcalc@settobp\WIDTHmRADIUSTR{\wd#1-#3}% |
| 1112 |
\adjcalc@settobp\WIDTHmRADIUSTRb{\wd#1-\tc@bezfacn#3}% |
| 1113 |
\adjcalc@settobp\RADIUSBRmDEPTH{#5-\dp#1}% |
| 1114 |
\adjcalc@settobp\RADIUSBRmDEPTHb{\tc@bezfacn#5-\dp#1}% |
| 1115 |
\adjcalc@settobp\WIDTHmRADIUSBR{\wd#1-#5}% |
| 1116 |
\adjcalc@settobp\WIDTHmRADIUSBRb{\wd#1-\tc@bezfacn#5}% |
| 1117 |
\adjcalc@settobp\RADIUSBLmDEPTH{#4-\dp#1}% |
| 1118 |
\adjcalc@settobp\RADIUSBLmDEPTHb{\tc@bezfacn#4-\dp#1}% |
| 1119 |
\adjcalc@settobp\RADIUSBLb{\tc@bezfacn#4}% |
| 1120 |
\adjcalc@settobp\LINEWIDTH{\fboxrule}% |
| 1121 |
} |
| 1122 |
% \end{macrocode} |
| 1123 |
% \end{macro} |
| 1124 |
% |
| 1125 |
% |
| 1126 |
% \begin{macro}{\@clip@roundedbox@pdfcode} |
| 1127 |
% \begin{macrocode} |
| 1128 |
\def\@clip@roundedboxpath@pdfcode{% |
| 1129 |
0 \HEIGHTmRADIUSTL m |
| 1130 |
0 \HEIGHTmRADIUSTLb \RADIUSTLb \HEIGHT \RADIUSTL \HEIGHT c |
| 1131 |
\WIDTHmRADIUSTR \HEIGHT l |
| 1132 |
\WIDTHmRADIUSTRb \HEIGHT \WIDTH \HEIGHTmRADIUSTRb \WIDTH \HEIGHTmRADIUSTR c |
| 1133 |
\WIDTH \RADIUSBRmDEPTH l |
| 1134 |
\WIDTH \RADIUSBRmDEPTHb \WIDTHmRADIUSBRb \DEPTH \WIDTHmRADIUSBR \DEPTH c |
| 1135 |
\RADIUSBL \DEPTH l |
| 1136 |
\RADIUSBLb \DEPTH 0 \RADIUSBLmDEPTHb 0 \RADIUSBLmDEPTH c |
| 1137 |
0 \RADIUSBLmDEPTH l |
| 1138 |
} |
| 1139 |
% \end{macrocode} |
| 1140 |
% \end{macro} |
| 1141 |
% |
| 1142 |
% |
| 1143 |
% |
| 1144 |
% \begin{macro}{\@clipcornersofbox}[5]{<box register}{<upper left>}{<upper right>}{<lower left>}{<lower right>} |
| 1145 |
% Clips round corners off. |
| 1146 |
% \begin{macrocode} |
| 1147 |
\def\@clipcornersofbox#1#2#3#4#5{% |
| 1148 |
\setbox#1=\hbox{% |
| 1149 |
\@clip@bpdimens{#1}{#2}{#3}{#4}{#5}% |
| 1150 |
\clip@pdfsave |
| 1151 |
\clip@pdfliteral direct {% |
| 1152 |
\@clip@roundedboxpath@pdfcode |
| 1153 |
h W n |
| 1154 |
}% |
| 1155 |
\hbox to 0pt{\copy#1\hss}% |
| 1156 |
\clip@pdfrestore |
| 1157 |
\hskip\wd#1% |
| 1158 |
}% |
| 1159 |
} |
| 1160 |
% \end{macrocode} |
| 1161 |
% \end{macro} |
| 1162 |
% |
| 1163 |
% |
| 1164 |
% |
| 1165 |
% \begin{macro}{\@rndframearoundbox}[6]{<box register}{<upper left>}{<upper right>}{<lower left>}{<lower right>}{<clip>} |
| 1166 |
% Round frame around a box. |
| 1167 |
% \begin{macrocode} |
| 1168 |
\def\@rndframearoundbox#1#2#3#4#5#6{% |
| 1169 |
\setbox#1=\hbox{% |
| 1170 |
\adjsetlength\@tempdima{\fboxsep+.5\fboxrule}% |
| 1171 |
\@marginbox#1\@tempdima\@tempdima\@tempdima\@tempdima% |
| 1172 |
\@clip@bpdimens{#1}{#2}{#3}{#4}{#5}% |
| 1173 |
\edef\@tempa{#6}% |
| 1174 |
\ifx\@empty\@tempa\else |
| 1175 |
\@clipcornersofbox{#1}{#2}{#3}{#4}{#5}% |
| 1176 |
\fi |
| 1177 |
% |
| 1178 |
\hbox to 0pt{\copy#1\hss}% |
| 1179 |
\clip@pdfsave |
| 1180 |
\hbox to 0pt{% |
| 1181 |
\color@setgroup |
| 1182 |
\adjbox@rndframe@color |
| 1183 |
\clip@pdfliteral direct {% |
| 1184 |
\LINEWIDTH w |
| 1185 |
\@clip@roundedboxpath@pdfcode |
| 1186 |
h s |
| 1187 |
}% |
| 1188 |
\color@endgroup |
| 1189 |
}% |
| 1190 |
\clip@pdfrestore |
| 1191 |
\hskip\wd#1% |
| 1192 |
}% |
| 1193 |
\adjsetlength\@tempdima{.5\fboxrule}% |
| 1194 |
\@marginbox#1\@tempdima\@tempdima\@tempdima\@tempdima% |
| 1195 |
} |
| 1196 |
% \end{macrocode} |
| 1197 |
% \end{macro} |
| 1198 |
% |
| 1199 |
% |
| 1200 |
%^^A vim: ft=tex |
| 1201 |
% \iffalse |
| 1202 |
%</tc-pdftex.def> |
| 1203 |
% \fi |
| 1204 |
% |
| 1205 |
% \subsubsection{luatex driver} |
| 1206 |
% \iffalse |
| 1207 |
%<*tc-luatex.def> |
| 1208 |
% \fi |
| 1209 |
% \begin{macrocode} |
| 1210 |
%<!COPYRIGHT> |
| 1211 |
\ProvidesFile{tc-luatex.def}[2025/02/26 v1.1 Clipping driver for luatex] |
| 1212 |
\protected\def\clip@pdfliteral{\pdfextension literal} |
| 1213 |
\protected\def\clip@pdfsave{\pdfextension save\relax} |
| 1214 |
\protected\def\clip@pdfrestore{\pdfextension restore\relax} |
| 1215 |
\input{tc-pdftex.def} |
| 1216 |
% \end{macrocode} |
| 1217 |
% |
| 1218 |
% \iffalse |
| 1219 |
%</tc-luatex.def> |
| 1220 |
% \fi |
| 1221 |
% |
| 1222 |
% \subsubsection{dvips driver} |
| 1223 |
% \iffalse |
| 1224 |
%<*tc-dvips.def> |
| 1225 |
% \fi |
| 1226 |
% \begin{macrocode} |
| 1227 |
%<!COPYRIGHT> |
| 1228 |
\ProvidesFile{tc-dvips.def}[2019/01/04 v2.2 Clipping driver for dvips] |
| 1229 |
% \end{macrocode} |
| 1230 |
% |
| 1231 |
% \begin{macro}{\@cliptoboxdim}[1]{box register to clip} |
| 1232 |
% Clips to official box dimension. |
| 1233 |
% |
| 1234 |
% The following clipping code was suggested by |
| 1235 |
% Joseph Wright (LaTeX3 project), but slightly modified |
| 1236 |
% for this package. |
| 1237 |
% \begin{macrocode} |
| 1238 |
\def\@cliptoboxdim#1{% |
| 1239 |
\setbox#1=\hbox{% |
| 1240 |
\adjcalc@settobp\WIDTH{\wd#1}% |
| 1241 |
\adjcalc@settobp\DEPTH{\dp#1}% |
| 1242 |
\adjcalc@settobp\TOTALHEIGHT{-\ht#1-\dp#1}% |
| 1243 |
\special{% |
| 1244 |
ps: |
| 1245 |
/mtrxc matrix currentmatrix def |
| 1246 |
currentpoint gsave |
| 1247 |
translate |
| 1248 |
Resolution 72 div VResolution 72 div |
| 1249 |
scale |
| 1250 |
newpath |
| 1251 |
0 \DEPTH \WIDTH \TOTALHEIGHT rectclip |
| 1252 |
newpath |
| 1253 |
mtrxc setmatrix |
| 1254 |
}% |
| 1255 |
\hbox to 0pt{\copy#1\hss}% |
| 1256 |
\special{ps: grestore }% |
| 1257 |
\hskip\wd#1% |
| 1258 |
}% |
| 1259 |
} |
| 1260 |
% |
| 1261 |
% \end{macrocode} |
| 1262 |
% \end{macro} |
| 1263 |
% |
| 1264 |
% |
| 1265 |
% \begin{macro}{\@clipcornersofbox}[5]{<box register}{<upper left>}{<upper right>}{<lower left>}{<lower right>} |
| 1266 |
% Clips round corners off. |
| 1267 |
% \begin{macrocode} |
| 1268 |
\def\@clipcornersofbox#1#2#3#4#5{% |
| 1269 |
\setbox#1=\hbox{% |
| 1270 |
\adjcalc@settobp\DEPTHmRADIUSBL\@tempdima |
| 1271 |
\adjcalc@settobp\TOTALHEIGHT{-\ht#1-\dp#1}% |
| 1272 |
\adjcalc@settobp\HEIGHT{-\ht#1}% |
| 1273 |
\adjcalc@settobp\DEPTH{\dp#1}% |
| 1274 |
\adjcalc@settobp\WIDTH{\wd#1}% |
| 1275 |
\adjcalc@settobp\RADIUSTL{#2}% |
| 1276 |
\adjcalc@settobp\RADIUSTR{#3}% |
| 1277 |
\adjcalc@settobp\RADIUSBL{#4}% |
| 1278 |
\adjcalc@settobp\RADIUSBR{#5}% |
| 1279 |
\adjcalc@settobp\RADIUSTLmHEIGHT{#2-\ht#1}% |
| 1280 |
\adjcalc@settobp\RADIUSTRmHEIGHT{#3-\ht#1}% |
| 1281 |
\adjcalc@settobp\WIDTHmRADIUSTR{\wd#1-#3}% |
| 1282 |
\adjcalc@settobp\DEPTHmRADIUSBR{\dp#1-#5}% |
| 1283 |
\adjcalc@settobp\WIDTHmRADIUSBR{\wd#1-#5}% |
| 1284 |
\adjcalc@settobp\DEPTHmRADIUSBL{\dp#1-#4}% |
| 1285 |
\special{% |
| 1286 |
ps: |
| 1287 |
/mtrxc matrix currentmatrix def |
| 1288 |
currentpoint gsave |
| 1289 |
translate |
| 1290 |
Resolution 72 div VResolution 72 div |
| 1291 |
scale |
| 1292 |
newpath |
| 1293 |
%0 \DEPTH neg translate |
| 1294 |
%0 \DEPTH \WIDTH \TOTALHEIGHT rectclip |
| 1295 |
0 \RADIUSTLmHEIGHT\space moveto |
| 1296 |
\RADIUSTL\space \RADIUSTLmHEIGHT\space \RADIUSTL\space 180 -90 arc |
| 1297 |
\WIDTHmRADIUSTR\space \HEIGHT\space lineto |
| 1298 |
\WIDTHmRADIUSTR\space \RADIUSTRmHEIGHT\space \RADIUSTR\space -90 0 arc |
| 1299 |
\WIDTH\space \DEPTHmRADIUSBR\space lineto |
| 1300 |
\WIDTHmRADIUSBR\space \DEPTHmRADIUSBR\space \RADIUSBR\space 0 90 arc |
| 1301 |
\RADIUSBL\space \DEPTH\space lineto |
| 1302 |
\RADIUSBL\space \DEPTHmRADIUSBL\space \RADIUSBL\space -270 -180 arc |
| 1303 |
closepath |
| 1304 |
%gsave 0.5 0 0 setrgbcolor stroke grestore |
| 1305 |
clip |
| 1306 |
newpath |
| 1307 |
mtrxc setmatrix |
| 1308 |
}% |
| 1309 |
\hbox to 0pt{\copy#1\hss}% |
| 1310 |
\special{ps: grestore }% |
| 1311 |
\hskip \wd#1% |
| 1312 |
}% |
| 1313 |
} |
| 1314 |
% \end{macrocode} |
| 1315 |
% \end{macro} |
| 1316 |
% |
| 1317 |
% |
| 1318 |
% |
| 1319 |
% \begin{macro}{\@rndframearoundbox}[6]{<box register}{<upper left>}{<upper right>}{<lower left>}{<lower right>}{<clip>} |
| 1320 |
% Clips round corners off. |
| 1321 |
% \begin{macrocode} |
| 1322 |
\def\@rndframearoundbox#1#2#3#4#5#6{% |
| 1323 |
\setbox#1=\hbox{% |
| 1324 |
\adjsetlength\@tempdima{\fboxsep+.5\fboxrule}% |
| 1325 |
\@marginbox#1\@tempdima\@tempdima\@tempdima\@tempdima% |
| 1326 |
\adjcalc@settobp\TOTALHEIGHT{-\ht#1-\dp#1}% |
| 1327 |
\adjcalc@settobp\HEIGHT{-\ht#1}% |
| 1328 |
\adjcalc@settobp\DEPTH{\dp#1}% |
| 1329 |
\adjcalc@settobp\WIDTH{\wd#1}% |
| 1330 |
\adjcalc@settobp\RADIUSTL{#2}% |
| 1331 |
\adjcalc@settobp\RADIUSTR{#3}% |
| 1332 |
\adjcalc@settobp\RADIUSBR{#5}% |
| 1333 |
\adjcalc@settobp\RADIUSBL{#4}% |
| 1334 |
\adjcalc@settobp\RADIUSTLmHEIGHT{#2-\ht#1}% |
| 1335 |
\adjcalc@settobp\RADIUSTRmHEIGHT{#3-\ht#1}% |
| 1336 |
\adjcalc@settobp\WIDTHmRADIUSTR{\wd#1-#3}% |
| 1337 |
\adjcalc@settobp\DEPTHmRADIUSBR{\dp#1-#5}% |
| 1338 |
\adjcalc@settobp\WIDTHmRADIUSBR{\wd#1-#5}% |
| 1339 |
\adjcalc@settobp\DEPTHmRADIUSBL{\dp#1-#4}% |
| 1340 |
\adjcalc@settobp\LINEWIDTH{\fboxrule}% |
| 1341 |
\edef\@tempa{#6}% |
| 1342 |
\ifx\@empty\@tempa\else |
| 1343 |
\@clipcornersofbox{#1}{#2}{#3}{#4}{#5}% |
| 1344 |
\fi |
| 1345 |
% |
| 1346 |
\hbox to 0pt{\copy#1\hss}% |
| 1347 |
\hbox to 0pt{% |
| 1348 |
\color@setgroup |
| 1349 |
\adjbox@rndframe@color |
| 1350 |
\special{% |
| 1351 |
ps: |
| 1352 |
/mtrxc matrix currentmatrix def |
| 1353 |
currentpoint gsave |
| 1354 |
translate |
| 1355 |
Resolution 72 div VResolution 72 div |
| 1356 |
scale |
| 1357 |
newpath |
| 1358 |
%0 \DEPTH neg translate |
| 1359 |
%0 \DEPTH \WIDTH \TOTALHEIGHT rectclip |
| 1360 |
0 \RADIUSTLmHEIGHT moveto |
| 1361 |
\RADIUSTL \RADIUSTLmHEIGHT \RADIUSTL 180 -90 arc |
| 1362 |
\WIDTHmRADIUSTR \HEIGHT lineto |
| 1363 |
\WIDTHmRADIUSTR \RADIUSTRmHEIGHT \RADIUSTR -90 0 arc |
| 1364 |
\WIDTH \DEPTHmRADIUSBR lineto |
| 1365 |
\WIDTHmRADIUSBR \DEPTHmRADIUSBR \RADIUSBR 0 90 arc |
| 1366 |
\RADIUSBL \DEPTH lineto |
| 1367 |
\RADIUSBL \DEPTHmRADIUSBL \RADIUSBL -270 -180 arc |
| 1368 |
closepath |
| 1369 |
\LINEWIDTH setlinewidth |
| 1370 |
stroke |
| 1371 |
newpath |
| 1372 |
mtrxc setmatrix |
| 1373 |
grestore |
| 1374 |
}% |
| 1375 |
\color@endgroup |
| 1376 |
}% |
| 1377 |
\hskip \wd#1% |
| 1378 |
}% |
| 1379 |
\adjsetlength\@tempdima{.5\fboxrule}% |
| 1380 |
\@marginbox#1\@tempdima\@tempdima\@tempdima\@tempdima% |
| 1381 |
} |
| 1382 |
% \end{macrocode} |
| 1383 |
% \end{macro} |
| 1384 |
% |
| 1385 |
%^^A vim: ft=tex |
| 1386 |
% \iffalse |
| 1387 |
%</tc-dvips.def> |
| 1388 |
% \fi |
| 1389 |
% |
| 1390 |
% \subsubsection{xetex driver} |
| 1391 |
% \iffalse |
| 1392 |
%<*tc-xetex.def> |
| 1393 |
% \fi |
| 1394 |
% \begin{macrocode} |
| 1395 |
%<!COPYRIGHT> |
| 1396 |
\ProvidesFile{tc-xetex.def}[2019/01/04 v2.2 Clipping driver for xetex] |
| 1397 |
% \end{macrocode} |
| 1398 |
% |
| 1399 |
% \begin{macro}{\@cliptoboxdim} |
| 1400 |
% Clips to official box dimension. |
| 1401 |
% |
| 1402 |
% The following clipping code was suggested by |
| 1403 |
% Joseph Wright (LaTeX3 project), but slightly modified |
| 1404 |
% for this package. |
| 1405 |
% \begin{macrocode} |
| 1406 |
\def\@cliptoboxdim#1{% |
| 1407 |
\setbox#1=\hbox{% |
| 1408 |
\adjcalc@settobp\WIDTH{\wd#1}% |
| 1409 |
\adjcalc@settobp\DEPTH{\dp#1}% |
| 1410 |
\adjcalc@settobp\TOTALHEIGHT{\ht#1+\dp#1}% |
| 1411 |
\special{pdf:content q }% |
| 1412 |
\special{pdf:code 0 -\DEPTH \WIDTH \TOTALHEIGHT re W n }% |
| 1413 |
\special{pdf:literal direct -1 0 0 -1 0 0 cm }% |
| 1414 |
\special{pdf:content q }% |
| 1415 |
\special{pdf:literal direct -1 0 0 -1 0 0 cm }% |
| 1416 |
\hbox to 0 pt{\copy#1\hss}% |
| 1417 |
\special{pdf:literal direct Q }% |
| 1418 |
\special{pdf:literal direct Q }% |
| 1419 |
\hskip\wd#1% |
| 1420 |
}% |
| 1421 |
} |
| 1422 |
% \end{macrocode} |
| 1423 |
% \end{macro} |
| 1424 |
% |
| 1425 |
% |
| 1426 |
% \begin{macro}{\@clip@bpdimens}[5]{<box register}{<upper left>}{<upper right>}{<lower left>}{<lower right>} |
| 1427 |
% \begin{macrocode} |
| 1428 |
\def\@clip@bpdimens#1#2#3#4#5{% |
| 1429 |
\adjcalc@settobp\TOTALHEIGHT{\ht#1+\dp#1}% |
| 1430 |
\adjcalc@settobp\HEIGHT{\ht#1}% |
| 1431 |
\adjcalc@settobp\DEPTH{-\dp#1}% |
| 1432 |
\adjcalc@settobp\WIDTH{\wd#1}% |
| 1433 |
\adjcalc@settobp\RADIUSTL{#2}% |
| 1434 |
\adjcalc@settobp\RADIUSTR{#3}% |
| 1435 |
\adjcalc@settobp\RADIUSBL{#4}% |
| 1436 |
\adjcalc@settobp\RADIUSBR{#5}% |
| 1437 |
\adjcalc@settobp\RADIUSTLb{\tc@bezfacn#2}% |
| 1438 |
\adjcalc@settobp\HEIGHTmRADIUSTL{\ht#1-#2}% |
| 1439 |
\adjcalc@settobp\HEIGHTmRADIUSTLb{\ht#1-\tc@bezfacn#2}% |
| 1440 |
\adjcalc@settobp\HEIGHTmRADIUSTR{\ht#1-#3}% |
| 1441 |
\adjcalc@settobp\HEIGHTmRADIUSTRb{\ht#1-\tc@bezfacn#3}% |
| 1442 |
\adjcalc@settobp\WIDTHmRADIUSTR{\wd#1-#3}% |
| 1443 |
\adjcalc@settobp\WIDTHmRADIUSTRb{\wd#1-\tc@bezfacn#3}% |
| 1444 |
\adjcalc@settobp\RADIUSBRmDEPTH{#5-\dp#1}% |
| 1445 |
\adjcalc@settobp\RADIUSBRmDEPTHb{\tc@bezfacn#5-\dp#1}% |
| 1446 |
\adjcalc@settobp\WIDTHmRADIUSBR{\wd#1-#5}% |
| 1447 |
\adjcalc@settobp\WIDTHmRADIUSBRb{\wd#1-\tc@bezfacn#5}% |
| 1448 |
\adjcalc@settobp\RADIUSBLmDEPTH{#4-\dp#1}% |
| 1449 |
\adjcalc@settobp\RADIUSBLmDEPTHb{\tc@bezfacn#4-\dp#1}% |
| 1450 |
\adjcalc@settobp\RADIUSBLb{\tc@bezfacn#4}% |
| 1451 |
\adjcalc@settobp\LINEWIDTH{\fboxrule}% |
| 1452 |
} |
| 1453 |
% \end{macrocode} |
| 1454 |
% \end{macro} |
| 1455 |
% |
| 1456 |
% |
| 1457 |
% \begin{macro}{\@clip@roundedbox@pdfcode} |
| 1458 |
% \begin{macrocode} |
| 1459 |
\def\@clip@roundedboxpath@pdfcode{% |
| 1460 |
0 \HEIGHTmRADIUSTL m |
| 1461 |
0 \HEIGHTmRADIUSTLb \RADIUSTLb \HEIGHT \RADIUSTL \HEIGHT c |
| 1462 |
\WIDTHmRADIUSTR \HEIGHT l |
| 1463 |
\WIDTHmRADIUSTRb \HEIGHT \WIDTH \HEIGHTmRADIUSTRb \WIDTH \HEIGHTmRADIUSTR c |
| 1464 |
\WIDTH \RADIUSBRmDEPTH l |
| 1465 |
\WIDTH \RADIUSBRmDEPTHb \WIDTHmRADIUSBRb \DEPTH \WIDTHmRADIUSBR \DEPTH c |
| 1466 |
\RADIUSBL \DEPTH l |
| 1467 |
\RADIUSBLb \DEPTH 0 \RADIUSBLmDEPTHb 0 \RADIUSBLmDEPTH c |
| 1468 |
0 \RADIUSBLmDEPTH l |
| 1469 |
} |
| 1470 |
% \end{macrocode} |
| 1471 |
% \end{macro} |
| 1472 |
% |
| 1473 |
% |
| 1474 |
% |
| 1475 |
% \begin{macro}{\@clipcornersofbox}[5]{<box register}{<upper left>}{<upper right>}{<lower left>}{<lower right>} |
| 1476 |
% Clips round corners off. |
| 1477 |
% \begin{macrocode} |
| 1478 |
\def\@clipcornersofbox#1#2#3#4#5{% |
| 1479 |
\setbox#1=\hbox{% |
| 1480 |
\@clip@bpdimens{#1}{#2}{#3}{#4}{#5}% |
| 1481 |
\special{pdf:content q }% |
| 1482 |
\special{pdf:literal direct |
| 1483 |
\@clip@roundedboxpath@pdfcode |
| 1484 |
h W n |
| 1485 |
}% |
| 1486 |
\special{pdf:literal direct -1 0 0 -1 0 0 cm }% |
| 1487 |
\special{pdf:content q }% |
| 1488 |
\special{pdf:literal direct -1 0 0 -1 0 0 cm }% |
| 1489 |
\hbox to 0pt{\copy#1\hss}% |
| 1490 |
\special{pdf:literal direct Q }% |
| 1491 |
\special{pdf:literal direct Q }% |
| 1492 |
\hskip\wd#1% |
| 1493 |
}% |
| 1494 |
} |
| 1495 |
% \end{macrocode} |
| 1496 |
% \end{macro} |
| 1497 |
% |
| 1498 |
% |
| 1499 |
% |
| 1500 |
% \begin{macro}{\@rndframearoundbox}[6]{<box register}{<upper left>}{<upper right>}{<lower left>}{<lower right>}{<clip>} |
| 1501 |
% Round frame around a box. |
| 1502 |
% \begin{macrocode} |
| 1503 |
\def\@rndframearoundbox#1#2#3#4#5#6{% |
| 1504 |
\setbox#1=\hbox{% |
| 1505 |
\adjsetlength\@tempdima{\fboxsep+.5\fboxrule}% |
| 1506 |
\@marginbox#1\@tempdima\@tempdima\@tempdima\@tempdima% |
| 1507 |
\@clip@bpdimens{#1}{#2}{#3}{#4}{#5}% |
| 1508 |
\edef\@tempa{#6}% |
| 1509 |
\ifx\@empty\@tempa\else |
| 1510 |
\@clipcornersofbox{#1}{#2}{#3}{#4}{#5}% |
| 1511 |
\fi |
| 1512 |
% |
| 1513 |
\hbox to 0pt{\copy#1\hss}% |
| 1514 |
\hbox to 0pt{% |
| 1515 |
\color@setgroup |
| 1516 |
\adjbox@rndframe@color |
| 1517 |
\special{pdf:content q }% |
| 1518 |
\special{pdf:literal direct |
| 1519 |
\LINEWIDTH w |
| 1520 |
\@clip@roundedboxpath@pdfcode |
| 1521 |
h s |
| 1522 |
}% |
| 1523 |
\special{pdf:literal direct -1 0 0 -1 0 0 cm }% |
| 1524 |
\special{pdf:content q }% |
| 1525 |
\special{pdf:literal direct -1 0 0 -1 0 0 cm }% |
| 1526 |
\special{pdf:literal direct Q }% |
| 1527 |
\special{pdf:literal direct Q }% |
| 1528 |
\color@endgroup |
| 1529 |
}% |
| 1530 |
\hskip\wd#1% |
| 1531 |
}% |
| 1532 |
\adjsetlength\@tempdima{.5\fboxrule}% |
| 1533 |
\@marginbox#1\@tempdima\@tempdima\@tempdima\@tempdima% |
| 1534 |
} |
| 1535 |
% \end{macrocode} |
| 1536 |
% \end{macro} |
| 1537 |
% |
| 1538 |
%^^A vim: ft=tex |
| 1539 |
% \iffalse |
| 1540 |
%</tc-xetex.def> |
| 1541 |
% \fi |
| 1542 |
% |
| 1543 |
% \Finale |
| 1544 |
% \endinput |
| 1545 |
% |
| 1546 |
% ^^A Standalone figures: |
| 1547 |
% |
| 1548 |
% \iffalse |
| 1549 |
%<*box.tex> |
| 1550 |
% \fi |
| 1551 |
%<*standalone> |
| 1552 |
\documentclass{standalone} |
| 1553 |
|
| 1554 |
\usepackage{tikz} |
| 1555 |
\usetikzlibrary{calc} |
| 1556 |
\newsavebox\mybox |
| 1557 |
|
| 1558 |
\begin{document} |
| 1559 |
%</standalone> |
| 1560 |
% Diagram of the TeX box model and its dimensions |
| 1561 |
% Copyright (C) 2001 by Martin Scharrer <[email protected]>, Nov 12th 2011 |
| 1562 |
% This is free code under the LPPL v1.3 or later version OR the CC BY-SA 3.0 |
| 1563 |
\begin{tikzpicture}[font=\sffamily,>=latex] |
| 1564 |
\newcommand\Cs[1]{\texttt{\scriptsize\textbackslash #1}} |
| 1565 |
% Save example text in box |
| 1566 |
\sbox\mybox{\pgfinterruptpicture\sffamily\color{black!25}\scalebox{10}{Xy}\endpgfinterruptpicture} |
| 1567 |
\def\HEIGHT{\ht\mybox} |
| 1568 |
\def\WIDTH{\wd\mybox} |
| 1569 |
\def\DEPTH{\dp\mybox} |
| 1570 |
% Extensions lines for dimensions (drawn here to be below other material) |
| 1571 |
\draw [gray,thin] |
| 1572 |
(0,0) -- +(-3.5ex,0) |
| 1573 |
(0,\HEIGHT) -- +(-3.5ex,0) |
| 1574 |
(0,-\DEPTH) -- +(-3.5ex,0) |
| 1575 |
(\WIDTH,\HEIGHT) -- +(3.5ex,0) |
| 1576 |
(\WIDTH,-\DEPTH) -- +(3.5ex,0) |
| 1577 |
(0,-\DEPTH) -- +(0,-3.5ex) |
| 1578 |
(\WIDTH,-\DEPTH) -- +(0,-3.5ex) |
| 1579 |
; |
| 1580 |
% Text node: |
| 1581 |
\node [inner sep=0pt,anchor=base west] {\usebox\mybox}; |
| 1582 |
% Baseline |
| 1583 |
\draw (0,0) -- (\WIDTH,0) node [above,midway] {baseline}; |
| 1584 |
% Box |
| 1585 |
\draw [thick] (0,-\DEPTH) rectangle (\WIDTH,\HEIGHT); |
| 1586 |
% Origin |
| 1587 |
\path [fill=white,draw=black] (0,0) circle (1pt); |
| 1588 |
\draw [<-,shorten <=2pt] (0,0) -- (2ex,-2ex) -- +(.5ex,0) node [right=-0.5ex] {origin}; |
| 1589 |
% Dimensions |
| 1590 |
\tikzset{inner sep=5pt} |
| 1591 |
\draw [->] (-2.5ex,0) -- +(0,-\DEPTH) node [pos=1.1,left,align=left] |
| 1592 |
{depth\\\Cs{depth}\\\Cs{dp}\Cs{br}}; |
| 1593 |
\draw [->] (-2.5ex,0) -- +(0, \HEIGHT) node [pos=.4,left,align=left] |
| 1594 |
{height\\\Cs{height}\\\Cs{ht}\Cs{br}}; |
| 1595 |
\draw [<->] (\WIDTH,-\DEPTH) ++(2.5ex,0) -- +(0,\DEPTH+\HEIGHT) node [midway,right,align=left] |
| 1596 |
{totalheight\\\Cs{totalheight}}; |
| 1597 |
\draw [<->] (0,-\DEPTH) ++(0,-2.5ex) -- +(\WIDTH,0) node [midway,below,align=left] |
| 1598 |
{width\\\Cs{width}\\\Cs{wd}\Cs{br}}; |
| 1599 |
\fill (-2.5ex,0) circle (.5pt); |
| 1600 |
% Center inner box |
| 1601 |
\path let |
| 1602 |
\p1 = (current bounding box.south west), |
| 1603 |
\p2 = (current bounding box.north east), |
| 1604 |
\p3 = (0,-\DEPTH), |
| 1605 |
\p4 = (\WIDTH,\HEIGHT) |
| 1606 |
in |
| 1607 |
(\x3-\x2+\x4,\y3) rectangle (\x4+\x3-\x1,\y4); |
| 1608 |
\end{tikzpicture} |
| 1609 |
%<*standalone> |
| 1610 |
\end{document} |
| 1611 |
%</standalone> |
| 1612 |
% \iffalse |
| 1613 |
%</box.tex> |
| 1614 |
% \fi |
| 1615 |
% |
| 1616 |
% \iffalse |
| 1617 |
%<*compare.tex> |
| 1618 |
% \fi |
| 1619 |
\documentclass{article} |
| 1620 |
\usepackage[margin=1cm,paperwidth=20cm,paperheight=100cm]{geometry} |
| 1621 |
\usepackage[]{xcolor} |
| 1622 |
\usepackage[export]{adjustbox} |
| 1623 |
%\listfiles |
| 1624 |
\fboxsep=0pt |
| 1625 |
\parskip=1cm |
| 1626 |
|
| 1627 |
\usepackage[tightpage]{preview} |
| 1628 |
|
| 1629 |
\usepackage{standalone} |
| 1630 |
\usepackage[T1]{fontenc} |
| 1631 |
\usepackage{lmodern} |
| 1632 |
\usepackage{tikz} |
| 1633 |
\newdimen\unit |
| 1634 |
\tikzset{unit/.code={\unit=\dimexpr#1\relax}} |
| 1635 |
\tikzset{xy/.style={x={#1},y={#1},unit={#1},font={\sffamily\fontsize{.2\unit}{.24\unit}\selectfont},line width=.01\unit}} |
| 1636 |
|
| 1637 |
\def\showdiff#1{% |
| 1638 |
{% |
| 1639 |
\diff=\dimexpr#10-#11\relax |
| 1640 |
\pgfmathsetlength\absdiff{abs(\diff)}% |
| 1641 |
\ifdim\diff=0pt% |
| 1642 |
\textcolor{green}{PASSED}% |
| 1643 |
\else |
| 1644 |
\ifdim\absdiff<\Epsilon |
| 1645 |
\pgfmathtruncatemacro\FCOLOR{100*(\Epsilon-abs(\absdiff))/\Epsilon}% |
| 1646 |
\textcolor{green!\FCOLOR!yellow}{OK: \the\diff}% |
| 1647 |
\else |
| 1648 |
\textcolor{red}{FAILED: \the\diff}% |
| 1649 |
\fi |
| 1650 |
\fi |
| 1651 |
\quad |
| 1652 |
\ifdim#11=0pt |
| 1653 |
\diff=#10 |
| 1654 |
\else |
| 1655 |
\pgfmathsetlength\diff{(#10/#11) - 1pt} |
| 1656 |
\fi |
| 1657 |
\ifdim\diff<0pt |
| 1658 |
\absdiff=-\diff |
| 1659 |
\else |
| 1660 |
\absdiff=\diff |
| 1661 |
\fi |
| 1662 |
\ifdim\diff=0pt% |
| 1663 |
\textcolor{green}{PASSED}% |
| 1664 |
\else |
| 1665 |
\ifdim\absdiff<\dEpsilon |
| 1666 |
\pgfmathtruncatemacro\FCOLOR{100*(\dEpsilon-abs(\absdiff))/\dEpsilon}% |
| 1667 |
\textcolor{green!\FCOLOR!yellow}{OK: \the\diff}% |
| 1668 |
\else |
| 1669 |
\textcolor{red}{FAILED: \the\diff}% |
| 1670 |
\fi |
| 1671 |
\fi |
| 1672 |
}% |
| 1673 |
} |
| 1674 |
|
| 1675 |
\newlength\diff |
| 1676 |
\newlength\absdiff |
| 1677 |
\newlength\Epsilon |
| 1678 |
\newlength\dEpsilon |
| 1679 |
\Epsilon=0.05pt |
| 1680 |
\dEpsilon=0.001pt |
| 1681 |
\def\test#1#2{% |
| 1682 |
\begin{preview}% |
| 1683 |
\sbox0{\includegraphics[#1]{#2}}% |
| 1684 |
\sbox1{\adjustbox{#1}{\input{#2}\unskip}}% |
| 1685 |
\begin{tabular}{ll@{}l} |
| 1686 |
\usebox0 & \usebox1 & .\\ |
| 1687 |
\the\ht0 & \the\ht1 & \showdiff\ht \\ |
| 1688 |
\the\dp0 & \the\dp1 & \showdiff\dp \\ |
| 1689 |
\the\wd0 & \the\wd1 & \showdiff\wd \\ |
| 1690 |
\end{tabular}% |
| 1691 |
\end{preview}% |
| 1692 |
} |
| 1693 |
|
| 1694 |
\begin{document} |
| 1695 |
\ttfamily |
| 1696 |
|
| 1697 |
\test{}{gridbp} |
| 1698 |
|
| 1699 |
\test{}{gridpt} |
| 1700 |
|
| 1701 |
\test{clip,trim=10bp 20bp 0 0,width=177bp,frame=1pt 1pt}{gridbp} |
| 1702 |
|
| 1703 |
\test{clip,trim=10pt 20pt 0 0,width=177pt,frame=1pt 1pt}{gridpt} |
| 1704 |
|
| 1705 |
\test{angle=45,clip,trim=10bp 0 0 0,width=177bp,totalheight=5cm,frame}{gridbp} |
| 1706 |
|
| 1707 |
\test{clip,trim=10pt 0 0 0,angle=90,trim=5pt 0 0 0}{gridbp} |
| 1708 |
|
| 1709 |
\test{angle=180,totalheight=5cm}{gridbp} |
| 1710 |
|
| 1711 |
\test{width=3cm,angle=0,totalheight=5cm}{gridbp} |
| 1712 |
|
| 1713 |
\test{width=3cm,totalheight=5cm,angle=180}{gridbp} |
| 1714 |
|
| 1715 |
\test{width=3cm,totalheight=5cm}{gridbp} |
| 1716 |
|
| 1717 |
\test{margin=.5cm .5cm .5cm .5cm,frame}{gridbp} |
| 1718 |
\end{document} |
| 1719 |
|
| 1720 |
\test{width=2cm, |
| 1721 |
margin=.1cm .1cm .1cm .1cm,frame,angle=5, |
| 1722 |
margin=.1cm .1cm .1cm .1cm,frame,angle=5, |
| 1723 |
margin=.1cm .1cm .1cm .1cm,frame,angle=5, |
| 1724 |
margin=.1cm .1cm .1cm .1cm,frame,angle=5, |
| 1725 |
margin=.1cm .1cm .1cm .1cm,frame,angle=5, |
| 1726 |
margin=.1cm .1cm .1cm .1cm,frame,angle=5, |
| 1727 |
margin=.1cm .1cm .1cm .1cm,frame,angle=5, |
| 1728 |
margin=.1cm .1cm .1cm .1cm,frame,angle=5, |
| 1729 |
margin=.1cm .1cm .1cm .1cm,frame |
| 1730 |
}{gridbp} |
| 1731 |
|
| 1732 |
\test{width=2cm, |
| 1733 |
margin=1pt 1pt 1pt 1pt,frame,angle=1, |
| 1734 |
margin=1pt 1pt 1pt 1pt,frame,angle=1, |
| 1735 |
margin=1pt 1pt 1pt 1pt,frame,angle=1, |
| 1736 |
margin=1pt 1pt 1pt 1pt,frame,angle=1, |
| 1737 |
margin=1pt 1pt 1pt 1pt,frame,angle=1, |
| 1738 |
margin=1pt 1pt 1pt 1pt,frame,angle=1, |
| 1739 |
margin=1pt 1pt 1pt 1pt,frame,angle=1, |
| 1740 |
margin=1pt 1pt 1pt 1pt,frame,angle=1, |
| 1741 |
margin=1pt 1pt 1pt 1pt,frame,angle=1, |
| 1742 |
margin=1pt 1pt 1pt 1pt,frame,angle=1, |
| 1743 |
margin=1pt 1pt 1pt 1pt,frame,angle=1, |
| 1744 |
margin=1pt 1pt 1pt 1pt,frame,angle=1, |
| 1745 |
margin=1pt 1pt 1pt 1pt,frame,angle=1, |
| 1746 |
margin=1pt 1pt 1pt 1pt,frame,angle=1, |
| 1747 |
margin=1pt 1pt 1pt 1pt,frame,angle=1, |
| 1748 |
margin=1pt 1pt 1pt 1pt,frame,angle=1, |
| 1749 |
margin=1pt 1pt 1pt 1pt,frame,angle=1, |
| 1750 |
margin=1pt 1pt 1pt 1pt,frame,angle=1, |
| 1751 |
margin=1pt 1pt 1pt 1pt,frame,angle=1, |
| 1752 |
margin=1pt 1pt 1pt 1pt,frame,angle=1, |
| 1753 |
}{gridbp} |
| 1754 |
|
| 1755 |
|
| 1756 |
\end{document} |
| 1757 |
|
| 1758 |
\adjustbox{width=2cm,trim={.5\WIDTH} 0 0 0,frame}{Ag} |
| 1759 |
% \iffalse |
| 1760 |
%</compare.tex> |
| 1761 |
% \fi |
| 1762 |
% |
| 1763 |
% \iffalse |
| 1764 |
%<*margin2.tex> |
| 1765 |
% \fi |
| 1766 |
%<*standalone> |
| 1767 |
\documentclass{standalone} |
| 1768 |
|
| 1769 |
\usepackage{tikz} |
| 1770 |
\usetikzlibrary{calc} |
| 1771 |
\newsavebox\mybox |
| 1772 |
|
| 1773 |
\begin{document} |
| 1774 |
%</standalone> |
| 1775 |
% Diagram of the TeX box model and its dimensions |
| 1776 |
% Copyright (C) 2001 by Martin Scharrer <[email protected]>, Nov 12th 2011 |
| 1777 |
% This is free code under the LPPL v1.3 or later version OR the CC BY-SA 3.0 |
| 1778 |
\begin{tikzpicture}[font=\sffamily,>=latex] |
| 1779 |
% Save example text in box |
| 1780 |
\def\text{\scalebox{10}{Xy}} |
| 1781 |
\sbox\mybox{\pgfinterruptpicture\sffamily\color{black!25}\scalebox{10}{Xy}\endpgfinterruptpicture} |
| 1782 |
\def\HEIGHT{\ht\mybox} |
| 1783 |
\def\WIDTH{\wd\mybox} |
| 1784 |
\def\DEPTH{\dp\mybox} |
| 1785 |
\def\LLX{.15\WIDTH} |
| 1786 |
\def\LLY{.5\DEPTH} |
| 1787 |
\def\URX{.15\WIDTH} |
| 1788 |
\def\URY{.25\HEIGHT} |
| 1789 |
% Text node: |
| 1790 |
\node [inner sep=0pt,anchor=base west] {\usebox\mybox}; |
| 1791 |
% Baseline |
| 1792 |
\draw (0,0) -- (\WIDTH,0);% node [above,midway] {baseline}; |
| 1793 |
%\draw [<-,shorten <=2pt] (0,0) -- (2ex,-2ex) -- +(.5ex,0) node [right=-0.5ex] {origin}; |
| 1794 |
% Dimensions |
| 1795 |
\begin{scope}[blue,every node/.append style={inner sep=2pt}] |
| 1796 |
\begin{scope} |
| 1797 |
\draw ([shift={(-\LLX,-\LLY)}]0,-\DEPTH) rectangle ([shift={(\URX,\URY)}]\WIDTH,\HEIGHT); |
| 1798 |
%\node [inner sep=0pt,anchor=base west,color=blue!50!white] {\text}; |
| 1799 |
\end{scope} |
| 1800 |
%\draw [->,.!45] (\WIDTH,\HEIGHT) -- ++(-\URX,-\URY); |
| 1801 |
%\draw [->,.!45] (0,-\DEPTH) -- ++(\LLX,\LLY); |
| 1802 |
\draw [->] (.5\WIDTH,-\DEPTH) -- ++(0,-\LLY) node [right,midway] {\scriptsize lly}; |
| 1803 |
\draw [->] (0,.5*\HEIGHT-.5*\DEPTH) -- ++(-\LLX,0) node [above,midway] {\scriptsize llx}; |
| 1804 |
\draw [->] (.5\WIDTH,\HEIGHT) -- ++(0,\URY) node [right,midway] {\scriptsize ury}; |
| 1805 |
\draw [->] (\WIDTH,.5*\HEIGHT-.5*\DEPTH) -- ++(\URX,0) node [above,midway] {\scriptsize urx}; |
| 1806 |
\draw [->] (.5\WIDTH,-\DEPTH) -- ++(0,-\LLY) node [right,midway] {\scriptsize lly}; |
| 1807 |
\draw (-\LLX,-\LLY) -- ([shift={(+\URX,0)}]\WIDTH,-\LLY); |
| 1808 |
\path [fill=white,draw] (-\LLX,-\LLY) circle (1pt); |
| 1809 |
\draw [->] (.5\WIDTH,0pt) -- ++(0,-\LLY) node [right,midway] {\scriptsize lly}; |
| 1810 |
\end{scope} |
| 1811 |
% Box |
| 1812 |
\draw [thick] (0,-\DEPTH) rectangle (\WIDTH,\HEIGHT); |
| 1813 |
% Origin |
| 1814 |
\path [fill=white,draw=black] (0,0) circle (1pt); |
| 1815 |
% Center inner box |
| 1816 |
\path let |
| 1817 |
\p1 = (current bounding box.south west), |
| 1818 |
\p2 = (current bounding box.north east), |
| 1819 |
\p3 = (0,-\DEPTH), |
| 1820 |
\p4 = (\WIDTH,\HEIGHT) |
| 1821 |
in |
| 1822 |
(\x3-\x2+\x4,\y3) rectangle (\x4+\x3-\x1,\y4); |
| 1823 |
\end{tikzpicture} |
| 1824 |
%<*standalone> |
| 1825 |
\end{document} |
| 1826 |
%</standalone> |
| 1827 |
% \iffalse |
| 1828 |
%</margin2.tex> |
| 1829 |
% \fi |
| 1830 |
% |
| 1831 |
% \iffalse |
| 1832 |
%<*margin.tex> |
| 1833 |
% \fi |
| 1834 |
%<*standalone> |
| 1835 |
\documentclass{standalone} |
| 1836 |
|
| 1837 |
\usepackage{tikz} |
| 1838 |
\usetikzlibrary{calc} |
| 1839 |
\newsavebox\mybox |
| 1840 |
|
| 1841 |
\begin{document} |
| 1842 |
% Diagram of the TeX box model and its dimensions |
| 1843 |
% Copyright (C) 2001 by Martin Scharrer <[email protected]>, Nov 12th 2011 |
| 1844 |
% This is free code under the LPPL v1.3 or later version OR the CC BY-SA 3.0 |
| 1845 |
%</standalone> |
| 1846 |
\begin{tikzpicture}[font=\sffamily,>=latex] |
| 1847 |
% Save example text in box |
| 1848 |
\def\text{\scalebox{10}{Xy}} |
| 1849 |
\sbox\mybox{\pgfinterruptpicture\sffamily\color{black!25}\scalebox{10}{Xy}\endpgfinterruptpicture} |
| 1850 |
\def\HEIGHT{\ht\mybox} |
| 1851 |
\def\WIDTH{\wd\mybox} |
| 1852 |
\def\DEPTH{\dp\mybox} |
| 1853 |
\def\LLX{.15\WIDTH} |
| 1854 |
\def\LLY{.5\DEPTH} |
| 1855 |
\def\URX{.15\WIDTH} |
| 1856 |
\def\URY{.25\HEIGHT} |
| 1857 |
% Text node: |
| 1858 |
\node [inner sep=0pt,anchor=base west] {\usebox\mybox}; |
| 1859 |
% Baseline |
| 1860 |
\draw (0,0) -- (\WIDTH,0);% node [above,midway] {baseline}; |
| 1861 |
%\draw [<-,shorten <=2pt] (0,0) -- (2ex,-2ex) -- +(.5ex,0) node [right=-0.5ex] {origin}; |
| 1862 |
% Dimensions |
| 1863 |
\begin{scope}[blue,every node/.append style={inner sep=2pt}] |
| 1864 |
\begin{scope} |
| 1865 |
\draw ([shift={(-\LLX,-\LLY)}]0,-\DEPTH) rectangle ([shift={(\URX,\URY)}]\WIDTH,\HEIGHT); |
| 1866 |
%\node [inner sep=0pt,anchor=base west,color=blue!50!white] {\text}; |
| 1867 |
\end{scope} |
| 1868 |
%\draw [->,.!45] (\WIDTH,\HEIGHT) -- ++(-\URX,-\URY); |
| 1869 |
%\draw [->,.!45] (0,-\DEPTH) -- ++(\LLX,\LLY); |
| 1870 |
\draw [->] (.5\WIDTH,-\DEPTH) -- ++(0,-\LLY) node [right,midway] {\scriptsize lly}; |
| 1871 |
\draw [->] (0,.5*\HEIGHT-.5*\DEPTH) -- ++(-\LLX,0) node [above,midway] {\scriptsize llx}; |
| 1872 |
\draw (-\LLX,0) -- ([shift={(+\URX,0)}]\WIDTH,0); |
| 1873 |
\draw [->] (.5\WIDTH,\HEIGHT) -- ++(0,\URY) node [right,midway] {\scriptsize ury}; |
| 1874 |
\draw [->] (\WIDTH,.5*\HEIGHT-.5*\DEPTH) -- ++(\URX,0) node [above,midway] {\scriptsize urx}; |
| 1875 |
\path [fill=white,draw] (-\LLX,0) circle (1pt); |
| 1876 |
\end{scope} |
| 1877 |
% Box |
| 1878 |
\draw [thick] (0,-\DEPTH) rectangle (\WIDTH,\HEIGHT); |
| 1879 |
% Origin |
| 1880 |
\path [fill=white,draw=black] (0,0) circle (1pt); |
| 1881 |
% Center inner box |
| 1882 |
\path let |
| 1883 |
\p1 = (current bounding box.south west), |
| 1884 |
\p2 = (current bounding box.north east), |
| 1885 |
\p3 = (0,-\DEPTH), |
| 1886 |
\p4 = (\WIDTH,\HEIGHT) |
| 1887 |
in |
| 1888 |
(\x3-\x2+\x4,\y3) rectangle (\x4+\x3-\x1,\y4); |
| 1889 |
\end{tikzpicture} |
| 1890 |
%<*standalone> |
| 1891 |
\end{document} |
| 1892 |
%</standalone> |
| 1893 |
% \iffalse |
| 1894 |
%</margin.tex> |
| 1895 |
% \fi |
| 1896 |
% |
| 1897 |
% \iffalse |
| 1898 |
%<*trim2.tex> |
| 1899 |
% \fi |
| 1900 |
%<*standalone> |
| 1901 |
\documentclass{standalone} |
| 1902 |
|
| 1903 |
\usepackage{tikz} |
| 1904 |
\usetikzlibrary{calc} |
| 1905 |
\usepackage{adjustbox} |
| 1906 |
\newsavebox\mybox |
| 1907 |
|
| 1908 |
\begin{document} |
| 1909 |
%</standalone> |
| 1910 |
% Diagram of the TeX box model and its dimensions |
| 1911 |
% Copyright (C) 2001 by Martin Scharrer <[email protected]>, Nov 12th 2011 |
| 1912 |
% This is free code under the LPPL v1.3 or later version OR the CC BY-SA 3.0 |
| 1913 |
|
| 1914 |
% Save example text in box |
| 1915 |
\def\text{\sffamily\scalebox{10}{Xy}} |
| 1916 |
\sbox\mybox{\sffamily\color{black!25}\scalebox{10}{Xy}} |
| 1917 |
\def\HEIGHT{\ht\mybox} |
| 1918 |
\def\WIDTH{\wd\mybox} |
| 1919 |
\def\DEPTH{\dp\mybox} |
| 1920 |
\def\LLX{.15\WIDTH} |
| 1921 |
\def\LLY{\DEPTH+.15\HEIGHT} |
| 1922 |
\def\URX{.15\WIDTH} |
| 1923 |
\def\URY{.25\HEIGHT} |
| 1924 |
% |
| 1925 |
%\usebox\mybox |
| 1926 |
%\rlap{\trimbox{{\LLX} {\LLY} {\URX} {\URY}}{\usebox\mybox}}\clipbox{{\LLX} {\LLY} {\URX} {\URY}}{\color{blue}{\text}} |
| 1927 |
\begin{tikzpicture}[font=\sffamily,>=latex] |
| 1928 |
% Extensions lines for dimensions (drawn here to be below other material) |
| 1929 |
\draw [gray,thin] |
| 1930 |
(0,0) -- +(-3.5ex,0) |
| 1931 |
(0,\HEIGHT) -- +(-3.5ex,0) |
| 1932 |
(0,-\DEPTH) -- +(-3.5ex,0) |
| 1933 |
(\WIDTH,\HEIGHT) -- +(3.5ex,0) |
| 1934 |
(\WIDTH,-\DEPTH) -- +(3.5ex,0) |
| 1935 |
(0,-\DEPTH) -- +(0,-3.5ex) |
| 1936 |
(\WIDTH,-\DEPTH) -- +(0,-3.5ex) |
| 1937 |
; |
| 1938 |
% Text node: |
| 1939 |
\node [inner sep=0pt,anchor=base west] {\usebox\mybox}; |
| 1940 |
% Baseline |
| 1941 |
\draw (0,0) -- (\WIDTH,0);% node [above,midway] {baseline}; |
| 1942 |
%\draw [<-,shorten <=2pt] (0,0) -- (2ex,-2ex) -- +(.5ex,0) node [right=-0.5ex] {origin}; |
| 1943 |
% Dimensions |
| 1944 |
\draw [->] (-2.5ex,0) -- +(0,-\DEPTH) node [midway,left] {depth}; |
| 1945 |
\draw [->] (-2.5ex,0) -- +(0, \HEIGHT) node [midway,left] {height}; |
| 1946 |
\draw [<->] (\WIDTH,-\DEPTH) ++(2.5ex,0) -- +(0,\DEPTH+\HEIGHT) node [midway,right] {totalheight}; |
| 1947 |
\draw [<->] (0,-\DEPTH) ++(0,-2.5ex) -- +(\WIDTH,0) node [midway,below] {width}; |
| 1948 |
\fill (-2.5ex,0) circle (.5pt); |
| 1949 |
\begin{scope}[blue] %,every node/.append style={inner sep=2pt}] |
| 1950 |
\begin{scope} |
| 1951 |
\clip ([shift={(\LLX,\LLY)}]0,-\DEPTH) rectangle ([shift={(-\URX,-\URY)}]\WIDTH,\HEIGHT); |
| 1952 |
\node [inner sep=0pt,anchor=base west,color=blue!50!white] {\text}; |
| 1953 |
\end{scope} |
| 1954 |
%\draw [->,.!45] (\WIDTH,\HEIGHT) -- ++(-\URX,-\URY); |
| 1955 |
%\draw [->,.!45] (0,-\DEPTH) -- ++(\LLX,\LLY); |
| 1956 |
\draw ([shift={(\LLX,\LLY)}]0,-\DEPTH) rectangle ([shift={(-\URX,-\URY)}]\WIDTH,\HEIGHT); |
| 1957 |
\draw [->] (\LLX,-\DEPTH) -- ++(0,\LLY) node [right,midway] {\scriptsize lly}; |
| 1958 |
\draw [->] (0,-\DEPTH+\LLY) -- ++(\LLX,0) node [above,midway] {\scriptsize llx}; |
| 1959 |
\draw (\LLX,-\DEPTH+\LLY) -- ([shift={(-\URX,0)}]\WIDTH,-\DEPTH+\LLY); |
| 1960 |
\draw [->] (\LLX+.2\WIDTH,-\DEPTH+\LLY) -- (\LLX+.2\WIDTH,0) node [right,midway] {\scriptsize moves down}; |
| 1961 |
\path [fill=white,draw] (\LLX,-\DEPTH+\LLY) circle (1pt); |
| 1962 |
\draw [->] |
| 1963 |
([shift={(-\URX,0)}]\WIDTH,\HEIGHT) -- |
| 1964 |
([shift={(-\URX,-\URY)}]\WIDTH,\HEIGHT) |
| 1965 |
node [left,midway] {\scriptsize ury} |
| 1966 |
; |
| 1967 |
\draw [->] |
| 1968 |
([shift={(0,-\URY)}]\WIDTH,\HEIGHT) -- |
| 1969 |
([shift={(-\URX,-\URY)}]\WIDTH,\HEIGHT) |
| 1970 |
node [below,midway] {\scriptsize urx} |
| 1971 |
; |
| 1972 |
\end{scope} |
| 1973 |
% Box |
| 1974 |
\draw [thick] (0,-\DEPTH) rectangle (\WIDTH,\HEIGHT); |
| 1975 |
% Origin |
| 1976 |
\path [fill=white,draw=black] (0,0) circle (1pt); |
| 1977 |
% Center inner box |
| 1978 |
\path let |
| 1979 |
\p1 = (current bounding box.south west), |
| 1980 |
\p2 = (current bounding box.north east), |
| 1981 |
\p3 = (0,-\DEPTH), |
| 1982 |
\p4 = (\WIDTH,\HEIGHT) |
| 1983 |
in |
| 1984 |
(\x3-\x2+\x4,\y3) rectangle (\x4+\x3-\x1,\y4); |
| 1985 |
\end{tikzpicture} |
| 1986 |
%<*standalone> |
| 1987 |
\end{document} |
| 1988 |
%</standalone> |
| 1989 |
% \iffalse |
| 1990 |
%</trim2.tex> |
| 1991 |
% \fi |
| 1992 |
% |
| 1993 |
% \iffalse |
| 1994 |
%<*trim3.tex> |
| 1995 |
% \fi |
| 1996 |
%<*standalone> |
| 1997 |
\documentclass{standalone} |
| 1998 |
|
| 1999 |
\usepackage{tikz} |
| 2000 |
\usetikzlibrary{calc} |
| 2001 |
\usepackage{adjustbox} |
| 2002 |
\newsavebox\mybox |
| 2003 |
|
| 2004 |
\begin{document} |
| 2005 |
%</standalone> |
| 2006 |
% Diagram of the TeX box model and its dimensions |
| 2007 |
% Copyright (C) 2001 by Martin Scharrer <[email protected]>, Nov 12th 2011 |
| 2008 |
% This is free code under the LPPL v1.3 or later version OR the CC BY-SA 3.0 |
| 2009 |
|
| 2010 |
% Save example text in box |
| 2011 |
\def\text{\sffamily\scalebox{10}{Xy}} |
| 2012 |
\sbox\mybox{\sffamily\color{black!25}\scalebox{10}{Xy}} |
| 2013 |
\def\HEIGHT{\ht\mybox} |
| 2014 |
\def\WIDTH{\wd\mybox} |
| 2015 |
\def\DEPTH{\dp\mybox} |
| 2016 |
\def\LLX{.15\WIDTH} |
| 2017 |
\def\LLY{.4\DEPTH} |
| 2018 |
\def\URX{.15\WIDTH} |
| 2019 |
\def\URY{(\HEIGHT+.25\DEPTH)} |
| 2020 |
% |
| 2021 |
%\leavevmode |
| 2022 |
%\rlap{\hbox to \wd\mybox{\hrulefill}}\usebox\mybox |
| 2023 |
%\rlap{\hbox to \wd\mybox{\hrulefill}}\rlap{\trimbox{{\LLX} {\LLY} {\URX} {\URY}}{\usebox\mybox}}\clipbox{{\LLX} {\LLY} {\URX} {\URY}}{\color{blue}{\text}} |
| 2024 |
%\sbox0{\clipbox{{\LLX} {\LLY} {\URX} {\URY}}{\color{blue}{\text}}}% |
| 2025 |
%ht=\the\ht0, dp=\the\dp0, wd=\the\wd0 |
| 2026 |
\begin{tikzpicture}[font=\sffamily,>=latex] |
| 2027 |
% Extensions lines for dimensions (drawn here to be below other material) |
| 2028 |
\draw [gray,thin] |
| 2029 |
(0,0) -- +(-3.5ex,0) |
| 2030 |
(0,\HEIGHT) -- +(-3.5ex,0) |
| 2031 |
(0,-\DEPTH) -- +(-3.5ex,0) |
| 2032 |
(\WIDTH,\HEIGHT) -- +(3.5ex,0) |
| 2033 |
(\WIDTH,-\DEPTH) -- +(3.5ex,0) |
| 2034 |
(0,-\DEPTH) -- +(0,-3.5ex) |
| 2035 |
(\WIDTH,-\DEPTH) -- +(0,-3.5ex) |
| 2036 |
; |
| 2037 |
% Text node: |
| 2038 |
\node [inner sep=0pt,anchor=base west] {\usebox\mybox}; |
| 2039 |
% Baseline |
| 2040 |
\draw (0,0) -- (\WIDTH,0);% node [above,midway] {baseline}; |
| 2041 |
%\draw [<-,shorten <=2pt] (0,0) -- (2ex,-2ex) -- +(.5ex,0) node [right=-0.5ex] {origin}; |
| 2042 |
% Dimensions |
| 2043 |
\draw [->] (-2.5ex,0) -- +(0,-\DEPTH) node [midway,left] {depth}; |
| 2044 |
\draw [->] (-2.5ex,0) -- +(0, \HEIGHT) node [midway,left] {height}; |
| 2045 |
\draw [<->] (\WIDTH,-\DEPTH) ++(2.5ex,0) -- +(0,\DEPTH+\HEIGHT) node [midway,right] {totalheight}; |
| 2046 |
\draw [<->] (0,-\DEPTH) ++(0,-2.5ex) -- +(\WIDTH,0) node [midway,below] {width}; |
| 2047 |
\fill (-2.5ex,0) circle (.5pt); |
| 2048 |
\begin{scope}[blue] %,every node/.append style={inner sep=2pt}] |
| 2049 |
\begin{scope} |
| 2050 |
\clip ([shift={(\LLX,\LLY)}]0,-\DEPTH) rectangle ([shift={(-\URX,-\URY)}]\WIDTH,\HEIGHT); |
| 2051 |
\node [inner sep=0pt,anchor=base west,color=blue!50!white] {\text}; |
| 2052 |
\end{scope} |
| 2053 |
%\draw [->,.!45] (\WIDTH,\HEIGHT) -- ++(-\URX,{-\URY}); |
| 2054 |
%\draw [->,.!45] (0,-\DEPTH) -- ++(\LLX,\LLY); |
| 2055 |
\draw ([shift={(\LLX,\LLY)}]0,-\DEPTH) rectangle ([shift={(-\URX,-\URY)}]\WIDTH,\HEIGHT); |
| 2056 |
\draw [->] (\LLX,-\DEPTH) -- ++(0,\LLY) node [right,midway] {\scriptsize lly}; |
| 2057 |
\draw [->] (0,-\DEPTH+\LLY) -- ++(\LLX,0) node [above,midway] {\scriptsize llx}; |
| 2058 |
\draw (\LLX,-\DEPTH+\LLY) -- ([shift={(-\URX,0)}]\WIDTH,-\DEPTH+\LLY); |
| 2059 |
\draw [->] (\LLX+.2\WIDTH,{\HEIGHT-\URY}) -- (\LLX+.2\WIDTH,0) node [pos=0.4,below right] {\scriptsize moves up}; |
| 2060 |
\path [fill=white,draw] (\LLX,{\HEIGHT-\URY}) circle (1pt); |
| 2061 |
\draw [->] |
| 2062 |
([shift={(-\URX,0)}]\WIDTH,\HEIGHT) -- |
| 2063 |
([shift={(-\URX,-\URY)}]\WIDTH,\HEIGHT) |
| 2064 |
node [left,midway] {\scriptsize ury} |
| 2065 |
; |
| 2066 |
\draw [->] |
| 2067 |
([shift={(0,-\URY)}]\WIDTH,\HEIGHT) -- |
| 2068 |
([shift={(-\URX,-\URY)}]\WIDTH,\HEIGHT) |
| 2069 |
node [below,midway] {\scriptsize urx} |
| 2070 |
; |
| 2071 |
\end{scope} |
| 2072 |
% Box |
| 2073 |
\draw [thick] (0,-\DEPTH) rectangle (\WIDTH,\HEIGHT); |
| 2074 |
% Origin |
| 2075 |
\path [fill=white,draw=black] (0,0) circle (1pt); |
| 2076 |
% Center inner box |
| 2077 |
\path let |
| 2078 |
\p1 = (current bounding box.south west), |
| 2079 |
\p2 = (current bounding box.north east), |
| 2080 |
\p3 = (0,-\DEPTH), |
| 2081 |
\p4 = (\WIDTH,\HEIGHT) |
| 2082 |
in |
| 2083 |
(\x3-\x2+\x4,\y3) rectangle (\x4+\x3-\x1,\y4); |
| 2084 |
\end{tikzpicture} |
| 2085 |
%<*standalone> |
| 2086 |
\end{document} |
| 2087 |
%</standalone> |
| 2088 |
% \iffalse |
| 2089 |
%</trim3.tex> |
| 2090 |
% \fi |
| 2091 |
% |
| 2092 |
% \iffalse |
| 2093 |
%<*trim.tex> |
| 2094 |
% \fi |
| 2095 |
%<*standalone> |
| 2096 |
\documentclass{standalone} |
| 2097 |
|
| 2098 |
\usepackage{tikz} |
| 2099 |
\usetikzlibrary{calc} |
| 2100 |
\newsavebox\mybox |
| 2101 |
|
| 2102 |
\begin{document} |
| 2103 |
%</standalone> |
| 2104 |
% Diagram of the TeX box model and its dimensions |
| 2105 |
% Copyright (C) 2001 by Martin Scharrer <[email protected]>, Nov 12th 2011 |
| 2106 |
% This is free code under the LPPL v1.3 or later version OR the CC BY-SA 3.0 |
| 2107 |
\begin{tikzpicture}[font=\sffamily,>=latex] |
| 2108 |
% Save example text in box |
| 2109 |
\def\text{\scalebox{10}{Xy}} |
| 2110 |
\sbox\mybox{\pgfinterruptpicture\sffamily\color{black!25}\scalebox{10}{Xy}\endpgfinterruptpicture} |
| 2111 |
\def\HEIGHT{\ht\mybox} |
| 2112 |
\def\WIDTH{\wd\mybox} |
| 2113 |
\def\DEPTH{\dp\mybox} |
| 2114 |
\def\LLX{.15\WIDTH} |
| 2115 |
\def\LLY{.5\DEPTH} |
| 2116 |
\def\URX{.15\WIDTH} |
| 2117 |
\def\URY{.25\HEIGHT} |
| 2118 |
% Extensions lines for dimensions (drawn here to be below other material) |
| 2119 |
\draw [gray,thin] |
| 2120 |
(0,0) -- +(-3.5ex,0) |
| 2121 |
(0,\HEIGHT) -- +(-3.5ex,0) |
| 2122 |
(0,-\DEPTH) -- +(-3.5ex,0) |
| 2123 |
(\WIDTH,\HEIGHT) -- +(3.5ex,0) |
| 2124 |
(\WIDTH,-\DEPTH) -- +(3.5ex,0) |
| 2125 |
(0,-\DEPTH) -- +(0,-3.5ex) |
| 2126 |
(\WIDTH,-\DEPTH) -- +(0,-3.5ex) |
| 2127 |
; |
| 2128 |
% Text node: |
| 2129 |
\node [inner sep=0pt,anchor=base west] {\usebox\mybox}; |
| 2130 |
% Baseline |
| 2131 |
\draw (0,0) -- (\WIDTH,0);% node [above,midway] {baseline}; |
| 2132 |
%\draw [<-,shorten <=2pt] (0,0) -- (2ex,-2ex) -- +(.5ex,0) node [right=-0.5ex] {origin}; |
| 2133 |
% Dimensions |
| 2134 |
\draw [->] (-2.5ex,0) -- +(0,-\DEPTH) node [midway,left] {depth}; |
| 2135 |
\draw [->] (-2.5ex,0) -- +(0, \HEIGHT) node [midway,left] {height}; |
| 2136 |
\draw [<->] (\WIDTH,-\DEPTH) ++(2.5ex,0) -- +(0,\DEPTH+\HEIGHT) node [midway,right] {totalheight}; |
| 2137 |
\draw [<->] (0,-\DEPTH) ++(0,-2.5ex) -- +(\WIDTH,0) node [midway,below] {width}; |
| 2138 |
\fill (-2.5ex,0) circle (.5pt); |
| 2139 |
\begin{scope}[blue,every node/.append style={inner sep=2pt}] |
| 2140 |
\begin{scope} |
| 2141 |
\clip ([shift={(\LLX,\LLY)}]0,-\DEPTH) rectangle ([shift={(-\URX,-\URY)}]\WIDTH,\HEIGHT); |
| 2142 |
\node [inner sep=0pt,anchor=base west,color=blue!50!white] {\text}; |
| 2143 |
\end{scope} |
| 2144 |
%\draw [->,.!45] (\WIDTH,\HEIGHT) -- ++(-\URX,-\URY); |
| 2145 |
%\draw [->,.!45] (0,-\DEPTH) -- ++(\LLX,\LLY); |
| 2146 |
\draw ([shift={(\LLX,\LLY)}]0,-\DEPTH) rectangle ([shift={(-\URX,-\URY)}]\WIDTH,\HEIGHT); |
| 2147 |
\draw [->] (\LLX,-\DEPTH) -- ++(0,\LLY) node [right,midway] {\scriptsize lly}; |
| 2148 |
\draw [->] (0,-\DEPTH+\LLY) -- ++(\LLX,0) node [above,midway] {\scriptsize llx}; |
| 2149 |
\draw (\LLX,0) -- ([shift={(-\URX,0)}]\WIDTH,0); |
| 2150 |
\draw [->] |
| 2151 |
([shift={(-\URX,0)}]\WIDTH,\HEIGHT) -- |
| 2152 |
([shift={(-\URX,-\URY)}]\WIDTH,\HEIGHT) |
| 2153 |
node [left,midway] {\scriptsize ury} |
| 2154 |
; |
| 2155 |
\draw [->] |
| 2156 |
([shift={(0,-\URY)}]\WIDTH,\HEIGHT) -- |
| 2157 |
([shift={(-\URX,-\URY)}]\WIDTH,\HEIGHT) |
| 2158 |
node [below,midway] {\scriptsize urx} |
| 2159 |
; |
| 2160 |
\path [fill=white,draw] (\LLX,0) circle (1pt); |
| 2161 |
\end{scope} |
| 2162 |
% Box |
| 2163 |
\draw [thick] (0,-\DEPTH) rectangle (\WIDTH,\HEIGHT); |
| 2164 |
% Origin |
| 2165 |
\path [fill=white,draw=black] (0,0) circle (1pt); |
| 2166 |
% Center inner box |
| 2167 |
\path let |
| 2168 |
\p1 = (current bounding box.south west), |
| 2169 |
\p2 = (current bounding box.north east), |
| 2170 |
\p3 = (0,-\DEPTH), |
| 2171 |
\p4 = (\WIDTH,\HEIGHT) |
| 2172 |
in |
| 2173 |
(\x3-\x2+\x4,\y3) rectangle (\x4+\x3-\x1,\y4); |
| 2174 |
\end{tikzpicture} |
| 2175 |
%<*standalone> |
| 2176 |
\end{document} |
| 2177 |
%</standalone> |
| 2178 |
% \iffalse |
| 2179 |
%</trim.tex> |
| 2180 |
% \fi |
| 2181 |
% |
| 2182 |
% \iffalse |
| 2183 |
%<*viewport2.tex> |
| 2184 |
% \fi |
| 2185 |
%<*standalone> |
| 2186 |
\documentclass{standalone} |
| 2187 |
|
| 2188 |
\usepackage{tikz} |
| 2189 |
\usetikzlibrary{calc} |
| 2190 |
\usepackage{adjustbox} |
| 2191 |
\newsavebox\mybox |
| 2192 |
|
| 2193 |
\begin{document} |
| 2194 |
%</standalone> |
| 2195 |
% Diagram of the TeX box model and its dimensions |
| 2196 |
% Copyright (C) 2001 by Martin Scharrer <[email protected]>, Nov 12th 2011 |
| 2197 |
% This is free code under the LPPL v1.3 or later version OR the CC BY-SA 3.0 |
| 2198 |
|
| 2199 |
% Save example text in box |
| 2200 |
\def\text{\sffamily\scalebox{10}{Xy}} |
| 2201 |
\sbox\mybox{\sffamily\color{black!25}\scalebox{10}{Xy}} |
| 2202 |
\def\HEIGHT{\ht\mybox} |
| 2203 |
\def\WIDTH{\wd\mybox} |
| 2204 |
\def\DEPTH{\dp\mybox} |
| 2205 |
\def\LLX{.15\WIDTH} |
| 2206 |
\def\LLY{\DEPTH-.15\HEIGHT} |
| 2207 |
\def\URX{.15\WIDTH} |
| 2208 |
\def\URY{.25\HEIGHT} |
| 2209 |
% |
| 2210 |
%\usebox\mybox |
| 2211 |
%\rlap{\trimbox{{\LLX} {\LLY} {\URX} {\URY}}{\usebox\mybox}}\clipbox{{\LLX} {\LLY} {\URX} {\URY}}{\color{blue}{\text}} |
| 2212 |
\begin{tikzpicture}[font=\sffamily,>=latex] |
| 2213 |
% Extensions lines for dimensions (drawn here to be below other material) |
| 2214 |
\draw [gray,thin] |
| 2215 |
(0,0) -- +(-3.5ex,0) |
| 2216 |
(0,\HEIGHT) -- +(-3.5ex,0) |
| 2217 |
(0,-\DEPTH) -- +(-3.5ex,0) |
| 2218 |
(\WIDTH,\HEIGHT) -- +(3.5ex,0) |
| 2219 |
(\WIDTH,-\DEPTH) -- +(3.5ex,0) |
| 2220 |
(0,-\DEPTH) -- +(0,-3.5ex) |
| 2221 |
(\WIDTH,-\DEPTH) -- +(0,-3.5ex) |
| 2222 |
; |
| 2223 |
% Text node: |
| 2224 |
\node [inner sep=0pt,anchor=base west] {\usebox\mybox}; |
| 2225 |
% Baseline |
| 2226 |
\draw (0,0) -- (\WIDTH,0);% node [above,midway] {baseline}; |
| 2227 |
%\draw [<-,shorten <=2pt] (0,0) -- (2ex,-2ex) -- +(.5ex,0) node [right=-0.5ex] {origin}; |
| 2228 |
% Dimensions |
| 2229 |
\draw [->] (-2.5ex,0) -- +(0,-\DEPTH) node [midway,left] {depth}; |
| 2230 |
\draw [->] (-2.5ex,0) -- +(0, \HEIGHT) node [midway,left] {height}; |
| 2231 |
\draw [<->] (\WIDTH,-\DEPTH) ++(2.5ex,0) -- +(0,\DEPTH+\HEIGHT) node [midway,right] {totalheight}; |
| 2232 |
\draw [<->] (0,-\DEPTH) ++(0,-2.5ex) -- +(\WIDTH,0) node [midway,below] {width}; |
| 2233 |
\fill (-2.5ex,0) circle (.5pt); |
| 2234 |
\begin{scope}[blue] |
| 2235 |
\clip ([shift={(\LLX,\LLY)}]0,-\DEPTH) rectangle ([shift={(-\URX,-\URY)}]\WIDTH,\HEIGHT); |
| 2236 |
\node [inner sep=0pt,anchor=base west,color=blue!50!white] {\text}; |
| 2237 |
\end{scope} |
| 2238 |
\begin{scope}[blue] |
| 2239 |
\draw ([shift={(\LLX,\LLY)}]0,-\DEPTH) rectangle ([shift={(-\URX,-\URY)}]\WIDTH,\HEIGHT); |
| 2240 |
\draw (\LLX,0) -- ([shift={(-\URX,0)}]\WIDTH,0); |
| 2241 |
\path [fill=white,draw] (\LLX,0) circle (1pt); |
| 2242 |
\end{scope} |
| 2243 |
\begin{scope}[blue!50!black] %,every node/.append style={inner sep=2pt}] |
| 2244 |
%\draw [->,.!45] (0,0) -- ++(-\URX+\WIDTH,-\URY+\HEIGHT); |
| 2245 |
%\draw [->,.!45] (0,0) -- ++(\LLX,\LLY-\DEPTH); |
| 2246 |
\draw [->] (\LLX,0) -- (\LLX,\LLY-\DEPTH) node [right,midway] {\scriptsize lly}; |
| 2247 |
\draw [->] (0,-\DEPTH+\LLY) -- ++(\LLX,0) node [above,midway] {\scriptsize llx}; |
| 2248 |
\draw [->] |
| 2249 |
([shift={(-\URX,0)}]\WIDTH,0) -- |
| 2250 |
([shift={(-\URX,-\URY)}]\WIDTH,\HEIGHT) |
| 2251 |
node [right,midway] {\scriptsize ury} |
| 2252 |
; |
| 2253 |
\draw [->] |
| 2254 |
([shift={(0,-\URY)}]0,\HEIGHT) -- |
| 2255 |
([shift={(-\URX,-\URY)}]\WIDTH,\HEIGHT) |
| 2256 |
node [above,midway] {\scriptsize urx} |
| 2257 |
; |
| 2258 |
\end{scope} |
| 2259 |
% Box |
| 2260 |
\draw [thick] (0,-\DEPTH) rectangle (\WIDTH,\HEIGHT); |
| 2261 |
% Origin |
| 2262 |
\path [fill=white,draw=black] (0,0) circle (1pt); |
| 2263 |
% Center inner box |
| 2264 |
\path let |
| 2265 |
\p1 = (current bounding box.south west), |
| 2266 |
\p2 = (current bounding box.north east), |
| 2267 |
\p3 = (0,-\DEPTH), |
| 2268 |
\p4 = (\WIDTH,\HEIGHT) |
| 2269 |
in |
| 2270 |
(\x3-\x2+\x4,\y3) rectangle (\x4+\x3-\x1,\y4); |
| 2271 |
\end{tikzpicture} |
| 2272 |
%<*standalone> |
| 2273 |
\end{document} |
| 2274 |
%</standalone> |
| 2275 |
% \iffalse |
| 2276 |
%</viewport2.tex> |
| 2277 |
% \fi |
| 2278 |
% |
| 2279 |
% \iffalse |
| 2280 |
%<*viewport.tex> |
| 2281 |
% \fi |
| 2282 |
%<*standalone> |
| 2283 |
\documentclass{standalone} |
| 2284 |
|
| 2285 |
\usepackage{tikz} |
| 2286 |
\usetikzlibrary{calc} |
| 2287 |
\usepackage{adjustbox} |
| 2288 |
\newsavebox\mybox |
| 2289 |
|
| 2290 |
\begin{document} |
| 2291 |
%</standalone> |
| 2292 |
% Diagram of the TeX box model and its dimensions |
| 2293 |
% Copyright (C) 2001 by Martin Scharrer <[email protected]>, Nov 12th 2011 |
| 2294 |
% This is free code under the LPPL v1.3 or later version OR the CC BY-SA 3.0 |
| 2295 |
|
| 2296 |
% Save example text in box |
| 2297 |
\def\text{\sffamily\scalebox{10}{Xy}} |
| 2298 |
\sbox\mybox{\sffamily\color{black!25}\scalebox{10}{Xy}} |
| 2299 |
\def\HEIGHT{\ht\mybox} |
| 2300 |
\def\WIDTH{\wd\mybox} |
| 2301 |
\def\DEPTH{\dp\mybox} |
| 2302 |
\def\LLX{.15\WIDTH} |
| 2303 |
\def\LLY{\DEPTH+.15\HEIGHT} |
| 2304 |
\def\URX{.15\WIDTH} |
| 2305 |
\def\URY{.25\HEIGHT} |
| 2306 |
% |
| 2307 |
%\usebox\mybox |
| 2308 |
%\rlap{\trimbox{{\LLX} {\LLY} {\URX} {\URY}}{\usebox\mybox}}\clipbox{{\LLX} {\LLY} {\URX} {\URY}}{\color{blue}{\text}} |
| 2309 |
\begin{tikzpicture}[font=\sffamily,>=latex] |
| 2310 |
% Extensions lines for dimensions (drawn here to be below other material) |
| 2311 |
\draw [gray,thin] |
| 2312 |
(0,0) -- +(-3.5ex,0) |
| 2313 |
(0,\HEIGHT) -- +(-3.5ex,0) |
| 2314 |
(0,-\DEPTH) -- +(-3.5ex,0) |
| 2315 |
(\WIDTH,\HEIGHT) -- +(3.5ex,0) |
| 2316 |
(\WIDTH,-\DEPTH) -- +(3.5ex,0) |
| 2317 |
(0,-\DEPTH) -- +(0,-3.5ex) |
| 2318 |
(\WIDTH,-\DEPTH) -- +(0,-3.5ex) |
| 2319 |
; |
| 2320 |
% Text node: |
| 2321 |
\node [inner sep=0pt,anchor=base west] {\usebox\mybox}; |
| 2322 |
% Baseline |
| 2323 |
\draw (0,0) -- (\WIDTH,0);% node [above,midway] {baseline}; |
| 2324 |
%\draw [<-,shorten <=2pt] (0,0) -- (2ex,-2ex) -- +(.5ex,0) node [right=-0.5ex] {origin}; |
| 2325 |
% Dimensions |
| 2326 |
\draw [->] (-2.5ex,0) -- +(0,-\DEPTH) node [midway,left] {depth}; |
| 2327 |
\draw [->] (-2.5ex,0) -- +(0, \HEIGHT) node [midway,left] {height}; |
| 2328 |
\draw [<->] (\WIDTH,-\DEPTH) ++(2.5ex,0) -- +(0,\DEPTH+\HEIGHT) node [midway,right] {totalheight}; |
| 2329 |
\draw [<->] (0,-\DEPTH) ++(0,-2.5ex) -- +(\WIDTH,0) node [midway,below] {width}; |
| 2330 |
\fill (-2.5ex,0) circle (.5pt); |
| 2331 |
\begin{scope}[blue] |
| 2332 |
\clip ([shift={(\LLX,\LLY)}]0,-\DEPTH) rectangle ([shift={(-\URX,-\URY)}]\WIDTH,\HEIGHT); |
| 2333 |
\node [inner sep=0pt,anchor=base west,color=blue!50!white] {\text}; |
| 2334 |
\end{scope} |
| 2335 |
\begin{scope}[blue] |
| 2336 |
%\draw [->,.!45] (0,0) -- ++(-\URX+\WIDTH,-\URY+\HEIGHT); |
| 2337 |
%\draw [->,.!45] (0,0) -- ++(\LLX,\LLY-\DEPTH); |
| 2338 |
\draw ([shift={(\LLX,\LLY)}]0,-\DEPTH) rectangle ([shift={(-\URX,-\URY)}]\WIDTH,\HEIGHT); |
| 2339 |
\draw (\LLX,-\DEPTH+\LLY) -- ([shift={(-\URX,0)}]\WIDTH,-\DEPTH+\LLY); |
| 2340 |
\draw [->] (\LLX+.2\WIDTH,-\DEPTH+\LLY) -- (\LLX+.2\WIDTH,0) node [right,midway] {\scriptsize moves down}; |
| 2341 |
\path [fill=white,draw] (\LLX,-\DEPTH+\LLY) circle (1pt); |
| 2342 |
\end{scope} |
| 2343 |
\begin{scope}[blue!50!black] %,every node/.append style={inner sep=2pt}] |
| 2344 |
\draw [->] (\LLX,0) -- (\LLX,\LLY-\DEPTH) node [right,midway] {\scriptsize lly}; |
| 2345 |
\draw [->] (0,-\DEPTH+\LLY) -- ++(\LLX,0) node [above,midway] {\scriptsize llx}; |
| 2346 |
\draw [->] |
| 2347 |
([shift={(-\URX,0)}]\WIDTH,0) -- |
| 2348 |
([shift={(-\URX,-\URY)}]\WIDTH,\HEIGHT) |
| 2349 |
node [right,midway] {\scriptsize ury} |
| 2350 |
; |
| 2351 |
\draw [->] |
| 2352 |
([shift={(0,-\URY)}]0,\HEIGHT) -- |
| 2353 |
([shift={(-\URX,-\URY)}]\WIDTH,\HEIGHT) |
| 2354 |
node [above,midway] {\scriptsize urx} |
| 2355 |
; |
| 2356 |
\end{scope} |
| 2357 |
% Box |
| 2358 |
\draw [thick] (0,-\DEPTH) rectangle (\WIDTH,\HEIGHT); |
| 2359 |
% Origin |
| 2360 |
\path [fill=white,draw=black] (0,0) circle (1pt); |
| 2361 |
% Center inner box |
| 2362 |
\path let |
| 2363 |
\p1 = (current bounding box.south west), |
| 2364 |
\p2 = (current bounding box.north east), |
| 2365 |
\p3 = (0,-\DEPTH), |
| 2366 |
\p4 = (\WIDTH,\HEIGHT) |
| 2367 |
in |
| 2368 |
(\x3-\x2+\x4,\y3) rectangle (\x4+\x3-\x1,\y4); |
| 2369 |
\end{tikzpicture} |
| 2370 |
%<*standalone> |
| 2371 |
\end{document} |
| 2372 |
%</standalone> |
| 2373 |
% \iffalse |
| 2374 |
%</viewport.tex> |
| 2375 |
% \fi |
| 2376 |
% |