redindex.sty 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. \ifx\ps@REDUCEreference\undefined
  2. \else\endinput\fi
  3. \typeout{Document style option `redindex' version 1.3 -- RmS 1999/04/15}
  4. %
  5. % Change: 1999/04/15: make it work with both very old and new array.sty
  6. \ifx\COMPATNOTE\undefined
  7. \@@input reduce.sty\relax
  8. \fi
  9. \ifx\extrarowheight\undefined
  10. \@@input array.sty\relax
  11. \fi
  12. %\newcommand{\REDUCE}{REDUCE}
  13. \if@twoside\else\ds@twoside\fi
  14. \def\ps@REDUCEreference{\let\@evenhead\@empty\let\@oddhead\@empty
  15. \def\@oddfoot{\rm \hfil REDUCE Reference\ \ \thepage}%
  16. \def\@evenfoot{\rm \thepage\ \ REDUCE Reference\hfil}}
  17. \newcommand{\indexentry}[1]{\newpage
  18. \markboth{#1}{#1}\section*{#1}}
  19. \def\in@#1#2{%
  20. \def\in@@##1#1##2##3\in@@{%
  21. \ifx\in@##2\in@false\else\in@true\fi}%
  22. \in@@#2#1\in@\in@@}
  23. \newif\ifin@
  24. \newtoks\double@list
  25. \double@list={}
  26. \def\add@to@double@list#1{\double@list=\expandafter{\the\double@list#1\relax}}
  27. \def\check@double@list#1{%
  28. \def\@tempa{\in@{#1}}%
  29. \expandafter\@tempa\expandafter{\the\double@list}}
  30. \catcode`\_=12
  31. \def\other@underscore{_}
  32. \catcode`\_=\active
  33. \def_{\ifmmode\expandafter\sb\else\_\fi}
  34. \def\redindex@sanitize{\@sanitize\catcode`\ =10\relax
  35. \catcode`\\=0\relax
  36. \catcode`\{=1\relax
  37. \catcode`\}=2\relax
  38. \catcode`\_=\active}
  39. \def\check@multiple@label#1,#2,#3{% #1 is name, #2 is type, #3 is value
  40. \@ifundefined{r@#1}{\newlabel@{#1}{#3}}{%
  41. \typeout{Double found: #1, list: \the\double@list}%
  42. \check@double@list{#1}\ifin@\else\global\add@to@double@list{#1}\fi}}
  43. \let\newlabel@=\newlabel
  44. \def\newlabel{\begingroup
  45. \redindex@sanitize
  46. \newlabel@@
  47. }
  48. \def\newlabel@@#1#2{%\tracingall
  49. % \begingroup
  50. \let_=\other@underscore
  51. \newlabel@{#1}{#2}%
  52. \in@,{#1}\ifin@\check@multiple@label#1,{#2}\fi
  53. \endgroup}
  54. \let\enddocument@=\enddocument
  55. \def\enddocument{\let_=\other@underscore
  56. \immediate\write\@mainaux{\string\add@to@double@list{\the\double@list}}%
  57. \enddocument@}
  58. \def\enddocument{\@checkend{document}\clearpage\begingroup
  59. \if@filesw
  60. \let_=\other@underscore
  61. \immediate\write\@mainaux{\string\add@to@double@list{\the\double@list}}%
  62. \immediate\closeout\@mainaux
  63. \def\global\@namedef##1##2{}\def\newlabel{\@testdef r}%
  64. \def\bibcite{\@testdef b}\@tempswafalse \makeatletter
  65. \redindex@sanitize\input \jobname.aux
  66. \if@tempswa \@@warning{Label(s) may have changed. Rerun to get
  67. cross-references right}\fi\fi\endgroup\deadcycles\z@\@@end}
  68. \def\@testdef #1#2#3{\def\@tempa{#3}\expandafter \ifx \csname #1@#2\endcsname
  69. \@tempa \else
  70. \typeout{Testing #2 failed: old: \csname #1@#2\endcsname <-> new: #3}
  71. \@tempswatrue \fi}
  72. \newcount\newitem@penalty
  73. \newskip\newitem@preskip
  74. \newskip\newitem@postskip
  75. \newskip\newitem@headsep
  76. %\def\newitem#1#2{% #1 is type, #2 is name
  77. \def\newitem#1[#2]#3{% #1 is type, #2 is ref key, #3 is name
  78. \endgroup
  79. \ifvmode\else\par\fi
  80. \addpenalty\newitem@penalty
  81. \addvspace\newitem@postskip
  82. \hrule
  83. \nobreak
  84. \vskip \newitem@preskip
  85. \hbox to\hsize{\LARGE\bf\sf \uppercase{#3}\hfil #1}%
  86. \nobreak
  87. \vskip \newitem@headsep
  88. \begingroup
  89. \let_=\other@underscore
  90. \index{#3}\index{#1!#3}%
  91. \def\_{_}\label{#2,#1}\nobreak
  92. \endgroup}
  93. \newitem@penalty=\@beginparpenalty
  94. \newitem@postskip = 20pt plus 5pt minus 5pt
  95. \newitem@preskip = 10pt
  96. \newitem@headsep = 5pt
  97. \parskip = 5pt plus 2pt
  98. \parindent = 0pt
  99. \def\newitemEnv#1{%
  100. \expandafter\edef\csname#1\endcsname{%
  101. \begingroup\noexpand\redindex@sanitize\csname#1@\endcsname}%
  102. \@namedef{#1@}{\@dblarg{\newitem{#1}}}%
  103. \@namedef{end#1}{}}
  104. \newitemEnv{Command}
  105. \newitemEnv{Operator}
  106. \newitemEnv{Function}
  107. \newitemEnv{Switch}
  108. \newitemEnv{Variable}
  109. \newitemEnv{Declaration}
  110. \newitemEnv{Package}
  111. \newitemEnv{Concept}
  112. \newitemEnv{Constant}
  113. \newitemEnv{Type}
  114. \newitemEnv{info}
  115. \newitemEnv{Introduction}
  116. \newskip\itemsec@sep
  117. \newcount\itemsec@penalty
  118. \itemsec@penalty=\@beginparpenalty
  119. \itemsec@sep=5pt
  120. \def\begin@itemsection#1{\par\everypar={}%
  121. \addvspace\itemsec@sep
  122. \addpenalty\itemsec@penalty
  123. \hbox{\large\bf\sf #1}\nobreak}
  124. \def\end@itemsection{\par}
  125. \def\Comments{\begin@itemsection{Comments}}
  126. \let\endComments\end@itemsection
  127. \begingroup
  128. \catcode`\^=\active \catcode`\&=\active \catcode`\_=\active
  129. \def\x{\def\setup@special@chars{\catcode`\^=\active \let^=\special@uparrow
  130. \catcode`\&=\active \let&=\special@ampersand}%
  131. \def\protectspecialchars{\def^{\char`\^}\def_{\char`\_}}%
  132. \def\normalspecialchars{\let^=\sp\let_=\sb}%
  133. \def\activespecialchars{\let^=\special@uparrow}}
  134. \expandafter\endgroup\x
  135. \let\begin@=\begin
  136. \let\end@=\end
  137. \def\@ifstar#1#2{\def\@tempa{#1}\def\@tempb{#2}\futurelet
  138. \@tempc\@if@star@}
  139. \def\@if@star@{\ifx \@tempc*\def\@tempd*{\@tempa}\else\let\@tempd\@tempb\fi\@tempd}
  140. \def\Examples{\begin@itemsection{Examples}%
  141. \setup@special@chars\protectspecialchars%\tracingall
  142. \def\{{{\tt\char`\{}}%
  143. \def\}{{\tt\char`\}}}%
  144. \def\arraystretch{1.5}%
  145. \extrarowheight=1mm
  146. \def\end{%
  147. \ifnum\catcode`\{=12\relax \expandafter \special@ampersand\fi\end@}%
  148. \let \protect \relax
  149. \lineskip \z@
  150. \baselineskip \z@
  151. \frenchspacing
  152. \m@th
  153. \def\\{\relax\iffalse{\fi\ifnum 0=`}\fi
  154. \@ifstar {\@xarraycr\noalign{\penalty\@M}}\@xarraycr}
  155. \def\@xarraycr{\@ifnextchar [%
  156. \@argarraycr {\ifnum 0=`{}\fi\cr}}
  157. \def\@argarraycr[##1]{\ifnum0=`{}\fi\ifdim ##1>\z@
  158. \expandafter\@xargarraycr\else
  159. \expandafter\@yargarraycr\fi{##1}}
  160. \def\@xargarraycr##1{\unskip
  161. \@tempdima ##1\advance\@tempdima \dp\@arstrutbox
  162. \vrule \@depth\@tempdima \@width\z@ \cr}
  163. \def\@yargarraycr##1{\cr\noalign{\vskip ##1}}
  164. \let\par=\@empty
  165. \setbox \@arstrutbox \hbox{\vrule
  166. \@height \arraystretch \ht \strutbox
  167. \@depth \arraystretch \dp \strutbox
  168. \@width \z@}%
  169. \ialign\bgroup\@arstrut
  170. \global\@startnewrowfalse
  171. \catcode`\{=12\relax
  172. \catcode`\}=12\relax
  173. \catcode`\%=12\relax
  174. \catcode`\$=12\relax
  175. \catcode`\~=12\relax
  176. \setbox0=\hbox\bgroup\protect\tt##\unskip\hfil\egroup\checkcolwidth
  177. &$\quad\protect\Rightarrow\quad$%
  178. \global\setbox0=\hbox\bgroup\activespecialchars##\egroup\checkcolwidtho\cr
  179. }
  180. \def\endExamples{\crcr\egroup\end@itemsection}
  181. %\def\Examples{\begin@itemsection{Examples}%
  182. % \setup@special@chars\protectspecialchars%\tracingall
  183. % \def\{{{\tt\char`\{}}%
  184. % \def\}{{\tt\char`\}}}%
  185. % \def\arraystretch{1.5}%
  186. % \extrarowheight=1mm
  187. % \def\end{%
  188. % \ifnum\catcode`\{=12\relax \expandafter \special@ampersand\fi\end@}%
  189. % \begin{tabular}[b]{>{%\protectspecialchars
  190. % \global\@startnewrowfalse
  191. % \catcode`\{=12\relax
  192. % \catcode`\}=12\relax
  193. % \catcode`\%=12\relax
  194. % \catcode`\$=12\relax
  195. % \setbox0=\hbox\bgroup\protect\tt}l<{\egroup\checkcolwidth}%
  196. % >{$\quad\protect\Rightarrow\quad$%
  197. % \global\setbox0=\hbox\bgroup\activespecialchars}l%
  198. % <{\egroup\checkcolwidtho}}}
  199. %\def\endExamples{\end{tabular}\end@itemsection}
  200. \def\explanationi#1{\multicolumn{2}{p{0.95\textwidth}}{%
  201. \normalspecialchars \em#1}}
  202. \let\explanation=\explanationi
  203. \def\explanationo#1{\parbox[t]{0.95\MaxOutputWidth}{\em#1}}
  204. \def\start@new@row@for@output{%
  205. \multicolumn{2}{@{\protect\DoOutputIndent}l}{\box0}}
  206. \def\DoOutputIndent{
  207. \dimen@=\textwidth
  208. \advance\dimen@ -\wd\z@
  209. \ifdim\dimen@>\OutputIndent \dimen@=\OutputIndent
  210. \else\ifdim\dimen@<\z@ \dimen@=\OutputIndent\fi\fi
  211. \hspace{\dimen@}}
  212. \newdimen\OutputIndent \OutputIndent=10mm
  213. \begingroup \catcode `|=0 \catcode `[= 1
  214. \catcode`]=2 \catcode `\{=12 \catcode `\}=12
  215. \catcode`\\=12 |gdef|@bixample#1\end{Bigexample}[#1|end[Bigexample]]
  216. |endgroup
  217. \def\Bigexample{\begin@itemsection{Example}%
  218. \@verbatim \frenchspacing\@vobeyspaces \@bixample}
  219. \def\endBigexample{\endtrivlist\end@itemsection}
  220. \def\Related{\begin@itemsection{Related information}\begin{description}}
  221. \def\endRelated{\end{description}}
  222. \newif\if@startnewrow \@startnewrowfalse
  223. \newif\if@startneworow \@startneworowfalse
  224. \def\special@uparrow#1{\vbox{\vskip2\p@
  225. \hbox{\raise.8\normalbaselineskip\hbox{#1}}}}
  226. \def\special@ampersand{&\if@startnewrow\expandafter\startnewrow\fi\tt}
  227. \def\startnewrow{\omit\\&\global\@startnewrowfalse}
  228. \newdimen\maxexamplecolwidth
  229. \maxexamplecolwidth = 5cm
  230. \def\checkcolwidth{%
  231. \ifdim\wd0>\maxexamplecolwidth
  232. \hbox to\maxexamplecolwidth{\unhbox0\hss}%
  233. \hskip-25pt\null
  234. \global\@startnewrowtrue
  235. \else \unhbox0 \fi
  236. }
  237. \def\checkcolwidtho{%
  238. \ifdim\wd0>\MaxOutputWidth
  239. \global\everycr={\start@new@row@for@output
  240. \global\everycr={}\cr}%
  241. % \global\@startneworowtrue
  242. \else \unhbox0 \fi
  243. }
  244. \def\multilineinput{\catcode`\{=1 \catcode`\}=2
  245. \begin{minipage}[b]{\maxexamplecolwidth}\@vobeyspaces\obeylines}
  246. \def\endmultilineinput{\end{minipage}}
  247. \def\multilineoutput#1{\begin{minipage}[t]{#1}\@vobeyspaces\obeylines
  248. \baselineskip =1.5\baselineskip}
  249. \def\endmultilineoutput{\end{minipage}}
  250. \newdimen\MaxOutputWidth \MaxOutputWidth=7cm
  251. \def\multilineoutput#1{%
  252. \vtop\bgroup\@parboxrestore
  253. \lineskip \baselineskip
  254. \@tempswafalse
  255. \def\par{\if@tempswa\egroup
  256. \ifdim\wd0>\z@\box0\fi
  257. \setbox0=\hbox\bgroup\fi
  258. \@tempswatrue}
  259. \@vobeyspaces\obeylines
  260. \setbox0=\hbox\bgroup}
  261. \def\endmultilineoutput{\egroup\ifdim\wd0>\z@\box0\fi \egroup}
  262. \def\multilineinput{%
  263. \vbox\bgroup\@parboxrestore
  264. \def\end{\catcode`\{=1 \catcode`\}=2 \end@}%
  265. \@tempswafalse
  266. \def\par{\if@tempswa\egroup
  267. \ifdim\wd0>\z@\box0\fi
  268. \setbox0=\hbox\bgroup\fi
  269. \@tempswatrue}
  270. \@vobeyspaces\obeylines
  271. \addvspace{.8\baselineskip}%
  272. \setbox0=\hbox\bgroup}
  273. \let\endmultilineinput=\endmultilineoutput
  274. \def\privateshowbox{\showboxbreadth\maxdimen\showboxdepth\maxdimen\showbox}
  275. \def\rfrac#1#2{\begingroup
  276. \lineskip2pt \baselineskip \z@
  277. \setbox0=\hbox{\tt#1}%
  278. \setbox1=\hbox{\tt#2}%
  279. \setbox2=\hbox{\tt-}%
  280. \ifdim \wd0>\wd1 \dimen@=\wd0 \else \dimen@=\wd1 \fi
  281. \advance \dimen@ by2\wd2\relax
  282. \setbox3=\vtop{\hbox to\dimen@{\hss\unhcopy0\hss}%
  283. \hbox to\dimen@{\leaders\copy2\hfill}%
  284. \hbox to\dimen@{\hss\unhcopy1\hss}}%
  285. \dimen@=\dp0 \advance\dimen@ by\ht2 \advance\dimen@ by\lineskip
  286. \@tempdima=\ht3 \advance \@tempdima by\dimen@ \ht3=\@tempdima
  287. \@tempdima=\dp3 \advance \@tempdima by-\dimen@ \dp3=\@tempdima
  288. % \privateshowbox3
  289. \box3
  290. \endgroup}
  291. \def\def@protected#1#2{%
  292. \expandafter\edef\csname#1\endcsname{\begingroup\noexpand\redindex@sanitize
  293. \catcode32=10
  294. \csname#1@\endcsname}%
  295. \@namedef{#1@}##1{\endgroup#2}}
  296. \def@protected{name}{\mbox{\tt#1}}
  297. %\let\keyw=\name
  298. %\let\operator=\name
  299. \def@protected{nameindex}{\name{#1}\index{#1}\label{#1}}
  300. \def@protected{hyperref}{#1}
  301. %\def@protected{nameref}{\name{#1}, p.~\pageref{#1}}
  302. \def@protected{nameref}{\name{#1}}
  303. \def@protected{see}{(see \hyperref@{#1})}
  304. \def@protected{key}{\fbox{\sf #1}}
  305. \def@protected{arg}{\mbox{\it #1}}
  306. \newdimen \Syntaxindent \Syntaxindent=2mm
  307. \def\Syntax{\large
  308. \list{}{\leftmargin\Syntaxindent\def\({$(}\def\){)$}%
  309. \mathcode`\ =32768}\item[]}
  310. \def\endSyntax{\endlist}
  311. \def\repeated{$+$}
  312. \def\optional{\relax\ifmmode\ast\else$\ast$\fi}
  313. %\def\meta#1{\mbox{\it#1}}
  314. \def\meta{\begingroup\catcode`\_=\active\meta@}
  315. \def\meta@#1{\ifmmode\mbox\fi{\it#1\/}\endgroup}
  316. \def\alternative{$\displaystyle
  317. \left\{\begin{tabular}{l}}
  318. \def\endalternative{\end{tabular}\right\}$}
  319. \def\section{\@startsection {section}{1}{\z@}{-3.5ex plus-1ex minus
  320. -.2ex}{2.3ex plus.2ex}{\reset@font\LARGE\bf}}
  321. \def\subsection{\@startsection{subsection}{2}{\z@}{-3.25ex plus-1ex
  322. minus-.2ex}{1.5ex plus.2ex}{\reset@font\Large\bf}}
  323. \def\subsubsection{\@startsection{subsubsection}{3}{\z@}{-3.25ex plus
  324. -1ex minus-.2ex}{1.5ex plus.2ex}{\reset@font\large\bf}}
  325. %%%%
  326. %%%% error message file
  327. %%%%
  328. \def\tableoferrormessages{\@restonecolfalse
  329. \if@twocolumn\@restonecoltrue\onecolumn\fi
  330. \chapter*{\contentsname
  331. \@mkboth{\uppercase{\contentsname}}{\uppercase{\contentsname}}}%
  332. \@starttoc{emg}\if@restonecol\twocolumn\fi}
  333. \def\ErrorMessage#1{%
  334. \addcontentsline{emg}{#1}}
  335. %%%% conditionals
  336. \def\IFTEX#1#2{#1}
  337. \long\def\INFO#1\end#2{\def\@tempa{#2}\def\@tempb{INFO}%
  338. \ifx\@tempa\@tempb\else\errmessage{\string\end{#2} not allowed
  339. inside INFO environment.}\@eha\fi
  340. \end{INFO}}
  341. \def\endINFO{\global\@ignoretrue}
  342. \def\TEX{}
  343. \def\endTEX{\global\@ignoretrue}
  344. \@ifundefined{reset@font}{\let\reset@font\@empty}{}
  345. \pagestyle{REDUCEreference}
  346. \endinput