arydshln.sty 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. % arydshln.sty v1.0 (April 1, 1993)
  2. % by Hiroshi NAKASHIMA (nakasima@kuis.kyoto-u.ac.jp)
  3. %
  4. % Dahsed horizontal/vertical line for LaTeX array/tabular environment.
  5. %
  6. % \hdashline dashed \hline
  7. % \cdashline dashed \cline
  8. % `:' in preamble dashed `|'
  9. %
  10. % \hdashlinewidth length of dash segment (default = 4pt)
  11. % \hdashlinegap gap between dash segments (default = 4pt)
  12. %
  13. % Ussage
  14. %
  15. % \begin{array}{|l:c:r|} % or \begin{tabular}/\begin{tabular*}
  16. % A&B&C\\\hdashline % draw dashed \hline
  17. % AAA&BBB&CCC\\\cdashline{1-2}% draw dashed \cline
  18. % \multicolumn{2}{|l:}{AB}&C\\
  19. % \\hdashline\hdashline % draw dashed \hline\hline
  20. % \end{array}
  21. %
  22. % |
  23. % V
  24. %
  25. % | A : B : C |
  26. % + - - + - - + - - +
  27. % | AAA : BBB : CCC |
  28. % + - - + - - + |
  29. % | AB : C |
  30. % + - - + - - + - - +
  31. % + - - + - - + - - +
  32. %
  33. % Bugs
  34. %
  35. % 1. Since this style file strongly depends on the coding for array/tabular
  36. % of LaTeX Version 2.09, it may be in compatible with higher versions.
  37. %
  38. % 2. Processing speed for array/tabular will become slower, even if dashed
  39. % lines are not included.
  40. %
  41. % 3. `:' in preamble should not be followed by `|' nor `@'.
  42. %
  43. % 4. Gap size varies depending on the dash line length.
  44. % Modification of LaTeX's array/tabular
  45. \def\endarray{\hdl@endarray \egroup\egroup \hdl@arrayrestore}
  46. \def\endtabular{\hdl@endarray \egroup\egroup \hdl@arrayrestore $\egroup}
  47. \expandafter\let\csname endtabular*\endcsname = \endtabular
  48. \def\@array[#1]#2{\setbox\@arstrutbox=\hbox{\vrule
  49. height\arraystretch \ht\strutbox
  50. depth\arraystretch \dp\strutbox
  51. width\z@}%
  52. \hdl@arrayinit
  53. \@mkpream{#2}\edef\@preamble{\halign \noexpand\@halignto
  54. \bgroup \tabskip\z@ \@arstrut \@preamble \tabskip\z@ \cr}%
  55. \let\@startpbox\@@startpbox \let\@endpbox\@@endpbox
  56. \hdl@preaminit
  57. \if #1t\vtop \else \if#1b\vbox \else \vcenter \fi\fi
  58. \bgroup \let\par\relax
  59. \let\@sharp##\let\protect\relax \lineskip\z@\baselineskip\z@\@preamble}
  60. \def\@xarraycr{\@ifnextchar[{\@argarraycr}{\ifnum0=`{\fi}${}\hdl@cr}}
  61. \def\@xtabularcr{\@ifnextchar[{\@argtabularcr}{\ifnum0=`{\fi}\hdl@cr}}
  62. \def\@xargarraycr#1{\@tempdima #1\advance\@tempdima \dp \@arstrutbox
  63. \vrule \@height\z@ \@depth\@tempdima \@width\z@
  64. \hdl@argcr\@tempdima}
  65. \def\@yargarraycr#1{\hdl@argcr{-#1}\noalign{\vskip #1}}
  66. \def\multicolumn#1#2#3{\multispan{#1}\begingroup
  67. \def\hdl@arraydashrule{\ifnum\@lastchclass=6\relax
  68. \@addtopreamble{\hdl@vdashrule{\hdl@currentcolumn}}%
  69. \else\@tempcnta#1\advance\@tempcnta\hdl@currentcolumn
  70. \@addtopreamble{\hdl@vdashrule{\the\@tempcnta}}\fi}%
  71. \@mkpream{#2}%
  72. \def\@sharp{#3}\let\protect\relax
  73. \let\@startpbox\@@startpbox\let\@endpbox\@@endpbox
  74. \hdl@preaminit
  75. \@arstrut \@preamble\endgroup
  76. \global\advance\hdl@currentcolumn#1\ignorespaces}
  77. \def\@addamp{\if@firstamp\@firstampfalse \else
  78. \edef\@preamble{\@preamble \global\advance\hdl@currentcolumn\@ne &}%
  79. \advance\hdl@columns\@ne \fi}
  80. \let\hdl@mkpream\@mkpream
  81. \def\@mkpream{\hdl@columns\@ne \let\hdl@vdashrule\relax \let\hdl@colhtdp\relax
  82. \hdl@mkpream}
  83. \def\@arrayclassz{\ifcase \@lastchclass \@acolampacol \or \@ampacol \or
  84. \or \or \@addamp \or
  85. \@acolampacol \or \@firstampfalse \@acol \fi
  86. \edef\@preamble{\@preamble
  87. \ifcase \@chnum
  88. \hfil\hdl@putcolumn{$\relax\@sharp$}\hfil
  89. \or \hdl@putcolumn{$\relax\@sharp$}\hfil
  90. \or \hfil\hdl@putcolumn{$\relax\@sharp$}\fi}}
  91. \def\@tabclassz{\ifcase \@lastchclass \@acolampacol \or \@ampacol \or
  92. \or \or \@addamp \or
  93. \@acolampacol \or \@firstampfalse \@acol \fi
  94. \edef\@preamble{\@preamble
  95. \ifcase \@chnum
  96. \hfil\hdl@putcolumn{\@sharp\unskip}\hfil
  97. \or \hdl@putcolumn{\@sharp\unskip}\hfil
  98. \or \hfil\hskip\z@ \hdl@putcolumn{\@sharp\unskip}\fi}}
  99. \def\@testpach#1{\@chclass \ifnum \@lastchclass=\tw@ 4 \else
  100. \ifnum \@lastchclass=3 5 \else
  101. \z@ \if #1c\@chnum \z@ \else
  102. \if #1l\@chnum \@ne \else
  103. \if #1r\@chnum \tw@ \else
  104. \@chclass \if #1|\@ne \let\@arrayrule\hdl@arrayrule \else
  105. \if #1:\@ne \let\@arrayrule\hdl@arraydashrule \else
  106. \if #1@\tw@ \else
  107. \if #1p3 \else \z@ \@preamerr 0\fi
  108. \fi \fi \fi \fi \fi \fi \fi \fi}
  109. \def\hline{\noalign{\ifnum0=`}\fi \hrule\@height\arrayrulewidth
  110. \hdl@hline\arrayrulewidth
  111. \let\@tempb\hline\futurelet\@tempa\hdl@xhline}
  112. \def\@@startpbox#1{\setbox\hdl@box\vtop\bgroup\hsize#1\@arrayparboxrestore}
  113. \def\@@endpbox{\par\vskip\dp\@arstrutbox\egroup\hdl@colhtdp\box\hdl@box\hfil}
  114. % Register declaration
  115. \newdimen\hdashlinewidth \hdashlinewidth4pt %
  116. \newdimen\hdashlinegap \hdashlinegap4pt %
  117. \newif\ifhdl@drawing
  118. \newif\ifhdl@doublerule
  119. \newcount\hdl@totalheight \newcount\hdl@totalheightsave
  120. \newcount\hdl@columns
  121. \newcount\hdl@currentcolumn \newcount\hdl@currentcolumnsave
  122. \newbox\hdl@box
  123. \newdimen\hdl@height \newdimen\hdl@heightsave
  124. \newdimen\hdl@depth \newdimen\hdl@depthsave
  125. \gdef\hdl@vdashcolumn{}
  126. \gdef\hdl@vdashcols{}
  127. % \hdashline and \cdashline
  128. \def\hdashline{\multispan{\hdl@columns}\unskip\hdl@hcline
  129. \noalign{\ifnum0=`}\fi
  130. \let\@tempb\hdashline\futurelet\@tempa\hdl@xhline}
  131. \def\hdl@xhline{\ifx\@tempa\hline \hdl@ixhline\fi
  132. \ifx\@tempa\hdashline \hdl@ixhline\fi
  133. \ifnum0=`{\fi}}
  134. \def\hdl@ixhline{\vskip\doublerulesep\hdl@hline\doublerulesep}
  135. \def\hdl@hline#1{\@tempcnta#1
  136. \global\advance\hdl@totalheight\@tempcnta
  137. \xdef\hdl@vdashcols{\hdl@vdashcols
  138. (-1,-1,/\the\@tempcnta);}}
  139. \def\hdl@hcline{\vrule\@height\arrayrulewidth\@width\hdashlinewidth
  140. \hskip.5\hdashlinegap
  141. \xleaders\hbox{\hskip.5\hdashlinegap
  142. \vrule\@height\arrayrulewidth\@width\hdashlinewidth
  143. \hskip.5\hdashlinegap}\hfill
  144. \hskip.5\hdashlinegap
  145. \vrule\@height\arrayrulewidth\@width\hdashlinewidth\cr
  146. \noalign{\vskip-\arrayrulewidth}}
  147. \def\cdashline#1{\hdl@cline[#1]}
  148. \def\hdl@cline[#1-#2]{\noalign{\global\@cla#1\relax
  149. \global\advance\@cla\m@ne
  150. \ifnum\@cla>0\global\let\@gtempa\hdl@clinea\else
  151. \global\let\@gtempa\hdl@clineb\fi
  152. \global\@clb#2\relax
  153. \global\advance\@clb-\@cla}\@gtempa}
  154. \def\hdl@clinea{\multispan\@cla&\multispan\@clb\unskip\hdl@hcline}
  155. \def\hdl@clineb{\multispan\@clb\unskip\hdl@hcline}
  156. % Initiation and preamble
  157. \def\hdl@arrayinit{
  158. \hdl@totalheightsave\hdl@totalheight \global\hdl@totalheight\z@
  159. \hdl@currentcolumnsave\hdl@currentcolumn \global\hdl@currentcolumn\z@
  160. \hdl@heightsave\hdl@height \global\hdl@height\z@
  161. \hdl@depthsave\hdl@depth \global\hdl@depth\z@
  162. \edef\hdl@vdashcolumnsave{\hdl@vdashcolumn}\gdef\hdl@vdashcolumn{}%
  163. \edef\hdl@vdashcolssave{\hdl@vdashcols}\gdef\hdl@vdashcols{}}
  164. \def\hdl@preaminit{\let\hdl@vdashrule\hdl@@vdashrule
  165. \let\hdl@colhtdp\hdl@@colhtdp}
  166. \def\hdl@putcolumn#1{\setbox\hdl@box\hbox{#1}\hdl@colhtdp \box\hdl@box}
  167. \def\hdl@@colhtdp{%
  168. \ifdim\hdl@height<\ht\hdl@box \global\hdl@height\ht\hdl@box \fi
  169. \ifdim\hdl@depth<\dp\hdl@box \global\hdl@depth\dp\hdl@box\fi}
  170. \let\hdl@arrayrule\@arrayrule
  171. \def\hdl@arraydashrule{\ifnum\@lastchclass=6\relax
  172. \@addtopreamble{\hdl@vdashrule{0}}%
  173. \else \@addtopreamble{\hdl@vdashrule{\the\hdl@columns}}\fi}
  174. \def\hdl@@vdashrule#1{\xdef\hdl@vdashcolumn{\hdl@vdashcolumn#1,}}
  175. % End of row
  176. \def\hdl@cr{\cr\noalign{\hdl@@cr\z@}}
  177. \def\hdl@argcr#1{\cr\noalign{\hdl@@cr{#1}}}
  178. \def\hdl@@cr#1{
  179. \ifdim\hdl@height<\ht\@arstrutbox \hdl@height\ht\@arstrutbox\fi
  180. \ifdim\hdl@depth<\dp\@arstrutbox \hdl@depth\dp\@arstrutbox\fi
  181. \@tempcnta\hdl@height \advance\@tempcnta\hdl@depth
  182. \@tempdima#1\advance\@tempcnta\@tempdima
  183. \global\advance\hdl@totalheight\@tempcnta
  184. \xdef\hdl@vdashcols{\hdl@vdashcols
  185. (\hdl@vdashcolumn-1,-1,/\the\@tempcnta);}%
  186. \gdef\hdl@vdashcolumn{}\global\hdl@currentcolumn\z@
  187. \global\hdl@height\z@ \global\hdl@depth\z@}
  188. % End of array/tabular
  189. \def\hdl@endarray{\crcr \noalign{
  190. \ifdim\hdl@height=\z@
  191. \ifdim\hdl@depth=\z@ \else \hdl@@cr\z@ \fi
  192. \else \hdl@@cr\z@ \fi}\omit
  193. \def\hdl@vdrow{}\global\let\hdl@vd\relax
  194. \global\let\hdl@amp\relax \global\let\hdl@omit\relax
  195. \hdl@makevd
  196. \global\let\hdl@vd\hdl@@vd
  197. \global\let\hdl@amp\hdl@@amp \global\let\hdl@omit\hdl@@omit
  198. \hdl@vdrow\cr}
  199. \def\hdl@arrayrestore{\global\hdl@totalheight\hdl@totalheightsave
  200. \global\hdl@currentcolumn\hdl@currentcolumnsave
  201. \global\hdl@height\hdl@heightsave
  202. \global\hdl@depth\hdl@depthsave
  203. \xdef\hdl@vdashcolumn{\hdl@vdashcolumnsave}%
  204. \xdef\hdl@vdashcols{\hdl@vdashcolssave}}
  205. \def\hdl@@amp{&}
  206. \def\hdl@@omit{\omit}
  207. \def\hdl@makevd{\@tempcnta\hdl@totalheight \@tempcntb\hdl@totalheight
  208. \hdl@drawingfalse \def\@tempb{}%
  209. \hdl@doublerulefalse
  210. \expandafter\hdl@imakevd\hdl@vdashcols\@nil;%
  211. \ifhdl@drawing \hdl@drawvd \fi
  212. \edef\hdl@vdashcols{\@tempb}%
  213. \ifhdl@doublerule
  214. \edef\hdl@vdrow{\hdl@vdrow\hskip\doublerulesep}%
  215. \let\next\hdl@makevd
  216. \else
  217. \advance\hdl@currentcolumn\@ne
  218. \ifnum\hdl@currentcolumn>\hdl@columns \let\next\relax
  219. \else
  220. \ifnum\hdl@currentcolumn=\@ne
  221. \edef\hdl@vdrow{\hdl@vdrow\hfil}%
  222. \else
  223. \edef\hdl@vdrow{\hdl@vdrow
  224. \hdl@amp \hdl@omit \hfil}%
  225. \fi
  226. \let\next\hdl@makevd
  227. \fi\fi\next}
  228. \def\hdl@imakevd#1;{\def\@tempa{#1}\ifx\@tempa\@nnil \let\next\relax
  229. \else \hdl@iimakevd#1\let\next\hdl@imakevd \fi \next}
  230. \def\hdl@iimakevd(#1/#2){\hdl@iiimakevd#1\@nil
  231. \edef\@tempb{\@tempb(\@tempc/#2);}\advance\@tempcntb-#2}
  232. \def\hdl@iiimakevd#1,#2,#3\@nil{%
  233. \ifnum#1<\z@\def\@tempc{-1,-1,}%
  234. \ifhdl@drawing \hdl@drawvd \hdl@drawingfalse \fi
  235. \else
  236. \ifnum#1=\hdl@currentcolumn \relax
  237. \ifhdl@drawing \else
  238. \@tempcnta\@tempcntb \hdl@drawingtrue
  239. \fi
  240. \def\@tempc{#2,#3}%
  241. \ifnum#1=#2\relax \hdl@doubleruletrue \fi
  242. \else
  243. \ifhdl@drawing \hdl@drawvd \hdl@drawingfalse \fi
  244. \def\@tempc{#1,#2,#3}%
  245. \fi\fi}
  246. \def\hdl@drawvd{\advance\@tempcnta-\@tempcntb
  247. \edef\hdl@vdrow{\hdl@vdrow \hdl@vd{\the\@tempcntb}{\the\@tempcnta}}}
  248. \def\hdl@@vd#1#2{\vbox to\z@{\vss\hbox{\hskip-.5\arrayrulewidth
  249. \raise#1sp\vbox to#2sp{
  250. \hrule\@height.5\hdashlinewidth\@width\arrayrulewidth
  251. \vskip.5\hdashlinegap
  252. \xleaders\vbox{\vskip.5\hdashlinegap
  253. \hrule\@height\hdashlinewidth\@width\arrayrulewidth
  254. \vskip.5\hdashlinegap}\vfil
  255. \vskip.5\hdashlinegap
  256. \hrule\@height.5\hdashlinewidth\@width\arrayrulewidth}%
  257. \hskip-.5\arrayrulewidth}}}