summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/ushort/ushort.dtx
blob: 7ec998c7f742101050ca07712d07ffc6d54914ad (plain)
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
% \def\fileversion{2.2}\def\filedate{2001/06/13}\def\docdate{2013/11/26}
%\iffalse These lines are necessary for the doc and docstrip utilities
%<*asciidocu>

%%#
%%# Author:
%%#
%%# M. V\"ath      martin@mvath.de
%%#
%%# The package may be distributed and/or modified under the conditions of
%%# the LaTeX Project Public License (version 1.3c or later).

%%#############################################################################
%%#
%%#  With this package you may write shorter (or longer) underlines/underbars.
%%#  This is particularly useful for `underlined' variables which are needed
%%#  by some engineers.
%%#
%%#############################################################################

%%#
%%# This package was tested with plain TeX, LaTeX 2.09, and LaTeX 2e,
%%# and it should actually run with most other TeX formats.
%%#

% If you have access to (reasonable new) docstrip TeXfiles, you should run
% tex/latex on the file
%   `ushort.ins'
% to produce the files `ushort.sty', `ushort.txt' and `ushort.tex'.
% (In case `ushort.ins' is lost: You can find its content in the last
%  few lines of the file you are currently reading between the
%  lines %<*insfile> and %</insfile>;
%  BTW: You should name this file here `ushort.dtx' before you run tex
%  on ushort.ins).
%
% The file `ushort.txt' contains a `brief' (but complete) ascii
% documentation. If you have additionally access to LaTeX2e, you may run
% latex on the generated file `ushort.tex' to produce `ushort.dvi' which
% contains a more luxury documentation.
%
% If you do not have access to the docstrip TeXfiles you may simply
% copy/rename this file here into
%   `ushort.sty'
% to use the package and read the ascii documentation in this file.
% The ascii documentation (the content of `ushort.txt') consists of all
% lines in this file which start with %%# (this the above block and another
% (very large) block which follows soon).
%
% But I do not recommended this, because TeX will need more time to read this
% longer file, and because there might be a (very slight) incompatibility if
% you use it (namely if you load `ushort.sty' with some *extremely* strange
% catcodes).
% I recommend in this case instead to generate the file `ushort.sty' as
% anything between the lines %<*package> and %</package> by hand.
% (This is not precisely the file which you get with the docstrip TeXfiles,
% but a reasonable good substitute. To speed up loading, you may also
% eliminate all lines starting with `% ' in `ushort.sty').
% For your information: The file `ushort.tex' produced by the docstrip
% TeXfiles is anything between the lines %<*driver> and %</driver>
% (with a line containing \endinput and two comment lines appended).
%
%
% In any case, you end up with the file `ushort.sty'.
%
% If you can generate `ushort.tex', you will probably want to stop
% reading now and instead read the `luxury' documentation in `ushort.dvi'.
%
% Otherwise, you have to make due with the following ascii documentation.
%
%
% \fi\catcode\#14\relax\iffalse  (This line is needed for the doc utility)
%

%%# In the newsgroup de.comp.text.tex the question arose whether it is
%%# possible to define `underlined' variables: Such variables are required for
%%# complex vectors by electrical engineers.
%%# The usual \underline command is not appropriate for this purpose, because
%%# the underlines of concatenated variables merge which is not desired.
%%# One may use the macro "\ushort" of this package instead.
%%#
%%# However, this package also provides a generic macro which allows to
%%# create new commands which work similarly but use different parameters
%%# for the underlines. In particular, it is possible to create e.g. a macro
%%# which draws longer underlines than usual or which does a similar task with
%%# \underbar.

%%#
%%# Installation:
%%#

%%# To use ushort, you have to put `ushort.sty' in a path where TeX looks
%%# for its input files. The TeX documents using ushort need the
%%# following modifications in their header:
%%#
%%# a) If you use LaTeX2.09, use ushort as a style option, e.g.
%%#      \documentstyle[ushort]{article}
%%#    or
%%#      \documentstyle[ushort,12pt]{article}
%%# b) If you use LaTeX2e, put in the preamble the command
%%#      \usepackage{ushort}
%%# c) If you use some other (non-LaTeX) format, you will probably have to
%%#    insert a line like
%%#          \catcode`\@=11\relax \input ushort.sty \catcode`\@=12\relax
%%#
%%# For TeX insiders:
%%# The only LaTeX-specific commands used in `ushort.sty' are:
%%#
%%#   \newcommand (only in the form \newcommand{\command}{} to ensure that
%%#                 \command was not defined before)
%%#   \ProvidesPackage
%%#   \typeout
%%#
%%#   The above commands are used only if they are defined.
%%#

%%#
%%# Description of the provided macros:
%%#

%%# This package provides the following macros.
%%#
%%# \ushort
%%#     This command is used analogously to \underline with the difference that
%%#     the underlines are slightly shorter than usual (and so, in particular,
%%#     in concatenations of `\ushort'ed variable names the underlines do not
%%#     merge). The length of the underline is chosen under the assumption that
%%#     the argument is a single character. If you want to underline a variable
%%#     name which consists of more than one character, use instead the command
%%# \ushortw  [Mnemonic: ushort word]
%%#     which is analogous to \ushort but such that the length of the underline
%%#     is chosen appropriate for a `long' argument. (This does not look as
%%#     good as \ushort if the argument is a single character).
%%# \ushortd  [Mnemonic: ushort double]
%%#     This is analogous to \ushort except that the underline is doubled.
%%# \ushortdw [Mnemonic: ushortd word]
%%#     This is analogous to \ushortw except that the underline is doubled.
%%# \ushortdline
%%#     This is analogous to \underline except that the underline is doubled.
%%#     This command is internally used by \ushortd and \ushortdw and
%%#     thus redefinitions change also the behavior of \ushortd and \ushortdw
%%#     correspondingly.
%%#     In Plain TeX, this macro can be used only in math mode.
%%# \ushortCreate
%%#     This can be used to generate a macro which behaves similarly to \ushort
%%#     or \ushortd but for which certain parameters can be changed.
%%# \ushortEnsuremath
%%#     This is rather equivalent to the LaTeX2e macro \ensuremath
%%#     (but is available also e.g. in compatibility mode or if this package
%%#     is used with plain TeX or LaTeX 2.09).
%%#
%%# Only \ushortCreate needs a detailed description. Its call syntax is:
%%#
%%# \ushortCreate*:\command[Summand]<FactorBefore>(FactorAfter)
%%#              +{additional calculations}{Name}
%%#
%%# All arguments except for the last one {Name} are optional.
%%# Moreover, also the order of these arguments can be changed arbitrarily,
%%# and they can be repeated (all except for the last occurrence of each
%%# each type of argument is ignored).
%%# Only the last argument {Name} can not be repeated and must be at the end.
%%#
%%# This command creates a new macro \Name. It is not tested whether \Name
%%# already exists; if it exists already, it is overridden. In particular,
%%# it is admissible to use \ushortCreate to redefine \ushort, \ushortw,
%%# \ushortd, or \ushortdw. This is the recommended method, if you want to
%%# change the default values.
%%#
%%# The macro \Name can be used analogously to \underline, but the precise
%%# behavior depends on the arguments of \ushortCreate.
%%#
%%# The meaning of the arguments is as follows:
%%#
%%# *   If the * is present, then the command \underbar is used
%%#     (instead of the default \underline) to draw the underline.
%%#     Moreover, the command \underbar is not used in math mode (while
%%#     \underline is used in math mode).
%%# :\command  Use \command instead of the default \underline to draw the
%%#     underline. Whether \command is executed in math mode or not
%%#     depends on whether * has been used.
%%# [Summand]  Add Summand to the length of the underline before drawing.
%%#     Values like -.3\ht0 are admissible. Summand is expanded only when \Name
%%#     is expanded, and \wd0 or \ht0 give the width respectively height of the
%%#     argument given to \name. In particular, also the value of the unit `em'
%%#     depends on the mode in which \Name is called.
%%#     The default is empty (which means 0pt but is faster).
%%# <FactorBefore> Multiply the length of the underline before adding Summand.
%%#     The empty string means 1 (and costs no time).
%%#     The default is empty.
%%# (FactorAfter)  Multiply the length of the underline after adding Summand.
%%#     The empty string means 1 (and costs no time).
%%#     The default is `.8'.
%%# +{Additional calculations} With this argument, you can introduce an
%%#     arbitrary command sequence into the generated command: This sequence
%%#     is executed (within a group) after Summand was added, but before
%%#     FactorAfter is applied. This sequence is meant to do additional
%%#     calculation with \dimen0 which is the length of the generated
%%#     underline. When the calculations are carried out, \box0 contains the
%%#     content which is to be underlined. However, in contrast to previous
%%#     releases of this package, modifications of this box are ignored.
%%#     Instead, the registers \dimen1 and \dimen2 also contain the height and
%%#     depth of this box - you have to modify these values to attain the
%%#     desired effect.
%%#
%%# Examples:
%%#
%%# The most important examples are the macros \ushort, \ushortw, \ushortd,
%%# and \ushortdw which have been created by
%%#
%%#    \ushortCreate{ushort}
%%#    \ushortCreate()[-.1em]{ushortw}
%%#    \ushortCreate:\ushortdline{ushortd}
%%#    \ushortCreate:\ushortdline()[-.1em]{ushortdw}
%%#
%%# A further example demonstrating other parameters is
%%#
%%#    \ushortCreate(3)(.5){uline}
%%#
%%# This creates the macro \uline which underbars its argument but such that
%%# the underbar has only half of the usual length (the argument (3)
%%# in the above call is overridden by the later argument (.5)).
%%#
%%# A more useful example is
%%#
%%#    \ushortCreate()[-.3\ht0]{ushort}
%%#
%%# This modifies \ushort such that the underline is shrunken by .3 times
%%# the height of the argument of \ushort. If the argument is one letter, this
%%# means: The higher the letter, the shorter the underline. This looks good
%%# for italic fonts with some exceptions (like the letter `b').

%  This is the end of the ascii documentation
%</asciidocu>
%\fi\catcode\#6\relax
%
% \iffalse
%<*metainfo>
% \fi

% \def\basename{ushort}

%% \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         \~}

% \CheckSum{272}

% \iffalse
%   \RecordChanges
% \fi
% \def\ChangesTab{\def\mypar{\par}}\let\orichanges\changes
% \def\changes#1#2#3{\orichanges{#1}{#2}{#3}\relax
%   \expandafter\def\expandafter\ChangesTab\expandafter{\ChangesTab
%   \item[v#1 {\mdseries(\emph{#2})}] {#3.}}}
% \newcommand{\cmdcite}[1]{\texttt{\textbackslash#1}}
% \def\mypar{}

% \changes{2.2}{2013/11/26}{Update email, add license. Date/version remains the
%   same since only commments and documentation are modified}
% \changes{2.2}{2001/06/13}{As
%   Alessandro Russo \texttt{<russo@ian.pv.cnr.it>} suggested,
%   the case of arguments consisting of more than a single character is
%   now documented. Corresponding macros \cmdcite{ushortw} and
%   \cmdcite{ushortdw} have been added}
% \changes{2.1}{2001/06/07}{Improved speed dramatically (up to factor 4)
%   by not using \cmdcite{phantom} anymore. Unfortunately, if bad hacks had
%   been used for the argument ``Additional calculations'' in
%   \cmdcite{ushortCreate}, they could fail to work now. For this reason,
%   the major release number has been changed.\mypar
%   Further internal change: In \cmdcite{ushrt@Main} the arguments are now
%   expanded by a loop}
% \changes{1.4}{2001/04/06}{Set defaults for the parameters as documented}
% \changes{1.3}{2001/04/05}{Added the argument for additional calculations.
%   Changed the default values of the arguments (and thus of \cmdcite{ushort})}
% \changes{1.2}{2001/04/04}{Removed a typing error in the scan macro and
%   added the commands \cmdcite{ushortd} and \cmdcite{ushortdline}}
% \changes{1.1}{2001/04/04}{Introduced clean version of
% \cmdcite{ushortEnsuremath} (and eliminated the corresponding previous hack)}
% \changes{1.0}{2001/04/03}{First beta release}
%
% \iffalse
%
% The following part is the code needed to compile the documentation.
% We do some trickery here, because we want that this file here could be used
% for *both*: Compiling the documentation *and* as `ushort.sty'
% (if really required).
% Everything between the lines %<*driver> and %</driver>
% goes to the file `ushort.tex'.
%
% \fi
\ifcat @a% If this test is positive, then `@' has letter catcode which means
%          that this file is loaded as a style file (or as described in the
%          install section of the documentation).
\def\TemporaryDummy{}
\else\long\def\TemporaryDummy{%
%
%
% \iffalse
%</metainfo>
%<*driver>
\documentclass{ltxdoc}
\OnlyDescription%% Comment this out, or
%%\AlsoImplementation%% uncomment this line, if you want to see the source.

%% If you want an index, uncomment one of the following lines.
%% After running latex a first time, you have to use
%%      makeindex -s gind.ist ushort
%% Then run latex again.
%%\CodelineIndex% comment this out if you want an index referring to codelines
%%\PageIndex% comment this out if you want an index referring to pages
%%\OldMakeindex% uncomment this line, if your MakeIndex is pre-v2.9

\setlength\hfuzz{15pt}
\hbadness=7000
\begin{document}
\DocInput{ushort.dtx}
\end{document}
%</driver>
%<*metainfo>
% \fi
}
\fi\TemporaryDummy\let\TemporaryDummy\undefined
%
% \iffalse
%          Personal macros used for the doc utility:
% \fi
% \MakeShortVerb{"}
% \def\bracemeta#1{\texttt{\{}\meta{#1}\texttt{\}}}
% \def\DescMac#1{\expandafter\DescribeMacro\expandafter{\csname#1\endcsname}}
% \def\iDescribe#1{\item[\mdseries\cmdcite{#1}:]\DescMac{#1}}
% \def\nocomment{}
% \parindent0pt

% \title{The \texttt{ushort} package\thanks
%   {This package has version number \fileversion{}, last revised \filedate.
%   The package may be distributed and/or modified under the conditions of the
%   LaTeX Project Public License, either version 1.3c of this license or (at
%   your option) any later version. The latest version of this license is in
%   \texttt{http://www.latex-project.org/lppl.txt}, and version 1.3c or later
%   is part of all distributions of LaTeX version 2005/12/01 or later.}}
% \author{Martin V\"ath\thanks
%   {\texttt{martin@mvath.de}}}
% \date{\docdate}
% \maketitle

% \begin{abstract}
% With this package you may write shorter (or longer) underlines/underbars.
% This is particularly useful for `underlined' variables which are needed
% by some engineers.
% \end{abstract}

% You may copy this package freely, as long as you distribute only unmodified
% and complete versions.

% \tableofcontents

% \section{Changes}
%
% \begin{description}
%    \ChangesTab
% \end{description}

% \section{Introduction}
%
% In the newsgroup "de.comp.text.tex" the question arose whether it is
% possible to define `underlined' variables: Such variables are required for
% complex vectors by electrical engineers.
% The usual "\underline" command is not appropriate for this purpose, because
% the underlines of concatenated variables merge which is not desired.
% One may use the macro "\ushort" of this package instead.
%
% However, this package also provides a generic macro which allows to
% create new commands which work similarly but use different parameters
% for the underlines. In particular, it is possible to create e.g.\ a macro
% which draws longer underlines than usual or which does a similar task with
% "\underbar".

% \section{Installation}

% This package was tested with plain \TeX, \LaTeX 2.09, and \LaTeXe, and it
% should actually run with most other \TeX\ formats.

% To use ``ushort'', you have to put the file "ushort.sty" in a path where
% \TeX\ looks for its input files. The \TeX\ documents using ushort need the
% following modifications in their header:
%
% \begin{itemize}
% \item If you use \LaTeXe, put in the preamble the command
%   \begin{verbatim}
%     \usepackage{ushort}\end{verbatim}
%
% \item If you use \LaTeX 2.09, use "ushort" as a style option, e.g.\
%   \begin{verbatim}
%     \documentstyle[ushort]{article}\end{verbatim}
%    or
%   \begin{verbatim}
%     \documentstyle[ushort,12pt]{article}\end{verbatim}
%
% \item If you use some other (non-\LaTeX) format, you will probably have to
%    insert a line like
% \begin{verbatim}
% \catcode`\@=11\relax \input ushort.sty \catcode`\@=12\relax\end{verbatim}
%
% \end{itemize}
%
% For \TeX\ insiders:
% The only \LaTeX-specific commands used in "ushort.sty" are:
%
% \begin{itemize}
% \item "\newcommand" (used only in the form "\newcommand{"\meta{command}"}{}"
%       to ensure that \meta{command} was not defined before)
% \item "\ProvidesPackage"
% \item "\typeout"
% \end{itemize}
% The above commands are used only if they are defined
% (for "\typeout" a reasonable substitute is used, otherwise).

%
% \section{Description of the provided macros}
%
% This package provides the following macros.
% \begin{description}
% \iDescribe{ushort}
%   This command is used analogously to
%   "\underline" with the difference that the underlines are slightly shorter
%   than usual (and so, in particular, in concatenations of "\ushort"'ed
%   variable names the underlines do not merge).
%   The length of the underline is chosen under the assumption that
%   the argument is a single character. If you want to underline a variable
%   name which consists of more than one character, use instead the
%   following command "\ushortw".
% \iDescribe{ushortw} (Mnemonic: ``ushort word'').
%   This command is analogous to "\ushort" but such that the length of the
%   underline is chosen appropriate for a `long' argument. (This does not
%   look as good as "\ushort" if the argument is a single character).
% \iDescribe{ushortd} (Mnemonic: ``ushort double'').
%   This is analogous to "\ushort" except that the underline is doubled.
% \iDescribe{ushortdw} (Mnemonic: ``ushortd word'').
%   This is analogous to "\ushortd" except that the underline is doubled.
% \iDescribe{ushortdline}
%   This is analogous to "\underline" except that the underline is doubled.
%   This command is internally used by "\ushortd" and "\ushortdw",
%   and thus redefinitions change also the behavior of "\ushortd" and
%   "\ushortdw" correspondingly.
%   In Plain \TeX, this macro can be used only in math mode.
% \iDescribe{ushortCreate}
%   This can be used to generate a macro which behaves similarly to "\ushort"
%   or "\ushortd" but for which certain parameters can be changed.
%   For a detailed description, see below.
% \iDescribe{ushortEnsuremath}
%   This is rather equivalent to the \LaTeXe\ macro "\ensuremath"
%   (but is available also e.g.\ in compatibility mode or if this package
%   is used with plain \TeX\ or \LaTeX 2.09).
% \end{description}
%
% Only "\ushortCreate" needs a detailed description. Its call syntax is:
% \begin{quote}
%"\ushortCreate*:\"\meta{command}"["\meta{summand}"]<"\meta{factor before}">"\\
%"             "\relax
%"("\meta{factor after}")+"\bracemeta{additional calculations}\bracemeta{name}
% \end{quote}
%
% All arguments except for the last one \bracemeta{name} are optional.
% Moreover, also the order of these arguments can be changed arbitrarily,
% and they can be repeated (all except for the last occurrence of each
% each type of argument is ignored).
% Only the last argument \bracemeta{name} can not be repeated and must be at
% the end.
%
% This command creates a new macro \textbackslash\meta{name}.
% It is not tested whether \textbackslash\meta{name} already exists;
% if it exists already, it is overridden. In particular,
% it is admissible to use "\ushortCreate" to redefine "\ushort", "\ushortw",
% "\ushortd", or "\ushortdw". This is the recommended method, if you want to
% change the default values.
%
% The macro \textbackslash\meta{name} can be used analogously to "\underline",
% but the precise behavior depends on the arguments of "\ushortCreate".
%
% The meaning of the arguments is as follows:
%
% \begin{description}
% \item[\mdseries\texttt*]
%     If the "*" is present, then the command "\underbar" is used
%     (instead of the default "\underline") to draw the underline.
%     Moreover, the command "\underbar" is not used in math mode (while
%     "\underline" is used in math mode).
% \item[\mdseries\texttt:\textbackslash\meta{command}]
%     Use \textbackslash\meta{command} instead of the default "\underline" to
%     draw the underline. Whether \textbackslash\meta{command} is executed in
%     math mode or not depends on whether "*" has been used.
% \item[\mdseries\texttt{[}\meta{summand}\texttt{]}]
%     Add \meta{summand} to the length of the underline before drawing.
%     Values like "-.3\ht0" are admissible.
%     \meta{summand} is expanded only when \textbackslash\meta{name} is
%     expanded, and "\wd0" or "\ht0" give the width respectively height of the
%     argument given to "\name". In particular, also the value of the unit "em"
%     depends on the mode in which \textbackslash\meta{name} is called.
%     The default is empty (which means "0pt" but is faster).
% \item[\mdseries\texttt{<}\meta{factor before}\texttt{>}]
%     Multiply the length of the underline before adding \meta{summand}.
%     The empty string means $1$ (and costs no time).
%     The default is empty.
% \item[\mdseries\texttt{(}\meta{factor after}\texttt{)}]
%     Multiply the length of the underline after adding \meta{summand}.
%     The empty string means $1$ (and costs no time).
%     The default is "0.8".
% \item[\mdseries\texttt+\bracemeta{Additional calculations}]
%     With this argument, you can introduce an arbitrary command sequence into
%     the generated command: This sequence is executed (within a group) after
%     \meta{summand} was added, but before \meta{factor after} is applied.
%     This sequence is meant to do additional calculation with "\dimen0" which
%     is the length of the generated underline.
%     When the calculations are carried out, "\box0" contains the
%     content which is to be underlined. However, in contrast to previous
%     releases of this package, modifications of this box are ignored.
%     Instead, the registers "\dimen1" and "\dimen2" also contain the height
%     and depth of this box -- you have to modify these values to attain the
%     desired effect.
% \end{description}
%
% Examples:
% The most important examples are the macros "\ushort", "\ushortw",
% "\ushortd", and "\ushortdw" which have been created by
% \begin{verbatim}
%    \ushortCreate{ushort}
%    \ushortCreate()[-.1em]{ushortw}
%    \ushortCreate:\ushortdline{ushortd}
%    \ushortCreate:\ushortdline()[-.1em]{ushortdw}\end{verbatim}
% A further example demonstrating other parameters is
% \begin{verbatim}
%    \ushortCreate*(3)(.5){uline}\end{verbatim}
% This creates the macro "\uline" which underbars its argument but such that
% the underbar has only half of the usual length (the argument "(3)" in
% the above call is overridden by the later argument "(.5)").\par
% A more useful example is
% \begin{verbatim}
%    \ushortCreate()[-.3\ht0]{ushort}\end{verbatim}
% This modifies "\ushort" such that the underline is shrunken by $.3$ times
% the height of the argument of "\ushort". If the argument is one letter, this
% means: The higher the letter, the shorter the underline. This looks good
% for italic fonts with some exceptions (like the letter "b").


% \iffalse
%</metainfo>
% \fi
% \iffalse--------------------------------------------------------------\fi
% \StopEventually{\PrintChanges}
%                     \section{Implementation}
%
% \iffalse--------------------------------------------------------------
%
%
%<*package>
% \fi
%    \begin{macrocode}
%%
%% This file was generated by the docstrip utility from ushort.dtx.
%% You may distribute this file only together with the source ushort.dtx
%% (and if possible with ushort.ins) and only if these files are unmodified.
%%
%% Author:
%%
%% M. V\"ath      martin@mvath.de
%%

\ifx\typeout\undefined
  \def\ushrt@tmp{\immediate\write17}
\else
  \let\ushrt@tmp\typeout
\fi
\ushrt@tmp{ushort.sty by M. Vaeth: Release: 2.2 }

%% First, some LaTeX support:

\ifx\ProvidesPackage\undefined\else
  \ProvidesPackage{ushort}[2001/06/13 v2.2]
\fi

\ifx\newcommand\undefined\else
  \newcommand{\ushort}{}
  \newcommand{\ushortw}{}
  \newcommand{\ushortd}{}
  \newcommand{\ushortdw}{}
  \newcommand{\ushortdline}{}
  \newcommand{\ushortCreate}{}
  \newcommand{\ushortEnsuremath}{}
\fi

%% The implementation follows

%    \end{macrocode}
%
% \begin{macro}{\ushortCreate}
% We first scan the parameters into various macros. Then we call "\ushrt@Main".
%    \begin{macrocode}
\def\ushortCreate{\let\ushrt@calc\ushrt@empty\let\ushrt@TextMode\undefined
  \def\ushrt@FactorAfter{0.8}\let\ushrt@FactorBefore\ushrt@calc
  \let\ushrt@Summand\ushrt@empty\def\ushrt@cmd{\underline}\ushrt@TestLoop}
\def\ushrt@TestLoop{\ushrt@TestAndExec*\ushrt@Star\ushrt@TestCommand}
\def\ushrt@Star*{\def\ushrt@cmd{\underbar}\let\ushrt@TextMode\ushrt@empty
  \ushrt@TestLoop}
\def\ushrt@TestCommand{\ushrt@TestAndExec:\ushrt@GetCommand\ushrt@TestCalc}
\def\ushrt@GetCommand:#1{\def\ushrt@cmd{#1}\ushrt@TestLoop}
\def\ushrt@TestCalc{\ushrt@TestAndExec+\ushrt@GetCalc\ushrt@TestSummand}
\def\ushrt@GetCalc+#1{\def\ushrt@calc{#1}\ushrt@TestLoop}
\def\ushrt@TestSummand{\ushrt@TestAndExec[%]
  \ushrt@GetSummand\ushrt@TestFactorBefore}
\def\ushrt@GetSummand[#1]{\def\ushrt@Summand{\advance\dimen0 by#1}%
  \ushrt@TestLoop}
\def\ushrt@TestFactorBefore{\ushrt@TestAndExec<%>
  \ushrt@GetFactorBefore\ushrt@TestFactorAfter}
\def\ushrt@GetFactorBefore<#1>{\def\ushrt@FactorBefore{#1}\ushrt@TestLoop}
\def\ushrt@TestFactorAfter{\ushrt@TestAndExec(%)
  \ushrt@GetFactorAfter\ushrt@Main}
\def\ushrt@GetFactorAfter(#1){\def\ushrt@FactorAfter{#1}\ushrt@TestLoop}

%    \end{macrocode}
%
%  \begin{macro}{\ushrt@TestAndExec}
%  "\ushrt@TestAndExec" is a submacro needed to scan the parameters.
%    \begin{macrocode}
\def\ushrt@TestAndExec#1#2#3{%
  \ushrt@SkipAndExec{%
    \ifx\ushrt@NextToken#1%
      \def\ushrt@exec{#2}%
    \else
      \def\ushrt@exec{#3}%
    \fi
    \ushrt@exec}}
\def\ushrt@SkipAndExec#1{\def\ushrt@tmp{#1}\ushrt@skip}
\def\ushrt@skip{\futurelet\ushrt@NextToken\ushrt@tmp}

%    \end{macrocode}
%  \end{macro}
%  \begin{macro}{\ushrt@Main}
%  "\ushrt@Main" calls "\ushrt@Define" with appropriately expanded parameters.
%    \begin{macrocode}
\def\ushrt@Main#1{\def\ushrt@exec{\ushrt@Define}\ushrt@ExpandLoop
  \ushrt@cmd\ushrt@calc\ushrt@Summand\ushrt@FactorBefore\ushrt@FactorAfter
  {\csname#1\endcsname}{\csname ushrt@#1\endcsname}{}}

%    \end{macrocode}
%   \begin{macro}{\ushrt@ExpandLoop}
%   "\ushrt@ExpandLoop" expands successively the first token in each argument
%   by precisely one level (until the empty argument is reached which marks
%   the end of the argument list).
%   The expanded arguments are put into "{...}" and added to the end of the
%   content of "\ushrt@exec".
%   When all arguments have been parsed, "\ushrt@exec" is executed.
%    \begin{macrocode}
\def\ushrt@ExpandLoop#1{\def\ushrt@tmp{#1}%
  \ifx\ushrt@tmp\ushrt@empty
    \let\ushrt@tmp\ushrt@exec
  \else
    \let\ushrt@tmp\ushrt@ExpandLoop
    \expandafter\ushrt@Expand\expandafter{#1}%
  \fi\ushrt@tmp}
\def\ushrt@Expand#1{\expandafter
  \def\expandafter\ushrt@exec\expandafter{\ushrt@exec{#1}}}

%    \end{macrocode}
%   \end{macro}
%  \end{macro}
%  \begin{macro}{\ushrt@Define}
% All arguments of "\ushrt@Define" must be expanded. The call syntax is:
% \begin{quote}
%"\ushrt@Define"\relax
%\bracemeta{underline command}\bracemeta{calculations}\bracemeta{summand}\\
%"             "\relax
%\bracemeta{factor before}\bracemeta{factor after}"{\"\meta{name}"}"\relax
%"{\ushrt@"\meta{name}"}"
% \end{quote}
% Actually, \meta{summand} is not only the pure summand but the token sequence
% "\advance\dimen0 by"\meta{value}; \meta{summand} may also be empty.
%    \begin{macrocode}
\def\ushrt@Define#1#2#3#4#5#6#7{%
  \def#6##1{\ushortEnsuremath{\mathpalette#7{##1}##1}}%
  \ifx\ushrt@TextMode\undefined
    \def#7##1##2{\hbox to 0pt{{\mathsurround0pt$#1{%
      {\setbox0\hbox{\mathsurround0pt$##1##2$}%
        \dimen0=#4\wd0#3\dimen1\ht0\dimen2\dp0#2%
        \setbox0\hbox to#5\dimen0{}\ht0\dimen1\dp0\dimen2%
        \box0}}$\hss}}}%
  \else
    \def#7##1##2{\hbox to 0pt{#1{%
      {\setbox0\hbox{\mathsurround0pt$##1##2$}%
        \dimen0=#4\wd0#3\dimen1\ht0\dimen2\dp0#2%
        \setbox0\hbox to#5\dimen0{}\ht0\dimen1\dp0\dimen2%
        \box0}}\hss}}%
  \fi}

%    \end{macrocode}
%  \end{macro}
% \end{macro}
%
% \begin{macro}{\ushortEnsuremath}
% Since "\ensuremath" does not work due to \LaTeXe's irritating test for
% compatibility mode (and in order to use this package also for plain \TeX\
% and \LaTeX 2.09), we must write our own "\ensuremath" command. The command
% "\relax" in the beginning is necessary, because otherwise our command would
% not work if it is the first command in e.g.\ an "{eqnarray}" environment.
%    \begin{macrocode}
\def\ushortEnsuremath{\relax
  \ifmmode
    \let\ushrt@exec\ushrt@NoSwitch
  \else
    \let\ushrt@exec\ushrt@Switch
  \fi\ushrt@exec}
\def\ushrt@NoSwitch#1{#1}
\def\ushrt@Switch#1{\relax$#1\relax$\relax}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ushrt@empty}
% We do not want to rely on the fact that "\empty" is defined as "{}", so
% we use our own definition.
%    \begin{macrocode}
\def\ushrt@empty{}

%    \end{macrocode}
% \end{macro}
% \begin{macro}{\ushort}
% "\ushort" is nothing else but an instance created by "\ushortCreate"
% with the default values.
%    \begin{macrocode}
\ushortCreate{ushort}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\ushortw}
% "\ushortw" is nothing else but an instance created by "\ushortCreate"
% where the default values are changed by omitting \meta{factor after} and
% by setting another value for \meta{summand}:
%    \begin{macrocode}
\ushortCreate()[-.1em]{ushortw}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\ushortd}
% "\ushortd" is nothing else but an instance created by "\ushortCreate"
% with the default values but the \textbackslash\meta{command} value
% "\ushortdline":
%    \begin{macrocode}
\ushortCreate:\ushortdline{ushortd}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\ushortdw}
% "\ushortdw" is nothing else but an instance created by "\ushortCreate"
% where the default values are modified as in "\ushortw" and "\ushortd":
%    \begin{macrocode}
\ushortCreate:\ushortdline()[-.1em]{ushortdw}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\ushortdline}
%  "\ushortdline" in turn is very simple to implement:
%    \begin{macrocode}
\def\ushortdline#1{\underline{\underline #1}}
%    \end{macrocode}
% \end{macro}
%
%
% \iffalse
%</package>
% \fi
% \Finale\PrintIndex
%
%
%
% \iffalse
%<*metainfo>
% \fi
\iffalse -------------------------------------------------------------
%
% Just in case that for some reason the file `ushort.ins' got lost:
% The content of this file is between the lines %<*insfile> and %</insfile>.
%
%\iffalse
%</metainfo>
%<*insfile>
\def\batchfile{ushort.ins}
\input docstrip.tex
\keepsilent
\nopreamble
\generateFile{ushort.sty}{f}{\from{ushort.dtx}{package}}
\generateFile{ushort.txt}{f}{\from{ushort.dtx}{asciidocu}}
\generateFile{ushort.tex}{f}{\from{ushort.dtx}{driver}}
%%\generateFile{ushort.ins.dup}{f}{\from{ushort.dtx}{insfile}}

\Msg{***************************************************************}
\Msg{*}
\Msg{* To finish the installation you have to move the}
\Msg{* file 'ushort.sty' into a directory searched by TeX.}
\Msg{*}
\Msg{*}
\Msg{* Run the file ushort.tex through LaTeX to produce the}
\Msg{* documentation or read the ascii documentation in ushort.txt}
\Msg{*}
\Msg{*}
\Msg{***************************************************************}
\endbatchfile
%</insfile>
%<*metainfo>
% \fi
\fi
% \iffalse
%</metainfo>
% \fi
\endinput

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: "ushort.tex"
%%% End: