Debian Codegraph @

texmf-dist/source/latex/ushort/ushort.dtx

raw
1 % \def\fileversion{2.2}\def\filedate{2001/06/13}\def\docdate{2013/11/26}
2 %\iffalse These lines are necessary for the doc and docstrip utilities
3 %<*asciidocu>
4
5 %%#
6 %%# Author:
7 %%#
8 %%# M. V\"ath [email protected]
9 %%#
10 %%# The package may be distributed and/or modified under the conditions of
11 %%# the LaTeX Project Public License (version 1.3c or later).
12
13 %%#############################################################################
14 %%#
15 %%# With this package you may write shorter (or longer) underlines/underbars.
16 %%# This is particularly useful for `underlined' variables which are needed
17 %%# by some engineers.
18 %%#
19 %%#############################################################################
20
21 %%#
22 %%# This package was tested with plain TeX, LaTeX 2.09, and LaTeX 2e,
23 %%# and it should actually run with most other TeX formats.
24 %%#
25
26 % If you have access to (reasonable new) docstrip TeXfiles, you should run
27 % tex/latex on the file
28 % `ushort.ins'
29 % to produce the files `ushort.sty', `ushort.txt' and `ushort.tex'.
30 % (In case `ushort.ins' is lost: You can find its content in the last
31 % few lines of the file you are currently reading between the
32 % lines %<*insfile> and %</insfile>;
33 % BTW: You should name this file here `ushort.dtx' before you run tex
34 % on ushort.ins).
35 %
36 % The file `ushort.txt' contains a `brief' (but complete) ascii
37 % documentation. If you have additionally access to LaTeX2e, you may run
38 % latex on the generated file `ushort.tex' to produce `ushort.dvi' which
39 % contains a more luxury documentation.
40 %
41 % If you do not have access to the docstrip TeXfiles you may simply
42 % copy/rename this file here into
43 % `ushort.sty'
44 % to use the package and read the ascii documentation in this file.
45 % The ascii documentation (the content of `ushort.txt') consists of all
46 % lines in this file which start with %%# (this the above block and another
47 % (very large) block which follows soon).
48 %
49 % But I do not recommended this, because TeX will need more time to read this
50 % longer file, and because there might be a (very slight) incompatibility if
51 % you use it (namely if you load `ushort.sty' with some *extremely* strange
52 % catcodes).
53 % I recommend in this case instead to generate the file `ushort.sty' as
54 % anything between the lines %<*package> and %</package> by hand.
55 % (This is not precisely the file which you get with the docstrip TeXfiles,
56 % but a reasonable good substitute. To speed up loading, you may also
57 % eliminate all lines starting with `% ' in `ushort.sty').
58 % For your information: The file `ushort.tex' produced by the docstrip
59 % TeXfiles is anything between the lines %<*driver> and %</driver>
60 % (with a line containing \endinput and two comment lines appended).
61 %
62 %
63 % In any case, you end up with the file `ushort.sty'.
64 %
65 % If you can generate `ushort.tex', you will probably want to stop
66 % reading now and instead read the `luxury' documentation in `ushort.dvi'.
67 %
68 % Otherwise, you have to make due with the following ascii documentation.
69 %
70 %
71 % \fi\catcode\#14\relax\iffalse (This line is needed for the doc utility)
72 %
73
74 %%# In the newsgroup de.comp.text.tex the question arose whether it is
75 %%# possible to define `underlined' variables: Such variables are required for
76 %%# complex vectors by electrical engineers.
77 %%# The usual \underline command is not appropriate for this purpose, because
78 %%# the underlines of concatenated variables merge which is not desired.
79 %%# One may use the macro "\ushort" of this package instead.
80 %%#
81 %%# However, this package also provides a generic macro which allows to
82 %%# create new commands which work similarly but use different parameters
83 %%# for the underlines. In particular, it is possible to create e.g. a macro
84 %%# which draws longer underlines than usual or which does a similar task with
85 %%# \underbar.
86
87 %%#
88 %%# Installation:
89 %%#
90
91 %%# To use ushort, you have to put `ushort.sty' in a path where TeX looks
92 %%# for its input files. The TeX documents using ushort need the
93 %%# following modifications in their header:
94 %%#
95 %%# a) If you use LaTeX2.09, use ushort as a style option, e.g.
96 %%# \documentstyle[ushort]{article}
97 %%# or
98 %%# \documentstyle[ushort,12pt]{article}
99 %%# b) If you use LaTeX2e, put in the preamble the command
100 %%# \usepackage{ushort}
101 %%# c) If you use some other (non-LaTeX) format, you will probably have to
102 %%# insert a line like
103 %%# \catcode`\@=11\relax \input ushort.sty \catcode`\@=12\relax
104 %%#
105 %%# For TeX insiders:
106 %%# The only LaTeX-specific commands used in `ushort.sty' are:
107 %%#
108 %%# \newcommand (only in the form \newcommand{\command}{} to ensure that
109 %%# \command was not defined before)
110 %%# \ProvidesPackage
111 %%# \typeout
112 %%#
113 %%# The above commands are used only if they are defined.
114 %%#
115
116 %%#
117 %%# Description of the provided macros:
118 %%#
119
120 %%# This package provides the following macros.
121 %%#
122 %%# \ushort
123 %%# This command is used analogously to \underline with the difference that
124 %%# the underlines are slightly shorter than usual (and so, in particular,
125 %%# in concatenations of `\ushort'ed variable names the underlines do not
126 %%# merge). The length of the underline is chosen under the assumption that
127 %%# the argument is a single character. If you want to underline a variable
128 %%# name which consists of more than one character, use instead the command
129 %%# \ushortw [Mnemonic: ushort word]
130 %%# which is analogous to \ushort but such that the length of the underline
131 %%# is chosen appropriate for a `long' argument. (This does not look as
132 %%# good as \ushort if the argument is a single character).
133 %%# \ushortd [Mnemonic: ushort double]
134 %%# This is analogous to \ushort except that the underline is doubled.
135 %%# \ushortdw [Mnemonic: ushortd word]
136 %%# This is analogous to \ushortw except that the underline is doubled.
137 %%# \ushortdline
138 %%# This is analogous to \underline except that the underline is doubled.
139 %%# This command is internally used by \ushortd and \ushortdw and
140 %%# thus redefinitions change also the behavior of \ushortd and \ushortdw
141 %%# correspondingly.
142 %%# In Plain TeX, this macro can be used only in math mode.
143 %%# \ushortCreate
144 %%# This can be used to generate a macro which behaves similarly to \ushort
145 %%# or \ushortd but for which certain parameters can be changed.
146 %%# \ushortEnsuremath
147 %%# This is rather equivalent to the LaTeX2e macro \ensuremath
148 %%# (but is available also e.g. in compatibility mode or if this package
149 %%# is used with plain TeX or LaTeX 2.09).
150 %%#
151 %%# Only \ushortCreate needs a detailed description. Its call syntax is:
152 %%#
153 %%# \ushortCreate*:\command[Summand]<FactorBefore>(FactorAfter)
154 %%# +{additional calculations}{Name}
155 %%#
156 %%# All arguments except for the last one {Name} are optional.
157 %%# Moreover, also the order of these arguments can be changed arbitrarily,
158 %%# and they can be repeated (all except for the last occurrence of each
159 %%# each type of argument is ignored).
160 %%# Only the last argument {Name} can not be repeated and must be at the end.
161 %%#
162 %%# This command creates a new macro \Name. It is not tested whether \Name
163 %%# already exists; if it exists already, it is overridden. In particular,
164 %%# it is admissible to use \ushortCreate to redefine \ushort, \ushortw,
165 %%# \ushortd, or \ushortdw. This is the recommended method, if you want to
166 %%# change the default values.
167 %%#
168 %%# The macro \Name can be used analogously to \underline, but the precise
169 %%# behavior depends on the arguments of \ushortCreate.
170 %%#
171 %%# The meaning of the arguments is as follows:
172 %%#
173 %%# * If the * is present, then the command \underbar is used
174 %%# (instead of the default \underline) to draw the underline.
175 %%# Moreover, the command \underbar is not used in math mode (while
176 %%# \underline is used in math mode).
177 %%# :\command Use \command instead of the default \underline to draw the
178 %%# underline. Whether \command is executed in math mode or not
179 %%# depends on whether * has been used.
180 %%# [Summand] Add Summand to the length of the underline before drawing.
181 %%# Values like -.3\ht0 are admissible. Summand is expanded only when \Name
182 %%# is expanded, and \wd0 or \ht0 give the width respectively height of the
183 %%# argument given to \name. In particular, also the value of the unit `em'
184 %%# depends on the mode in which \Name is called.
185 %%# The default is empty (which means 0pt but is faster).
186 %%# <FactorBefore> Multiply the length of the underline before adding Summand.
187 %%# The empty string means 1 (and costs no time).
188 %%# The default is empty.
189 %%# (FactorAfter) Multiply the length of the underline after adding Summand.
190 %%# The empty string means 1 (and costs no time).
191 %%# The default is `.8'.
192 %%# +{Additional calculations} With this argument, you can introduce an
193 %%# arbitrary command sequence into the generated command: This sequence
194 %%# is executed (within a group) after Summand was added, but before
195 %%# FactorAfter is applied. This sequence is meant to do additional
196 %%# calculation with \dimen0 which is the length of the generated
197 %%# underline. When the calculations are carried out, \box0 contains the
198 %%# content which is to be underlined. However, in contrast to previous
199 %%# releases of this package, modifications of this box are ignored.
200 %%# Instead, the registers \dimen1 and \dimen2 also contain the height and
201 %%# depth of this box - you have to modify these values to attain the
202 %%# desired effect.
203 %%#
204 %%# Examples:
205 %%#
206 %%# The most important examples are the macros \ushort, \ushortw, \ushortd,
207 %%# and \ushortdw which have been created by
208 %%#
209 %%# \ushortCreate{ushort}
210 %%# \ushortCreate()[-.1em]{ushortw}
211 %%# \ushortCreate:\ushortdline{ushortd}
212 %%# \ushortCreate:\ushortdline()[-.1em]{ushortdw}
213 %%#
214 %%# A further example demonstrating other parameters is
215 %%#
216 %%# \ushortCreate(3)(.5){uline}
217 %%#
218 %%# This creates the macro \uline which underbars its argument but such that
219 %%# the underbar has only half of the usual length (the argument (3)
220 %%# in the above call is overridden by the later argument (.5)).
221 %%#
222 %%# A more useful example is
223 %%#
224 %%# \ushortCreate()[-.3\ht0]{ushort}
225 %%#
226 %%# This modifies \ushort such that the underline is shrunken by .3 times
227 %%# the height of the argument of \ushort. If the argument is one letter, this
228 %%# means: The higher the letter, the shorter the underline. This looks good
229 %%# for italic fonts with some exceptions (like the letter `b').
230
231 % This is the end of the ascii documentation
232 %</asciidocu>
233 %\fi\catcode\#6\relax
234 %
235 % \iffalse
236 %<*metainfo>
237 % \fi
238
239 % \def\basename{ushort}
240
241 %% \CharacterTable
242 %% {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
243 %% 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
244 %% Digits \0\1\2\3\4\5\6\7\8\9
245 %% Exclamation \! Double quote \" Hash (number) \#
246 %% Dollar \$ Percent \% Ampersand \&
247 %% Acute accent \' Left paren \( Right paren \)
248 %% Asterisk \* Plus \+ Comma \,
249 %% Minus \- Point \. Solidus \/
250 %% Colon \: Semicolon \; Less than \<
251 %% Equals \= Greater than \> Question mark \?
252 %% Commercial at \@ Left bracket \[ Backslash \\
253 %% Right bracket \] Circumflex \^ Underscore \_
254 %% Grave accent \` Left brace \{ Vertical bar \|
255 %% Right brace \} Tilde \~}
256
257 % \CheckSum{272}
258
259 % \iffalse
260 % \RecordChanges
261 % \fi
262 % \def\ChangesTab{\def\mypar{\par}}\let\orichanges\changes
263 % \def\changes#1#2#3{\orichanges{#1}{#2}{#3}\relax
264 % \expandafter\def\expandafter\ChangesTab\expandafter{\ChangesTab
265 % \item[v#1 {\mdseries(\emph{#2})}] {#3.}}}
266 % \newcommand{\cmdcite}[1]{\texttt{\textbackslash#1}}
267 % \def\mypar{}
268
269 % \changes{2.2}{2013/11/26}{Update email, add license. Date/version remains the
270 % same since only commments and documentation are modified}
271 % \changes{2.2}{2001/06/13}{As
272 % Alessandro Russo \texttt{<[email protected]>} suggested,
273 % the case of arguments consisting of more than a single character is
274 % now documented. Corresponding macros \cmdcite{ushortw} and
275 % \cmdcite{ushortdw} have been added}
276 % \changes{2.1}{2001/06/07}{Improved speed dramatically (up to factor 4)
277 % by not using \cmdcite{phantom} anymore. Unfortunately, if bad hacks had
278 % been used for the argument ``Additional calculations'' in
279 % \cmdcite{ushortCreate}, they could fail to work now. For this reason,
280 % the major release number has been changed.\mypar
281 % Further internal change: In \cmdcite{ushrt@Main} the arguments are now
282 % expanded by a loop}
283 % \changes{1.4}{2001/04/06}{Set defaults for the parameters as documented}
284 % \changes{1.3}{2001/04/05}{Added the argument for additional calculations.
285 % Changed the default values of the arguments (and thus of \cmdcite{ushort})}
286 % \changes{1.2}{2001/04/04}{Removed a typing error in the scan macro and
287 % added the commands \cmdcite{ushortd} and \cmdcite{ushortdline}}
288 % \changes{1.1}{2001/04/04}{Introduced clean version of
289 % \cmdcite{ushortEnsuremath} (and eliminated the corresponding previous hack)}
290 % \changes{1.0}{2001/04/03}{First beta release}
291 %
292 % \iffalse
293 %
294 % The following part is the code needed to compile the documentation.
295 % We do some trickery here, because we want that this file here could be used
296 % for *both*: Compiling the documentation *and* as `ushort.sty'
297 % (if really required).
298 % Everything between the lines %<*driver> and %</driver>
299 % goes to the file `ushort.tex'.
300 %
301 % \fi
302 \ifcat @a% If this test is positive, then `@' has letter catcode which means
303 % that this file is loaded as a style file (or as described in the
304 % install section of the documentation).
305 \def\TemporaryDummy{}
306 \else\long\def\TemporaryDummy{%
307 %
308 %
309 % \iffalse
310 %</metainfo>
311 %<*driver>
312 \documentclass{ltxdoc}
313 \OnlyDescription%% Comment this out, or
314 %%\AlsoImplementation%% uncomment this line, if you want to see the source.
315
316 %% If you want an index, uncomment one of the following lines.
317 %% After running latex a first time, you have to use
318 %% makeindex -s gind.ist ushort
319 %% Then run latex again.
320 %%\CodelineIndex% comment this out if you want an index referring to codelines
321 %%\PageIndex% comment this out if you want an index referring to pages
322 %%\OldMakeindex% uncomment this line, if your MakeIndex is pre-v2.9
323
324 \setlength\hfuzz{15pt}
325 \hbadness=7000
326 \begin{document}
327 \DocInput{ushort.dtx}
328 \end{document}
329 %</driver>
330 %<*metainfo>
331 % \fi
332 }
333 \fi\TemporaryDummy\let\TemporaryDummy\undefined
334 %
335 % \iffalse
336 % Personal macros used for the doc utility:
337 % \fi
338 % \MakeShortVerb{"}
339 % \def\bracemeta#1{\texttt{\{}\meta{#1}\texttt{\}}}
340 % \def\DescMac#1{\expandafter\DescribeMacro\expandafter{\csname#1\endcsname}}
341 % \def\iDescribe#1{\item[\mdseries\cmdcite{#1}:]\DescMac{#1}}
342 % \def\nocomment{}
343 % \parindent0pt
344
345 % \title{The \texttt{ushort} package\thanks
346 % {This package has version number \fileversion{}, last revised \filedate.
347 % The package may be distributed and/or modified under the conditions of the
348 % LaTeX Project Public License, either version 1.3c of this license or (at
349 % your option) any later version. The latest version of this license is in
350 % \texttt{http://www.latex-project.org/lppl.txt}, and version 1.3c or later
351 % is part of all distributions of LaTeX version 2005/12/01 or later.}}
352 % \author{Martin V\"ath\thanks
353 % {\texttt{[email protected]}}}
354 % \date{\docdate}
355 % \maketitle
356
357 % \begin{abstract}
358 % With this package you may write shorter (or longer) underlines/underbars.
359 % This is particularly useful for `underlined' variables which are needed
360 % by some engineers.
361 % \end{abstract}
362
363 % You may copy this package freely, as long as you distribute only unmodified
364 % and complete versions.
365
366 % \tableofcontents
367
368 % \section{Changes}
369 %
370 % \begin{description}
371 % \ChangesTab
372 % \end{description}
373
374 % \section{Introduction}
375 %
376 % In the newsgroup "de.comp.text.tex" the question arose whether it is
377 % possible to define `underlined' variables: Such variables are required for
378 % complex vectors by electrical engineers.
379 % The usual "\underline" command is not appropriate for this purpose, because
380 % the underlines of concatenated variables merge which is not desired.
381 % One may use the macro "\ushort" of this package instead.
382 %
383 % However, this package also provides a generic macro which allows to
384 % create new commands which work similarly but use different parameters
385 % for the underlines. In particular, it is possible to create e.g.\ a macro
386 % which draws longer underlines than usual or which does a similar task with
387 % "\underbar".
388
389 % \section{Installation}
390
391 % This package was tested with plain \TeX, \LaTeX 2.09, and \LaTeXe, and it
392 % should actually run with most other \TeX\ formats.
393
394 % To use ``ushort'', you have to put the file "ushort.sty" in a path where
395 % \TeX\ looks for its input files. The \TeX\ documents using ushort need the
396 % following modifications in their header:
397 %
398 % \begin{itemize}
399 % \item If you use \LaTeXe, put in the preamble the command
400 % \begin{verbatim}
401 % \usepackage{ushort}\end{verbatim}
402 %
403 % \item If you use \LaTeX 2.09, use "ushort" as a style option, e.g.\
404 % \begin{verbatim}
405 % \documentstyle[ushort]{article}\end{verbatim}
406 % or
407 % \begin{verbatim}
408 % \documentstyle[ushort,12pt]{article}\end{verbatim}
409 %
410 % \item If you use some other (non-\LaTeX) format, you will probably have to
411 % insert a line like
412 % \begin{verbatim}
413 % \catcode`\@=11\relax \input ushort.sty \catcode`\@=12\relax\end{verbatim}
414 %
415 % \end{itemize}
416 %
417 % For \TeX\ insiders:
418 % The only \LaTeX-specific commands used in "ushort.sty" are:
419 %
420 % \begin{itemize}
421 % \item "\newcommand" (used only in the form "\newcommand{"\meta{command}"}{}"
422 % to ensure that \meta{command} was not defined before)
423 % \item "\ProvidesPackage"
424 % \item "\typeout"
425 % \end{itemize}
426 % The above commands are used only if they are defined
427 % (for "\typeout" a reasonable substitute is used, otherwise).
428
429 %
430 % \section{Description of the provided macros}
431 %
432 % This package provides the following macros.
433 % \begin{description}
434 % \iDescribe{ushort}
435 % This command is used analogously to
436 % "\underline" with the difference that the underlines are slightly shorter
437 % than usual (and so, in particular, in concatenations of "\ushort"'ed
438 % variable names the underlines do not merge).
439 % The length of the underline is chosen under the assumption that
440 % the argument is a single character. If you want to underline a variable
441 % name which consists of more than one character, use instead the
442 % following command "\ushortw".
443 % \iDescribe{ushortw} (Mnemonic: ``ushort word'').
444 % This command is analogous to "\ushort" but such that the length of the
445 % underline is chosen appropriate for a `long' argument. (This does not
446 % look as good as "\ushort" if the argument is a single character).
447 % \iDescribe{ushortd} (Mnemonic: ``ushort double'').
448 % This is analogous to "\ushort" except that the underline is doubled.
449 % \iDescribe{ushortdw} (Mnemonic: ``ushortd word'').
450 % This is analogous to "\ushortd" except that the underline is doubled.
451 % \iDescribe{ushortdline}
452 % This is analogous to "\underline" except that the underline is doubled.
453 % This command is internally used by "\ushortd" and "\ushortdw",
454 % and thus redefinitions change also the behavior of "\ushortd" and
455 % "\ushortdw" correspondingly.
456 % In Plain \TeX, this macro can be used only in math mode.
457 % \iDescribe{ushortCreate}
458 % This can be used to generate a macro which behaves similarly to "\ushort"
459 % or "\ushortd" but for which certain parameters can be changed.
460 % For a detailed description, see below.
461 % \iDescribe{ushortEnsuremath}
462 % This is rather equivalent to the \LaTeXe\ macro "\ensuremath"
463 % (but is available also e.g.\ in compatibility mode or if this package
464 % is used with plain \TeX\ or \LaTeX 2.09).
465 % \end{description}
466 %
467 % Only "\ushortCreate" needs a detailed description. Its call syntax is:
468 % \begin{quote}
469 %"\ushortCreate*:\"\meta{command}"["\meta{summand}"]<"\meta{factor before}">"\\
470 %" "\relax
471 %"("\meta{factor after}")+"\bracemeta{additional calculations}\bracemeta{name}
472 % \end{quote}
473 %
474 % All arguments except for the last one \bracemeta{name} are optional.
475 % Moreover, also the order of these arguments can be changed arbitrarily,
476 % and they can be repeated (all except for the last occurrence of each
477 % each type of argument is ignored).
478 % Only the last argument \bracemeta{name} can not be repeated and must be at
479 % the end.
480 %
481 % This command creates a new macro \textbackslash\meta{name}.
482 % It is not tested whether \textbackslash\meta{name} already exists;
483 % if it exists already, it is overridden. In particular,
484 % it is admissible to use "\ushortCreate" to redefine "\ushort", "\ushortw",
485 % "\ushortd", or "\ushortdw". This is the recommended method, if you want to
486 % change the default values.
487 %
488 % The macro \textbackslash\meta{name} can be used analogously to "\underline",
489 % but the precise behavior depends on the arguments of "\ushortCreate".
490 %
491 % The meaning of the arguments is as follows:
492 %
493 % \begin{description}
494 % \item[\mdseries\texttt*]
495 % If the "*" is present, then the command "\underbar" is used
496 % (instead of the default "\underline") to draw the underline.
497 % Moreover, the command "\underbar" is not used in math mode (while
498 % "\underline" is used in math mode).
499 % \item[\mdseries\texttt:\textbackslash\meta{command}]
500 % Use \textbackslash\meta{command} instead of the default "\underline" to
501 % draw the underline. Whether \textbackslash\meta{command} is executed in
502 % math mode or not depends on whether "*" has been used.
503 % \item[\mdseries\texttt{[}\meta{summand}\texttt{]}]
504 % Add \meta{summand} to the length of the underline before drawing.
505 % Values like "-.3\ht0" are admissible.
506 % \meta{summand} is expanded only when \textbackslash\meta{name} is
507 % expanded, and "\wd0" or "\ht0" give the width respectively height of the
508 % argument given to "\name". In particular, also the value of the unit "em"
509 % depends on the mode in which \textbackslash\meta{name} is called.
510 % The default is empty (which means "0pt" but is faster).
511 % \item[\mdseries\texttt{<}\meta{factor before}\texttt{>}]
512 % Multiply the length of the underline before adding \meta{summand}.
513 % The empty string means $1$ (and costs no time).
514 % The default is empty.
515 % \item[\mdseries\texttt{(}\meta{factor after}\texttt{)}]
516 % Multiply the length of the underline after adding \meta{summand}.
517 % The empty string means $1$ (and costs no time).
518 % The default is "0.8".
519 % \item[\mdseries\texttt+\bracemeta{Additional calculations}]
520 % With this argument, you can introduce an arbitrary command sequence into
521 % the generated command: This sequence is executed (within a group) after
522 % \meta{summand} was added, but before \meta{factor after} is applied.
523 % This sequence is meant to do additional calculation with "\dimen0" which
524 % is the length of the generated underline.
525 % When the calculations are carried out, "\box0" contains the
526 % content which is to be underlined. However, in contrast to previous
527 % releases of this package, modifications of this box are ignored.
528 % Instead, the registers "\dimen1" and "\dimen2" also contain the height
529 % and depth of this box -- you have to modify these values to attain the
530 % desired effect.
531 % \end{description}
532 %
533 % Examples:
534 % The most important examples are the macros "\ushort", "\ushortw",
535 % "\ushortd", and "\ushortdw" which have been created by
536 % \begin{verbatim}
537 % \ushortCreate{ushort}
538 % \ushortCreate()[-.1em]{ushortw}
539 % \ushortCreate:\ushortdline{ushortd}
540 % \ushortCreate:\ushortdline()[-.1em]{ushortdw}\end{verbatim}
541 % A further example demonstrating other parameters is
542 % \begin{verbatim}
543 % \ushortCreate*(3)(.5){uline}\end{verbatim}
544 % This creates the macro "\uline" which underbars its argument but such that
545 % the underbar has only half of the usual length (the argument "(3)" in
546 % the above call is overridden by the later argument "(.5)").\par
547 % A more useful example is
548 % \begin{verbatim}
549 % \ushortCreate()[-.3\ht0]{ushort}\end{verbatim}
550 % This modifies "\ushort" such that the underline is shrunken by $.3$ times
551 % the height of the argument of "\ushort". If the argument is one letter, this
552 % means: The higher the letter, the shorter the underline. This looks good
553 % for italic fonts with some exceptions (like the letter "b").
554
555
556 % \iffalse
557 %</metainfo>
558 % \fi
559 % \iffalse--------------------------------------------------------------\fi
560 % \StopEventually{\PrintChanges}
561 % \section{Implementation}
562 %
563 % \iffalse--------------------------------------------------------------
564 %
565 %
566 %<*package>
567 % \fi
568 % \begin{macrocode}
569 %%
570 %% This file was generated by the docstrip utility from ushort.dtx.
571 %% You may distribute this file only together with the source ushort.dtx
572 %% (and if possible with ushort.ins) and only if these files are unmodified.
573 %%
574 %% Author:
575 %%
576 %% M. V\"ath [email protected]
577 %%
578
579 \ifx\typeout\undefined
580 \def\ushrt@tmp{\immediate\write17}
581 \else
582 \let\ushrt@tmp\typeout
583 \fi
584 \ushrt@tmp{ushort.sty by M. Vaeth: Release: 2.2 }
585
586 %% First, some LaTeX support:
587
588 \ifx\ProvidesPackage\undefined\else
589 \ProvidesPackage{ushort}[2001/06/13 v2.2]
590 \fi
591
592 \ifx\newcommand\undefined\else
593 \newcommand{\ushort}{}
594 \newcommand{\ushortw}{}
595 \newcommand{\ushortd}{}
596 \newcommand{\ushortdw}{}
597 \newcommand{\ushortdline}{}
598 \newcommand{\ushortCreate}{}
599 \newcommand{\ushortEnsuremath}{}
600 \fi
601
602 %% The implementation follows
603
604 % \end{macrocode}
605 %
606 % \begin{macro}{\ushortCreate}
607 % We first scan the parameters into various macros. Then we call "\ushrt@Main".
608 % \begin{macrocode}
609 \def\ushortCreate{\let\ushrt@calc\ushrt@empty\let\ushrt@TextMode\undefined
610 \def\ushrt@FactorAfter{0.8}\let\ushrt@FactorBefore\ushrt@calc
611 \let\ushrt@Summand\ushrt@empty\def\ushrt@cmd{\underline}\ushrt@TestLoop}
612 \def\ushrt@TestLoop{\ushrt@TestAndExec*\ushrt@Star\ushrt@TestCommand}
613 \def\ushrt@Star*{\def\ushrt@cmd{\underbar}\let\ushrt@TextMode\ushrt@empty
614 \ushrt@TestLoop}
615 \def\ushrt@TestCommand{\ushrt@TestAndExec:\ushrt@GetCommand\ushrt@TestCalc}
616 \def\ushrt@GetCommand:#1{\def\ushrt@cmd{#1}\ushrt@TestLoop}
617 \def\ushrt@TestCalc{\ushrt@TestAndExec+\ushrt@GetCalc\ushrt@TestSummand}
618 \def\ushrt@GetCalc+#1{\def\ushrt@calc{#1}\ushrt@TestLoop}
619 \def\ushrt@TestSummand{\ushrt@TestAndExec[%]
620 \ushrt@GetSummand\ushrt@TestFactorBefore}
621 \def\ushrt@GetSummand[#1]{\def\ushrt@Summand{\advance\dimen0 by#1}%
622 \ushrt@TestLoop}
623 \def\ushrt@TestFactorBefore{\ushrt@TestAndExec<%>
624 \ushrt@GetFactorBefore\ushrt@TestFactorAfter}
625 \def\ushrt@GetFactorBefore<#1>{\def\ushrt@FactorBefore{#1}\ushrt@TestLoop}
626 \def\ushrt@TestFactorAfter{\ushrt@TestAndExec(%)
627 \ushrt@GetFactorAfter\ushrt@Main}
628 \def\ushrt@GetFactorAfter(#1){\def\ushrt@FactorAfter{#1}\ushrt@TestLoop}
629
630 % \end{macrocode}
631 %
632 % \begin{macro}{\ushrt@TestAndExec}
633 % "\ushrt@TestAndExec" is a submacro needed to scan the parameters.
634 % \begin{macrocode}
635 \def\ushrt@TestAndExec#1#2#3{%
636 \ushrt@SkipAndExec{%
637 \ifx\ushrt@NextToken#1%
638 \def\ushrt@exec{#2}%
639 \else
640 \def\ushrt@exec{#3}%
641 \fi
642 \ushrt@exec}}
643 \def\ushrt@SkipAndExec#1{\def\ushrt@tmp{#1}\ushrt@skip}
644 \def\ushrt@skip{\futurelet\ushrt@NextToken\ushrt@tmp}
645
646 % \end{macrocode}
647 % \end{macro}
648 % \begin{macro}{\ushrt@Main}
649 % "\ushrt@Main" calls "\ushrt@Define" with appropriately expanded parameters.
650 % \begin{macrocode}
651 \def\ushrt@Main#1{\def\ushrt@exec{\ushrt@Define}\ushrt@ExpandLoop
652 \ushrt@cmd\ushrt@calc\ushrt@Summand\ushrt@FactorBefore\ushrt@FactorAfter
653 {\csname#1\endcsname}{\csname ushrt@#1\endcsname}{}}
654
655 % \end{macrocode}
656 % \begin{macro}{\ushrt@ExpandLoop}
657 % "\ushrt@ExpandLoop" expands successively the first token in each argument
658 % by precisely one level (until the empty argument is reached which marks
659 % the end of the argument list).
660 % The expanded arguments are put into "{...}" and added to the end of the
661 % content of "\ushrt@exec".
662 % When all arguments have been parsed, "\ushrt@exec" is executed.
663 % \begin{macrocode}
664 \def\ushrt@ExpandLoop#1{\def\ushrt@tmp{#1}%
665 \ifx\ushrt@tmp\ushrt@empty
666 \let\ushrt@tmp\ushrt@exec
667 \else
668 \let\ushrt@tmp\ushrt@ExpandLoop
669 \expandafter\ushrt@Expand\expandafter{#1}%
670 \fi\ushrt@tmp}
671 \def\ushrt@Expand#1{\expandafter
672 \def\expandafter\ushrt@exec\expandafter{\ushrt@exec{#1}}}
673
674 % \end{macrocode}
675 % \end{macro}
676 % \end{macro}
677 % \begin{macro}{\ushrt@Define}
678 % All arguments of "\ushrt@Define" must be expanded. The call syntax is:
679 % \begin{quote}
680 %"\ushrt@Define"\relax
681 %\bracemeta{underline command}\bracemeta{calculations}\bracemeta{summand}\\
682 %" "\relax
683 %\bracemeta{factor before}\bracemeta{factor after}"{\"\meta{name}"}"\relax
684 %"{\ushrt@"\meta{name}"}"
685 % \end{quote}
686 % Actually, \meta{summand} is not only the pure summand but the token sequence
687 % "\advance\dimen0 by"\meta{value}; \meta{summand} may also be empty.
688 % \begin{macrocode}
689 \def\ushrt@Define#1#2#3#4#5#6#7{%
690 \def#6##1{\ushortEnsuremath{\mathpalette#7{##1}##1}}%
691 \ifx\ushrt@TextMode\undefined
692 \def#7##1##2{\hbox to 0pt{{\mathsurround0pt$#1{%
693 {\setbox0\hbox{\mathsurround0pt$##1##2$}%
694 \dimen0=#4\wd0#3\dimen1\ht0\dimen2\dp0#2%
695 \setbox0\hbox to#5\dimen0{}\ht0\dimen1\dp0\dimen2%
696 \box0}}$\hss}}}%
697 \else
698 \def#7##1##2{\hbox to 0pt{#1{%
699 {\setbox0\hbox{\mathsurround0pt$##1##2$}%
700 \dimen0=#4\wd0#3\dimen1\ht0\dimen2\dp0#2%
701 \setbox0\hbox to#5\dimen0{}\ht0\dimen1\dp0\dimen2%
702 \box0}}\hss}}%
703 \fi}
704
705 % \end{macrocode}
706 % \end{macro}
707 % \end{macro}
708 %
709 % \begin{macro}{\ushortEnsuremath}
710 % Since "\ensuremath" does not work due to \LaTeXe's irritating test for
711 % compatibility mode (and in order to use this package also for plain \TeX\
712 % and \LaTeX 2.09), we must write our own "\ensuremath" command. The command
713 % "\relax" in the beginning is necessary, because otherwise our command would
714 % not work if it is the first command in e.g.\ an "{eqnarray}" environment.
715 % \begin{macrocode}
716 \def\ushortEnsuremath{\relax
717 \ifmmode
718 \let\ushrt@exec\ushrt@NoSwitch
719 \else
720 \let\ushrt@exec\ushrt@Switch
721 \fi\ushrt@exec}
722 \def\ushrt@NoSwitch#1{#1}
723 \def\ushrt@Switch#1{\relax$#1\relax$\relax}
724
725 % \end{macrocode}
726 % \end{macro}
727 %
728 % \begin{macro}{\ushrt@empty}
729 % We do not want to rely on the fact that "\empty" is defined as "{}", so
730 % we use our own definition.
731 % \begin{macrocode}
732 \def\ushrt@empty{}
733
734 % \end{macrocode}
735 % \end{macro}
736 % \begin{macro}{\ushort}
737 % "\ushort" is nothing else but an instance created by "\ushortCreate"
738 % with the default values.
739 % \begin{macrocode}
740 \ushortCreate{ushort}
741 % \end{macrocode}
742 % \end{macro}
743 % \begin{macro}{\ushortw}
744 % "\ushortw" is nothing else but an instance created by "\ushortCreate"
745 % where the default values are changed by omitting \meta{factor after} and
746 % by setting another value for \meta{summand}:
747 % \begin{macrocode}
748 \ushortCreate()[-.1em]{ushortw}
749 % \end{macrocode}
750 % \end{macro}
751 % \begin{macro}{\ushortd}
752 % "\ushortd" is nothing else but an instance created by "\ushortCreate"
753 % with the default values but the \textbackslash\meta{command} value
754 % "\ushortdline":
755 % \begin{macrocode}
756 \ushortCreate:\ushortdline{ushortd}
757 % \end{macrocode}
758 % \end{macro}
759 % \begin{macro}{\ushortdw}
760 % "\ushortdw" is nothing else but an instance created by "\ushortCreate"
761 % where the default values are modified as in "\ushortw" and "\ushortd":
762 % \begin{macrocode}
763 \ushortCreate:\ushortdline()[-.1em]{ushortdw}
764 % \end{macrocode}
765 % \end{macro}
766 % \begin{macro}{\ushortdline}
767 % "\ushortdline" in turn is very simple to implement:
768 % \begin{macrocode}
769 \def\ushortdline#1{\underline{\underline #1}}
770 % \end{macrocode}
771 % \end{macro}
772 %
773 %
774 % \iffalse
775 %</package>
776 % \fi
777 % \Finale\PrintIndex
778 %
779 %
780 %
781 % \iffalse
782 %<*metainfo>
783 % \fi
784 \iffalse -------------------------------------------------------------
785 %
786 % Just in case that for some reason the file `ushort.ins' got lost:
787 % The content of this file is between the lines %<*insfile> and %</insfile>.
788 %
789 %\iffalse
790 %</metainfo>
791 %<*insfile>
792 \def\batchfile{ushort.ins}
793 \input docstrip.tex
794 \keepsilent
795 \nopreamble
796 \generateFile{ushort.sty}{f}{\from{ushort.dtx}{package}}
797 \generateFile{ushort.txt}{f}{\from{ushort.dtx}{asciidocu}}
798 \generateFile{ushort.tex}{f}{\from{ushort.dtx}{driver}}
799 %%\generateFile{ushort.ins.dup}{f}{\from{ushort.dtx}{insfile}}
800
801 \Msg{***************************************************************}
802 \Msg{*}
803 \Msg{* To finish the installation you have to move the}
804 \Msg{* file 'ushort.sty' into a directory searched by TeX.}
805 \Msg{*}
806 \Msg{*}
807 \Msg{* Run the file ushort.tex through LaTeX to produce the}
808 \Msg{* documentation or read the ascii documentation in ushort.txt}
809 \Msg{*}
810 \Msg{*}
811 \Msg{***************************************************************}
812 \endbatchfile
813 %</insfile>
814 %<*metainfo>
815 % \fi
816 \fi
817 % \iffalse
818 %</metainfo>
819 % \fi
820 \endinput
821
822 %%% Local Variables:
823 %%% mode: latex
824 %%% TeX-master: "ushort.tex"
825 %%% End: