-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadjcalc.dtx
207 lines (205 loc) · 10.5 KB
/
adjcalc.dtx
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
% \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 adjcalc.dtx, adjustbox.ins
%% and the derived file adjcalc.sty.
%% It is part of the larger adjustbox bundle.
%%
%<=/COPYRIGHT>
% \fi
%
% \iffalse
%<*driver>
\ProvidesFile{adjcalc.dtx}[%
%<=*DATE>
2012/05/16
%<=/DATE>
%<=*VERSION>
v1.1
%<=/VERSION>
DTX file for the adjcalc package]
\documentclass[a4paper]{ydoc}[2011/11/16]
\usepackage{amsmath}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{fourier}
\usepackage{newverbs}
\MakeSpecialShortVerb\qverb\"
%\AtBeginDocument{\MakeShortMacroArgs\`\relax}
%\AtEndDocument{\DeleteShortVerb\`}
\GetFileInfo{adjcalc.dtx}
\usepackage{adjcalc}[\filedate]
\usepackage{tikz}
\normalmarginpar
%\EnableCrossrefs
%\CodelineIndex
%\RecordChanges
\OnlyDescription
\begin{document}
\DocInput{\jobname.dtx}
\PrintChanges
%\newpage\PrintIndex
\end{document}
%</driver>
% \fi
%
% \CheckSum{274}
%
% \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}{2011/11/16}{First version after extraction from \pkg{adjustbox} package.}
% \changes{v1.1}{2012/05/16}{Better separation from the \pkg{adjustbox} package. Added own manual.}
%
% \GetFileInfo{adjcalc.dtx}
%
% \DoNotIndex{\newcommand,\newenvironment,\def,\edef,\xdef,\gdef,\let}
% \bundle{adjustbox}
% \author{Martin Scharrer}
% \email{martin.scharrer@web.de}
% \ydocpdfsettings
% \maketitle
%
% \begin{abstract}
% This package provides macros to assign or to add algebraic expressions to \LaTeX lengths and counters.
% It either uses $\epsilon$-\TeX, the \pkg{calc} package or the \pkg{pgfmath} package internally to achieve this.
% This package is part of the \pkg{adjustbox} bundle and was originally part of the \pkg{adjustbox} package before
% it was extracted to a dedicated package.
% \end{abstract}
%
% \section{Introduction}
% \LaTeX\ lengths and counters can be set using \Macro\setlength and \Macro\setcounter,
% and values can be added to these using \Macro\addtoclength and \Macro\addtocounter, respectively.
% By default these macros await a single length or integer value to be assigned or added.
% However, often it is beneficial to use a short algebraic expression, like a sum of two values, instead.
% The \pkg{calc} package was created for this and redefines the above macros to parse the given expression.
% Another possibility is to use $\epsilon$-\TeX's \Macro\dimexpr or \Macro\glueexpr which also allows for
% several algebraic operations and is more efficient than the higher-level \pkg{calc} package.
% Finally PGF/TikZ provides a large math engine with the \pkg{pgfmath} package. It allows even
% for complicated functions like $\log$ or $\sin$. However, \pkg{pgfmath} is rather large, especially because
% with PGF v2.10 it cannot be loaded on its own due to a bug, which forces the whole \pkg{pgf} package to be loaded.
%
% Package authors which like to write macros which allow algebraic expressions for its length arguments
% now face the dilemma which math interface they should use. Either they exclude users which do not have an
% $\epsilon$-TeX distribution (even if they are very rare) or require to load a large package.
% This was the case with the \pkg{adjustbox} package and therefore own wrapper macros were used instead which
% will use one of the different math engine mentioned above.
% Because this functionality was deemed useful for other packages of the same and other authors it was
% extracted into the dedicated package \pkg{adjcalc}. The idea is that the user can choose the used math engine
% using package options.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \section{Package Options}\label{sec:options} ^^A (((
% The following options define the way length values are processed by the provided macros.
% The first group can be either used as package options and as local setting using \Macro\adjcalcset or as keys
% for \Macro\adjustbox or the \env{adjustbox} environment (but not for \Macro\includegraphics even if the \opt{export}
% option of \pkg{adjustbox} was used).
% The only difference between using them as package options or keys is that as package option they also load required packages.
% Therefore all keys used in the document should be used as package options first or the required packages must be loaded
% manually.
%
% \begin{description}\def\oitem#1{\item[{\normalfont\opt{#1}}]}
% \oitem{etex} Uses the $\epsilon$-\TeX\ primitive \Macro\glueexpr to parse length values. This allows for additions,
% subtractions as well as multiplications and devision by a numeric factor. See the official \pkg{etex\_man} document
% for more details. This setting is the default if $\epsilon$-\TeX\ is detected (which should be the case with all
% modern \LaTeX\ distributions).
% \oitem{calc} Uses the \pkg{calc} package to parse length values. It supports all operations mentioned for \opt{etex} and
% also some other operation like \Macro\widthof{<text>}.
% See the \pkg{calc} package manual for more details.
% This is the default setting if $\epsilon$-TeX is not detected.
% \oitem{pgfmath} Uses the \pkg{pgfmath} package of the \pkg{pgf} bundle to parse length values. It supports all basic
% numeric operations and also advanced mathematical functions.
% See the \pkg{pgf} manual for more details.
% Because the \pkg{pgfmath} package can't be loaded
% independently in the current version (v2.10) the whole \pkg{pgf} package will be loaded.
% \oitem{overwrite} This option will overwrite the standard macros with the macros of this package.
% This e.g.\ sets \Macro\setlength to be identical to \Macro\adjsetlength.
% Any package option used after \opt{overwrite} will still take affect before the redefinition,
% i.e.\ the order in which \opt{overwrite} is used is not meaningful.
% \oitem{defaultunit}\MacroArgs!{\hspace*{-1ex}}!'='<unit>\relax
% This sets the default unit used for macros and keys which allow for unit-less values,
% e.g.\ the \Key{trim} key of \Macro\adjustbox or the \Macro\trimbox macro of the \pkg{trimclip} package.
% The standard default unit is the same as for \Macro\includegraphics: "bp" (big points, PostScript points).
% However, for \LaTeX\ material \TeX\ normal unit "pt" (\TeX\ points) are better suited and will avoid rounding
% errors which otherwise get introduced by the internal conversion.
% The default unit is only used if the particular value is only a single number without unit,
% but not if any mathematical operations are used.
% If the special value |none| is used no default unit is applied and the internal check if the value is a single number
% is by-passed. This gives a small speed bonus and can be used to avoid potential issues with complex values.
% At this moment this setting will disable the default unit feature for the rest of the current group (i.e.\ all
% further \Macro\adjustbox keys or globally if used as a package option) and further usages of this option will
% have no affect. This might change in future versions of this package.
% \end{description}
%
% \noindent
% The following option can only be used as package option:
% \begin{description}\def\oitem#1{\item[{\normalfont\opt{#1}}]}
% \oitem{none} Disables the features of this package and makes all macros use the normal \LaTeX\ equivalents,
% e.g.\ \Macro\adjsetlength will expand to \Macro\setlength, etc.
% This option also disables any previous set option as well as any future use of \opt{overwrite}.
% \end{description}
%
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% \section{Macros}
%
% \DescribeMacro\adjcalcset{<key=value, \ldots>}
% This configuration macro allows to change the above mentioned options during the document.
% Any changes are only locally to the current group/environment.
% Please see the descriptions of the options for any limitations.
%
%
% \DescribeMacro\adjsetlength{<\textbackslash lengthmacro>}{<length expression>}
% \DescribeMacro\adjaddtolength{<\textbackslash lengthmacro>}{<length expression>}
% \DescribeMacro\adjsetcounter{<counter name>}{<integer expression>}
% \DescribeMacro\adjaddtocounter{<counter name>}{<integer expression>}
% These macros can be used to set and add to \LaTeX\ length registers and counters like with the normal
% macros \Macro\setlength, \Macro\addtolength, \Macro\setcounter and \Macro\addtocounter.
% However, these macros allow the use of algebraic expressions, like sums and multiplications, while
% the standard macros only await a single value.
%
%
% \DescribeMacro\adjsetlengthdefault{<\textbackslash lengthmacro>}{<length expression with or without unit>}
% This macro set the length macro but does also support length values without an explicit unit.
% If no unit is used the default unit set by the \opt{defaultunit} option is used. The initial default unit
% is `|bp|' (big points, i.e.\ PostScript/PDF points, 72bp=1inch).
%
%
% \StopEventually{}
% \clearpage
% \section{Implementation}
%
% \iffalse
%<@adjcalc.sty>
% \fi
%
% \Finale
% \endinput