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