slashbox.sty 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. % slashbox.sty by Koichi Yasuoka, May 27, 1993
  2. % minor modification by Toru Sato, May 31, 1993
  3. \typeout{slashbox style by K.Yasuoka, May 1993.}%
  4. \newbox\@slashboxa
  5. \newbox\@slashboxb
  6. \newbox\@slashboxc
  7. \newcount\@slashboxwd
  8. \newcount\@slashboxht
  9. \newdimen\@slashsepl
  10. \newdimen\@slashsepr
  11. \def\slashbox{%
  12. \def\@slashboxpicture##1{%
  13. \put(0,0){\line(##1,1){\@slashboxwd}}%
  14. \put(0,\@slashboxht){\makebox(0,0)[tl]{\box\@slashboxa}}%
  15. \put(\@slashboxwd,0){\makebox(0,0)[br]{\box\@slashboxb}}%
  16. }%
  17. \@slashbox
  18. }%
  19. \def\backslashbox{%
  20. \def\@slashboxpicture##1{%
  21. \put(0,\@slashboxht){\line(##1,-1){\@slashboxwd}}%
  22. \put(0,0){\makebox(0,0)[bl]{\box\@slashboxa}}%
  23. \put(\@slashboxwd,\@slashboxht){\makebox(0,0)[tr]{\box\@slashboxb}}%
  24. }%
  25. \@slashbox
  26. }%
  27. \def\@slashbox{\@ifnextchar [{\@@slashbox}{\@@slashbox[0pt]}}
  28. \def\@@slashbox[#1]{\@ifnextchar [{\@@@slashbox[#1]}{\@@@slashbox[#1][c]}}
  29. \def\@@@slashbox[#1][#2]#3#4{%
  30. % #1: width, #2: suppression of \tabcolsep on `l', `r', or `lr' side
  31. % #3: left item, #4: right item
  32. \@slashsepl=\tabcolsep
  33. \@slashsepr=\tabcolsep
  34. \@tfor\@tempa :=#2\do{\expandafter\let
  35. \csname @slashsep\@tempa\endcsname=\z@}%
  36. \setbox\@slashboxa=\hbox{\strut\hskip\tabcolsep\shortstack[l]{#3}}%
  37. \setbox\@slashboxb=\hbox{\shortstack[r]{#4}\hskip\tabcolsep\strut}%
  38. \setbox\@slashboxa=\hbox{\raise\dp\@slashboxa\box\@slashboxa}%
  39. \setbox\@slashboxb=\hbox{\raise\dp\@slashboxb\box\@slashboxb}%
  40. \setbox\@slashboxc=\hbox{%
  41. \@tempdima=\wd\@slashboxa
  42. \advance\@tempdima by \wd\@slashboxb
  43. \advance\@tempdima by \@slashsepl
  44. \advance\@tempdima by \@slashsepr
  45. \@tempdimb=#1\relax%
  46. \ifdim\@tempdimb>\@tempdima \@tempdima=\@tempdimb\fi%
  47. \@tempdimb=\ht\@slashboxa
  48. \advance\@tempdimb by \dp\@slashboxa
  49. \advance\@tempdimb by \ht\@slashboxb
  50. \advance\@tempdimb by \dp\@slashboxb
  51. \@tempcnta=\@tempdima
  52. \@tempcntb=\@tempdimb
  53. \advance\@tempcnta by \@tempcntb
  54. \advance\@tempcnta by -1
  55. \divide\@tempcnta by \@tempcntb
  56. \ifnum\@tempcnta>6 \@tempcnta=6
  57. \@tempdimb=0.166666666\@tempdima
  58. \else
  59. \ifnum\@tempcnta<1 \@tempcnta=1\fi
  60. \@tempdima=\@tempdimb
  61. \multiply\@tempdima by \@tempcnta
  62. \fi%
  63. \advance\@tempdima by -\@slashsepl
  64. \advance\@tempdima by -\@slashsepr
  65. \@slashboxwd=\@tempdima
  66. \@slashboxht=\@tempdimb
  67. \@tempcntb=\@slashsepl
  68. \setlength{\unitlength}{1sp}%
  69. \begin{picture}(\@slashboxwd,\@slashboxht)(\@tempcntb,0)
  70. \advance\@tempdima by \@slashsepl
  71. \advance\@tempdima by \@slashsepr
  72. \@slashboxwd=\@tempdima
  73. \@slashboxpicture{\@tempcnta}
  74. \end{picture}%
  75. }%
  76. $\vcenter{\box\@slashboxc}$%
  77. }%