summaryrefslogtreecommitdiff
path: root/macros/generic/misc/wiggly.tex
blob: 7f04760f34aa561f52e43f4c43ffe23f13f8233b (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
% 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}