summaryrefslogtreecommitdiff
path: root/macros/generic/misc/wiggly.tex
diff options
context:
space:
mode:
Diffstat (limited to 'macros/generic/misc/wiggly.tex')
-rw-r--r--macros/generic/misc/wiggly.tex30
1 files changed, 30 insertions, 0 deletions
diff --git a/macros/generic/misc/wiggly.tex b/macros/generic/misc/wiggly.tex
new file mode 100644
index 0000000000..7f04760f34
--- /dev/null
+++ b/macros/generic/misc/wiggly.tex
@@ -0,0 +1,30 @@
+% A macro \underwiggle for drawing variable length wiggly lines horizontally
+% under its argument in the same way as \underbar.
+% Written by Dr. John S. Garavelli on 4 December 1987 and adapted from a routine
+% by A. G. W. Cameron at Harvard University which appeared in TUGBOAT November
+% 1985, vol. 6, no. 3, p. 155.
+% WARNING: the computations performed by this macro can be very time consuming,
+% so use it sparingly.
+
+\newcount\vone \newcount\vtwo \newcount\vthree \newcount\vfour \newcount\vfive
+\newcount\vsix \newcount\vseven \newcount\veight \newcount\vnine \newcount\vten
+\newbox\wbox \newdimen\wbsize
+\def\underwiggle#1{\ifmmode\setbox\wbox=\hbox{$#1$}
+ \else\setbox\wbox=\hbox{#1}\fi
+\dp\wbox=0pt\wbsize=\wd\wbox\lower2pt\hbox to0pt
+{\hss$\vone=0\vtwo=0\vthree=7000\vfive=\vtwo
+\loop
+\vseven=\vone \divide\vseven by 2
+\vsix=\vfive \divide\vsix by 2 \multiply\vsix by -1
+\veight=16384 \advance\veight by \vsix
+\vnine=16384 \advance\vnine by -\vsix
+\vten=\vseven \advance\vten by 32768
+\hskip\vseven sp
+\vrule height\veight sp width 32768 sp depth\vnine sp
+\hskip-\vten sp
+\ifdim\vseven sp<\wbsize \advance\vone by 20000
+\advance\vtwo by \vthree
+\vfour=-\vtwo \divide\vfour by 10
+\advance\vthree by \vfour
+\advance\vfive by \vtwo
+\repeat$}\box\wbox}