summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/swrule/swrule.sty
blob: 1632cf3c9d4a080e2b11e02f9d050471233ae3a2 (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
% swrule.sty
% Written by Tobias G. Dussa <tdussa@sdhs.de>
% 09oct01
% Copyright (C) by Tobias G. Dussa <tdussa@sdhs.de>
%
% Provides two macros to create english lines a.k.a. swelled rules (i.e.
% lines % that become thicker towards the middle, much like a very
% far-stretched diamond) that only use plain tex means.
%
% The macros provided are
% - \swrule{length}{maximum width}
% - \swrulex{length}{minimum width}{maximum width}
%
% The \swrule macro is just a shortcut for \swrulex{length}{0pt}{max width}.
%
% The minimum width is the width of the line at the far left and
% right ends, while the maximum width is the width of the line in
% the very middle.
%
% The english line is made up of many short lines of different widths.
% The counter variable \swrulecount specifies how many small line pieces
% should be used to approximate the english line. It is set to 50 by
% default. The larger this value is, the finer-grained the resulting
% english line will be, so that the steps will not be as obvious.
% The \swrulecount variable should never be set to one, as a division
% by zero would occur. Likewise, any value smaller than 1 is pointless,
% albeit possible.
%
% The style package is a quick hack. If any error should occur, then
% I would greatly appreciate learning about it.
% Likewise, any suggestion is appreciated.
%
% The style package is copyrighted but may be used and extended in
% any way, as long as a pointer to the original author is maintained.
% The author is not liable for any problem that may or may not result
% from using this package. Use at your own risk.
%
% Enjoy.

\newcount\swrulecount
\newcount\swrulestep
\newdimen\swrulemin
\newdimen\swrulemax
\newdimen\swrulelength
\newdimen\swruleraise
\newdimen\swrulewidth
\newdimen\swruledelta
\newdimen\swrulepiece

\swrulecount=50

\def\swrulex#1#2#3{%
\swrulestep=\swrulecount%
\advance\swrulestep by -1%
\swrulelength=#1%
\swrulemin=#2%
\swrulemax=#3%
\swrulewidth=\swrulemin%
\swruleraise=\swrulemax%
\advance\swruleraise by -\swrulemin%
\divide\swruleraise by 2%
\swruledelta=\swrulemax%
\advance\swruledelta by -\swrulemin%
\divide\swruledelta by \swrulestep%
\multiply\swrulestep by 2\advance\swrulestep by 1%
\swrulepiece=\swrulelength%
\divide\swrulepiece by \swrulestep%
\swrulestep=1%
\hbox{%
\loop%
\raise\swruleraise\hbox{\rule{\swrulepiece}{\swrulewidth}}%
\ifnum\swrulestep<\swrulecount%
\advance\swrulestep by 1%
\advance\swruleraise by -\swruledelta%
\advance\swrulewidth by 2\swruledelta%
\repeat%
\advance\swrulestep by -1%
\advance\swruleraise by \swruledelta%
\advance\swrulewidth by -2\swruledelta%
\loop%
\raise\swruleraise\hbox{\rule{\swrulepiece}{\swrulewidth}}%
\ifnum\swrulestep>1%
\advance\swrulestep by -1%
\advance\swruleraise by \swruledelta%
\advance\swrulewidth by -2\swruledelta%
\repeat%
}}

\def\swrule#1#2{\swrulex{#1}{0pt}{#2}}