setstack.sty 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. %%
  2. %% This is file `setstack.sty', created by VIK 15 Dec 1998
  3. %% Reproduces useful macros from amsmath.sty, thus avoiding the need to load the entire
  4. %% amsmath.sty and run into conflicts
  5. %% Adds definitions for \overset, \underset, \sideset, \substack, \boxed, \leftroot,
  6. %% \uproot, \dddot, \ddddot, \varrow, \harrow (see The LateX Companion, pp 225-227)
  7. \NeedsTeXFormat{LaTeX2e}% LaTeX 2.09 can't be used (nor non-LaTeX)
  8. [1998/12/15]% LaTeX date must December 1998 or later
  9. \ProvidesPackage{setstack}
  10. \DeclareRobustCommand{\text}{%
  11. \ifmmode\expandafter\text@\else\expandafter\mbox\fi}
  12. \let\nfss@text\text
  13. \def\text@#1{\mathchoice
  14. {\textdef@\displaystyle\f@size{#1}}%
  15. {\textdef@\textstyle\tf@size{\firstchoice@false #1}}%
  16. {\textdef@\textstyle\sf@size{\firstchoice@false #1}}%
  17. {\textdef@\textstyle \ssf@size{\firstchoice@false #1}}%
  18. \check@mathfonts
  19. }
  20. \def\textdef@#1#2#3{\hbox{{%
  21. \everymath{#1}%
  22. \let\f@size#2\selectfont #3}}}
  23. % adds underset, overset, sideset and
  24. % substack features from amsmath.sty (Companion p. 226)
  25. \def\invalid@tag#1{\@amsmath@err{#1}{\the\tag@help}\gobble@tag}
  26. \def\dft@tag{\invalid@tag{\string\tag\space not allowed here}}
  27. \def\default@tag{\let\tag\dft@tag}
  28. \def\Let@{\let\\\math@cr}
  29. \def\restore@math@cr{\def\math@cr@@@{\cr}}
  30. \def\overset#1#2{\binrel@{#2}%
  31. \binrel@@{\mathop{\kern\z@#2}\limits^{#1}}}
  32. \def\underset#1#2{\binrel@{#2}%
  33. \binrel@@{\mathop{\kern\z@#2}\limits_{#1}}}
  34. \def\sideset#1#2#3{%
  35. \@mathmeasure\z@\displaystyle{#3}%
  36. \global\setbox\@ne\vbox to\ht\z@{}\dp\@ne\dp\z@
  37. \setbox\tw@\box\@ne
  38. \@mathmeasure4\displaystyle{\copy\tw@#1}%
  39. \@mathmeasure6\displaystyle{#3\nolimits#2}%
  40. \dimen@-\wd6 \advance\dimen@\wd4 \advance\dimen@\wd\z@
  41. \hbox to\dimen@{}\mathop{\kern-\dimen@\box4\box6}%
  42. }
  43. \newenvironment{subarray}[1]{%
  44. \vcenter\bgroup
  45. \Let@ \restore@math@cr \default@tag
  46. \baselineskip\fontdimen10 \scriptfont\tw@
  47. \advance\baselineskip\fontdimen12 \scriptfont\tw@
  48. \lineskip\thr@@\fontdimen8 \scriptfont\thr@@
  49. \lineskiplimit\lineskip
  50. \ialign\bgroup\ifx c#1\hfil\fi
  51. $\m@th\scriptstyle##$\hfil\crcr
  52. }{%
  53. \crcr\egroup\egroup
  54. }
  55. \newcommand{\substack}[1]{\subarray{c}#1\endsubarray}
  56. % definitions of dddot and ddddot(p. 225)
  57. \def\dddot#1{{\mathop{#1}\limits^{\vbox to-1.4\ex@{\kern-\tw@\ex@
  58. \hbox{\normalfont ...}\vss}}}}
  59. \def\ddddot#1{{\mathop{#1}\limits^{\vbox to-1.4\ex@{\kern-\tw@\ex@
  60. \hbox{\normalfont....}\vss}}}}
  61. % definitions of leftroot, uproot (p.225)
  62. \begingroup \catcode`\"=12
  63. \gdef\@@sqrt#1{\radical"270370 {#1}}
  64. \endgroup
  65. \def\leftroot{\@amsmath@err{\Invalid@@\leftroot}\@eha}
  66. \def\uproot{\@amsmath@err{\Invalid@@\uproot}\@eha}
  67. \newcount\uproot@
  68. \newcount\leftroot@
  69. \def\root{\relaxnext@
  70. \DN@{\ifx\@let@token\uproot\let\next@\nextii@\else
  71. \ifx\@let@token\leftroot\let\next@\nextiii@\else
  72. \let\next@\plainroot@\fi\fi\next@}%
  73. \def\nextii@\uproot##1{\uproot@##1\relax\FN@\nextiv@}%
  74. \def\nextiv@{\ifx\@let@token\@sptoken\DN@. {\FN@\nextv@}\else
  75. \DN@.{\FN@\nextv@}\fi\next@.}%
  76. \def\nextv@{\ifx\@let@token\leftroot\let\next@\nextvi@\else
  77. \let\next@\plainroot@\fi\next@}%
  78. \def\nextvi@\leftroot##1{\leftroot@##1\relax\plainroot@}%
  79. \def\nextiii@\leftroot##1{\leftroot@##1\relax\FN@\nextvii@}%
  80. \def\nextvii@{\ifx\@let@token\@sptoken
  81. \DN@. {\FN@\nextviii@}\else
  82. \DN@.{\FN@\nextviii@}\fi\next@.}%
  83. \def\nextviii@{\ifx\@let@token\uproot\let\next@\nextix@\else
  84. \let\next@\plainroot@\fi\next@}%
  85. \def\nextix@\uproot##1{\uproot@##1\relax\plainroot@}%
  86. \bgroup\uproot@\z@\leftroot@\z@\FN@\next@}
  87. \def\plainroot@#1\of#2{\setbox\rootbox\hbox{%
  88. $\m@th\scriptscriptstyle{#1}$}%
  89. \mathchoice{\r@@t\displaystyle{#2}}{\r@@t\textstyle{#2}}
  90. {\r@@t\scriptstyle{#2}}{\r@@t\scriptscriptstyle{#2}}\egroup}
  91. \def\r@@t#1#2{\setboxz@h{$\m@th#1\@@sqrt{#2}$}%
  92. \dimen@\ht\z@\advance\dimen@-\dp\z@
  93. \setbox\@ne\hbox{$\m@th#1\mskip\uproot@ mu$}%
  94. \advance\dimen@ by1.667\wd\@ne
  95. \mkern-\leftroot@ mu\mkern5mu\raise.6\dimen@\copy\rootbox
  96. \mkern-10mu\mkern\leftroot@ mu\boxz@}
  97. % definition of \boxed (math in frame, no dollars) p 225
  98. \def\boxed#1{\fbox{\m@th$\displaystyle#1$}}
  99. % definition of \smash for top and bottom parts of expression in braces (p.227)
  100. \renewcommand{\smash}[2][tb]{%
  101. \def\smash@{#1}%
  102. \ifmmode\@xp\mathpalette\@xp\mathsm@sh\else
  103. \@xp\makesm@sh\fi{#2}}
  104. % additional difinitions for arrows
  105. % zero mm wide #2 mm long vertical arrow shifted 1 mm to left, 1 mm up
  106. \newcommand{\varrow}[2]{%
  107. \unitlength=1mm
  108. \begin{picture}(0,6) % (0,0)
  109. % - for #1 to point arrow down,+ to point arrow up
  110. \end{picture}%
  111. \put(0,6){\vector(0,#1 3){#2}} % 6,- for down, 0, + for up
  112. }
  113. % 1 mm high #2 mm long horizontal arrow shifted 1 mm up (0,-1)
  114. \newcommand{\harrow}[2]{%
  115. \unitlength=1mm
  116. \begin{picture}(8,1)(0,-1) %
  117. % 1 mm distance between arrow and stackreled object over it (8,1)
  118. \put(0,0){\vector(#1 2,0){#2}} % - to point arrow left, + right
  119. \end{picture}%
  120. }
  121. \endinput
  122. %% end of setstack.sty
  123. %% Corrections history:
  124. %%