Debian Codegraph @

texk/web2c/xetexdir/xewebmac.tex

raw
1 % standard macros for WEB listings (in addition to PLAIN.TEX)
2 %
3 % pdfTeX adjustments mainained by Han The Thanh <[email protected]>.
4 % XeTeX adjustments mainited by Khaled Hosny <[email protected]>
5 %
6
7 \ifdefined\botofcontents\else\input webmac.tex\fi
8
9 % Some changes for xetex
10 \def\note#1#2.{\Y\noindent{\hangindent2em\baselineskip10pt\eightrm#1~\pdfnote#2..\par}}
11
12 \def\linkcolor#1{\special{color push rgb 0.4 0.6 1.0}#1\special{color pop}}
13 \def\link#1#2{\special{pdf:bann<</Type/Annot/Subtype/Link/Border[0 0 0]/A<</S/GoTo/D(#1)>>>>}\linkcolor{#2}\special{pdf:eann}}
14
15 \newtoks\toksA
16 \newtoks\toksB
17 \newtoks\toksC
18 \newtoks\toksD
19 \newcount\countA
20 \countA=0
21 \def\pdfnote#1.{\setbox0=\hbox{\toksA={#1.}\toksB={}\maketoks}\the\toksA}
22 \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
23 \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
24 \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
25 \def\maketoks{%
26 \expandafter\poptoks\the\toksA|ENDTOKS|
27 \ifx\first0\adn0
28 \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
29 \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
30 \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
31 \else
32 \ifnum0=\countA\else\makenote\fi
33 \ifx\first.\let\next=\done\else
34 \let\next=\maketoks
35 \addtokens{\toksB}{\the\toksD}
36 \ifx\first,\addtokens{\toksB}{\space}\fi
37 \fi
38 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
39 \next
40 }
41 \def\n#1{\link{#1}{#1}}
42 \def\makenote{\addtokens{\toksB}%
43 {\noexpand\n{\the\toksC}}\toksC={}\global\countA=0}
44 \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
45
46 \def\startsection{\Q{\let\*=\empty\special{pdf:dest (\modstar) [@thispage /XYZ @xpos @ypos null]}}%
47 \noindent{\let\*=\lapstar\bf\modstar.\quad}}
48
49 \def\X#1:#2\X{\ifmmode\gdef\XX{\null$\null}\else\gdef\XX{}\fi % section name
50 \XX$\langle\,$#2{\eightrm\kern.5em\pdfnote#1.}$\,\rangle$\XX}
51 \def\inx{\par\vskip6pt plus 1fil % we are beginning the index
52 \write\cont{} % ensure that the contents file isn't empty
53 \closeout\cont % the contents information has been fully gathered
54 \output{\ifpagesaved\normaloutput{\box\sbox}\lheader\rheader\fi
55 \global\setbox\sbox=\page \global\pagesavedtrue}
56 \pagesavedfalse \eject % eject the page-so-far and predecessors
57 \setbox\sbox\vbox{\unvbox\sbox} % take it out of its box
58 \vsize=\pageheight \advance\vsize by -\ht\sbox % the remaining height
59 \hsize=.5\pagewidth \advance\hsize by -10pt
60 % column width for the index (20pt between cols)
61 \parfillskip 0pt plus .6\hsize % try to avoid almost empty lines
62 \def\lr{L} % this tells whether the left or right column is next
63 \output{\if L\lr\global\setbox\lbox=\page \gdef\lr{R}
64 \else\normaloutput{\vbox to\pageheight{\box\sbox\vss
65 \hbox to\pagewidth{\box\lbox\hfil\page}}}\lheader\rheader
66 \global\vsize\pageheight\gdef\lr{L}\global\pagesavedfalse\fi}
67 \message{Index:}
68 \parskip 0pt plus .5pt
69 \outer\def\:##1, {\par\hangindent2em\noindent##1:\kern1em\pdfnote} % index entry
70 \let\ttentry=\. \def\.##1{\ttentry{##1\kern.2em}} % give \tt a little room
71 \def\[##1]{$\underline{##1}$} % underlined index item
72 \rm \rightskip0pt plus 2.5em \tolerance 10000 \let\*=\lapstar
73 \hyphenpenalty 10000 \parindent0pt}
74 \def\fin{\par\vfill\eject % this is done when we are ending the index
75 \ifpagesaved\null\vfill\eject\fi % output a null index column
76 \if L\lr\else\null\vfill\eject\fi % finish the current page
77 \parfillskip 0pt plus 1fil
78 \def\rhead{NAMES OF THE SECTIONS}
79 \message{Section names:}
80 \output{\normaloutput\page\lheader\rheader}
81 \setpage
82 \def\note##1##2.{\hfil\penalty-1\hfilneg\quad{\eightrm##1~\pdfnote##2..}}
83 \linepenalty=10 % try to conserve lines
84 \def\U{\note{Used in section}} % crossref for use of a section
85 \def\Us{\note{Used in sections}} % crossref for uses of a section
86 \def\:{\par\hangindent 2em}\let\*=*\let\.=\ttentry}
87 \def\con{\par\vfill\eject % finish the section names
88 \rightskip 0pt \hyphenpenalty 50 \tolerance 200
89 \setpage
90 \output{\normaloutput\page\lheader\rheader}
91 \titletrue % prepare to output the table of contents
92 \pageno=\contentspagenumber \def\rhead{TABLE OF CONTENTS}
93 \message{Table of contents:}
94 \topofcontents
95 \line{\hfil Section\hbox to3em{\hss Page}}
96 \def\Z##1##2##3{\line{\link{##2}{\ignorespaces##1
97 \leaders\hbox to .5em{.\hfil}\hfil\ ##2}
98 \hbox to3em{\hss##3}}}
99 \readcontents\relax % read the contents info
100 \botofcontents \makeoutlines\end} % print the contents page(s) and terminate
101
102 \newcount\countB
103 \def\makeoutlines{%
104 \def\?##1]{}\def\Z##1##2##3{\special{pdf:out 1 <</Title(##1)/A<</S/GoTo/D(##2)>>>>}}
105 \input CONTENTS\relax}
106 \endinput