% This is file cwebhmac.tex, part of the CWEBx distribution. % This file can be loaded after cwebxmac.tex, in order to automatically % insert \specials for use by the xhdvi previewer, or any other HyperTeX % dvi-file processing tool. Current version is alpha release. % Author: Marc van Leeuwen % Last modified: 8 november 1996. % The following macros are redefined % \stsec % \note
. % \finnote
. % \X:\X \ifx\hyperloaded\undefined \let\hyperloaded\relax \else \endinput\fi % Low level interface to hyperlinks and targets % \hyperanchor % general mechanism to define as anchor with \long\def\hyperanchor#1#2{\special{html:}{#2}\special{html:}} % \hyperlink % makes an active link referring to \def\hyperlink#1{\hyperanchor{href="#1"}} % \hypertarget % defines a local target for hyperlinks, that can be referenced by \def\hypertarget#1{\hyperanchor{name="#1"}} % \hyperdef % defines a hypertarget classified by and sequence \def\hyperdef#1#2{\hypertarget{#1.#2}} % \hyperref % creates a hyperlink to local target created by \hyperdef % are optional assignments for expansion of and {\catcode`\#=12 \gdef\sharp{#}} % to access neutralised '#' character \def\hyperref#1#2#3% {{#1\xdef\next{{\sharp#2.#3}}}\expandafter\hyperlink\next} % High level interface attached to CWEAVE-produced macros (or to those % accessed by them via the definition of cwebxmac.tex) % Target attached to beginning of each section. =sec, =\secno. \def\stsec {\endcodemode\noindent \hyperdef{sec}\secno{\let\*=\lapstar\bf\secstar.}\quad } \let\startsection=\stsec % this one is used; provides hook for extra actions % List of links attached to end of some sections. \def\note#1#2.% {\Y\noindent{\hangindent2\indentunit\baselineskip10pt\eightrm #1~\hypersecrefs#2, .\par}} % Same, but for references from the list of module names. \def\finnote#1#2.{\quad{\eightrm#1~\hypersecrefs#2, .}} % the following two are auxiliary macros that implement reference lists. % \hypersecrefs, , ..., , . % or \hypersecrefs, . % make list of hyperlinks to each of then mentioned sections \def\hypersecrefs#1, #2.% {\ifx|#2|\def\next{\finalsecrefs#1\ET\ET.#1\ETs\ETs}% final `.' follows below \else\hyperref{\let\*=\empty}{sec}{#1}{#1}, \let\next=\hypersecrefs \fi\next#2.% } % \finalsecref\ET\ET.\ETs\ETs. % or \finalsecref\ET\ET.\ETs\ETs. \def\finalsecrefs#1\ET#2\ET#3.#4\ETs#5\ETs#6.% {\ifx|#2#5|\hyperref{\let\*=\empty}{sec}{#1}{#1}% just 1 reference \else % \ET or \ETs \edef\next{\ifx|#5|#1\else#4\fi}% \toks0={\let\*=\empty}% \edef\next{{\the\toks0}{sec}{\next}{\next}}% \expandafter\hyperref\next% link to sec. with text #3#6% one is empty, the other is \ET or \ETs, as appropriate \hyperref{\let\*=\empty}{sec}{#2#5}{#2#5}% similar trick, link to sec. \fi } % we must change \ATP slightly, so that \X can recognise it and avoid a link \def\ATP{\X\ATP\kern-.5em:Preprocessor directives\X} \def\X#1:#2\X % module name {\langle\,${#2\eightrm\enspace\ifx\ATP#1\else\hypersecrefs#1, .\fi}$\,\rangle} {\catcode`_=12 \gdef\usplain{\def\_{_}}} \let\plainCident=\Cident \def\Cident#1{\def\idstart{#1}\futurelet\next\testid} \let\\=\Cident % cwebx only; a \hbox would prevent us from seeing "subscript" \def\testid {\ifx_\next \def\next_##1% {\hyperref\usplain{id}{\idstart##1}{\plainCident\idstart_{##1}}}% \else \hyperref\usplain{id}\idstart{\plainCident\idstart}% \let\next=\empty \fi\next } \def\indextestid {\ifx_\next \def\next_##1% {{\usplain\xdef\next{{id}{\idstart##1}}}% \expandafter\hyperdef\next{\plainCident\idstart_{##1}}% }% \else {\usplain\xdef\next{{id}{\idstart}}}% \expandafter\hyperdef\next{\plainCident\idstart}% \let\next=\empty \fi\next } {\let \inxentry=\relax % remove \outer-ness \toks0=\expandafter{\inx \let\testid=\indextestid}\xdef\inx{\the\toks0 } } \outer\def\inxentry#1#2, #3.% #1 is `h' or `m' for horiz/math mode {\par\hangindent2em\noindent \if#1m$#2$\else#2\relax\fi % \relax avoids fatal \next=\fi in \indextestid :\kern1em\indexrefs#3, .% } \def\indexrefs#1, #2.% {\hyperref{\let\*=\empty\def\[##1]{##1}}{sec}{#1}{#1}% \ifx|#2|\let\next=\empty\else, \let\next=\indexrefs\fi\next#2.% } \def\contentsline#1#2#3#4% #1=depth, #2=title, #3=secno, #4=pageno {\line{\hyperref{}{sec}{#3}{\ignorespaces#2} \leaders\hbox to .5em{.\hfil}\hfil \ \hyperref{}{sec}{#3}{#3 \hbox to3em{\hss#4}}% }% }