| 1 |
\input ptb-pdfData |
| 2 |
\input pdfDstruct/ptb-hyperlinks |
| 3 |
\input pdfDstruct/ptb-tableofcontents |
| 4 |
\_checkloaded{indexes} |
| 5 |
|
| 6 |
\createarray{index_listing} |
| 7 |
|
| 8 |
%\def\_addtoindex#1#2{% |
| 9 |
% \def\_temp{#2}% |
| 10 |
% \ifx\_temp\empty% |
| 11 |
% \expanded{\noexpand\_rappendarray{\noexpand\gotoanchor{index@anchor@\the\indexcnt}{\@defaultindexval}}}{index@#1@pages}% |
| 12 |
% \else% |
| 13 |
% \expanded{\noexpand\_rappendarray{\noexpand\gotoanchor{index@anchor@\the\indexcnt}{#2}}}{index@#1@pages}% |
| 14 |
% \fi% |
| 15 |
%} |
| 16 |
|
| 17 |
\def\_rfindarray#1#2{\findarray{#2}{#1}} |
| 18 |
\def\_runiqueappendarray#1#2{\uniqueappendarray{#2}{#1}} |
| 19 |
|
| 20 |
\newcount\indexcnt |
| 21 |
%\def\_indexize#1[#2]{{% |
| 22 |
% \globalsetters% |
| 23 |
% \anchor{index@anchor@\the\indexcnt}% |
| 24 |
% \lowercase{\def\_temp{#1}}% |
| 25 |
% \_xp\_rfindarray\_xp{\_temp}{index_listing}{\_regA}% |
| 26 |
% \ifx\@return@value\False% |
| 27 |
% \_xp\_rappendarray\_xp{\_temp}{index_listing}% |
| 28 |
% \fi% |
| 29 |
% \unless\ifcsname arr@index@\_temp @pages\endcsname% |
| 30 |
% \createarray{index@\_temp @pages}% |
| 31 |
% \fi% |
| 32 |
% \_xp\_addtoindex\_xp{\_temp}{#2}% |
| 33 |
% \global\advance\indexcnt by 1\relax% |
| 34 |
%}} |
| 35 |
% |
| 36 |
%\def\indexize#1{\_ifnextchar[ {\_indexize{#1}}{\_indexize{#1}[]}} |
| 37 |
|
| 38 |
\def\_lowercasedef#1#2{% |
| 39 |
\lowercase{\def#1{#2}}% |
| 40 |
} |
| 41 |
|
| 42 |
\def\_indexize{{% |
| 43 |
\globalsetters% |
| 44 |
\anchor{index@anchor@\the\indexcnt}% |
| 45 |
\_xp\_runiqueappendarray\_xp{\_category}{index_listing}% |
| 46 |
\ensurearray{index@category@\_category}% |
| 47 |
\unless\ifx\_item\empty% |
| 48 |
\_xp\_runiqueappendarray\_xp{\_item}{index@category@\_category}% |
| 49 |
\fi% |
| 50 |
\ensurearray{index@\_category:\_item}% |
| 51 |
\_xp\_rappendarray\_xp{\_value}{index@\_category:\_item}% |
| 52 |
%\_xp\_addtoindex\_xp{\_category}{#2}% |
| 53 |
\global\advance\indexcnt by 1\relax% |
| 54 |
}} |
| 55 |
|
| 56 |
\def\indexize#1{% |
| 57 |
\mapkeys{% |
| 58 |
category={% |
| 59 |
name=_category, |
| 60 |
definition=\_lowercasedef, |
| 61 |
required% |
| 62 |
}, |
| 63 |
item={% |
| 64 |
name=_item, |
| 65 |
definition=\_lowercasedef, |
| 66 |
default=% |
| 67 |
}, |
| 68 |
value={% |
| 69 |
name=_value, |
| 70 |
required% |
| 71 |
}, |
| 72 |
expand value, |
| 73 |
add hyperlink% |
| 74 |
}{#1}% |
| 75 |
\keyexists{expand value}{\_regA}\lastkeys% |
| 76 |
\unless\ifx\_regA\_nul% |
| 77 |
\edef\_value{\_value}% |
| 78 |
\fi% |
| 79 |
\keyexists{add hyperlink}{\_regA}\lastkeys% |
| 80 |
\unless\ifx\_regA\_nul% |
| 81 |
\_xp\def\_xp\_value\_xp{\_xp\unexpanded\_xp{\_value}}% |
| 82 |
\edef\_value{\noexpand\gotoanchor{index@anchor@\the\indexcnt}{\_value}}% |
| 83 |
\fi% |
| 84 |
\_indexize% |
| 85 |
} |
| 86 |
|
| 87 |
\def\_seealso{{% |
| 88 |
\globalsetters% |
| 89 |
\_xp\_runiqueappendarray\_xp{\_category}{index_listing}% |
| 90 |
\unless\ifx\_item\empty% |
| 91 |
\ensurearray{index@category@\_category}% |
| 92 |
\_xp\_runiqueappendarray\_xp{\_item}{index@category@\_category}% |
| 93 |
\fi% |
| 94 |
\ensurearray{index@\_category:\_item @see-also}% |
| 95 |
\_xp\_rappendarray\_xp{\_dest}{index@\_category:\_item @see-also}% |
| 96 |
}} |
| 97 |
|
| 98 |
\def\seealso#1{% |
| 99 |
\mapkeys{% |
| 100 |
category={% |
| 101 |
name=_category, |
| 102 |
definition=\_lowercasedef, |
| 103 |
required% |
| 104 |
}, |
| 105 |
item={% |
| 106 |
name=_item, |
| 107 |
definition=\_lowercasedef, |
| 108 |
default=% |
| 109 |
}, |
| 110 |
dest={% |
| 111 |
name=_dest, |
| 112 |
required% |
| 113 |
}, |
| 114 |
hyperlink={ |
| 115 |
name=_hlink% |
| 116 |
}, |
| 117 |
index link% |
| 118 |
}{#1}% |
| 119 |
\keyexists{hyperlink}{\_regA}\lastkeys% |
| 120 |
\unless\ifx\_regA\_nul% |
| 121 |
\_xp\def\_xp\_dest\_xp{\_xp\unexpanded\_xp{\_dest}}% |
| 122 |
\keyexists{index link}{\_regA}\lastkeys% |
| 123 |
\ifx\_regA\_nul% |
| 124 |
\edef\_dest{\noexpand\gotoanchor{\_hlink}{\_dest}}% |
| 125 |
\else% |
| 126 |
\edef\_dest{\noexpand\gotoanchor{index@\_hlink @anchor}{\_dest}}% |
| 127 |
\fi% |
| 128 |
\fi% |
| 129 |
\_seealso% |
| 130 |
} |
| 131 |
|
| 132 |
\newif\ifsecondcol |
| 133 |
\newbox\firstcol |
| 134 |
\newdimen\ohsize \ohsize=\hsize |
| 135 |
|
| 136 |
\unless\ifcsname makeheadline\endcsname |
| 137 |
\def\makeheadline{} |
| 138 |
%\def\makefootline{\hbox to\hsize{\baselineskip=24pt \lineskiplimit=0pt\hfil\thepage\hfil}} |
| 139 |
\def\makefootline{} |
| 140 |
\fi |
| 141 |
|
| 142 |
\def\twocoloutput{% |
| 143 |
\ifsecondcol% |
| 144 |
\shipout\vbox{\makeheadline\hbox to\ohsize{\box\firstcol\hfil\box255}\hsize=\ohsize\makefootline}% |
| 145 |
\global\secondcolfalse% |
| 146 |
\else% |
| 147 |
\global\setbox\firstcol=\vbox{\box255}% |
| 148 |
\global\secondcoltrue% |
| 149 |
\fi% |
| 150 |
\unless\ifnum\outputpenalty>-\@MM |
| 151 |
\ifsecondcol \null\eject\fi |
| 152 |
\fi% |
| 153 |
} |
| 154 |
|
| 155 |
\def\_titlecase#1{\uppercase{#1}} |
| 156 |
\def\titlecase#1{\_titlecase#1} |
| 157 |
|
| 158 |
% #1: category #2: type |
| 159 |
\def\print_index_type#1#2#3{% |
| 160 |
\par\quitvmode% |
| 161 |
{% |
| 162 |
\advance\leftskip by .5cm\relax |
| 163 |
\kern-.5cm\titlecase{#2}\anchor{index@#1:#2@anchor}: |
| 164 |
\ifcsname arr@index@#1:#2\endcsname |
| 165 |
\quitvmode\printarray{index@#1:#2}\par |
| 166 |
\fi% |
| 167 |
\ifcsname arr@index@#1:#2@see-also\endcsname% |
| 168 |
{\advance\leftskip by .25cm\relax |
| 169 |
\quitvmode\kern-.25cm\relax See also: \printarray{index@#1:#2@see-also}\par}% |
| 170 |
\fi% |
| 171 |
}% |
| 172 |
} |
| 173 |
|
| 174 |
% #1: category |
| 175 |
\def\print_index_category#1#2{% |
| 176 |
\par\quitvmode{% |
| 177 |
\advance\leftskip by .5cm\relax |
| 178 |
\kern-.5cm\titlecase{#1}\anchor{index@#1:@anchor}: |
| 179 |
\ifcsname arr@index@#1:\endcsname% |
| 180 |
\printarray{index@#1:}\par% |
| 181 |
\fi% |
| 182 |
\ifcsname arr@index@category@#1\endcsname% |
| 183 |
\sortarr{index@category@#1}{index@category@#1}\_cmp_str% |
| 184 |
\arraymap{index@category@#1}{\print_index_type{#1}}\par% |
| 185 |
\fi% |
| 186 |
\ifcsname arr@index@#1:@see-also\endcsname% |
| 187 |
\par{\advance\leftskip .25cm\relax |
| 188 |
\quitvmode\kern-.25cm See also: \printarray{index@#1:@see-also}\par}% |
| 189 |
\fi% |
| 190 |
}% |
| 191 |
} |
| 192 |
|
| 193 |
\def\index{% |
| 194 |
{%\hsize=0.4\hsize% |
| 195 |
\parindent=\z@% |
| 196 |
%\output={\twocoloutput}% |
| 197 |
\section{Index}% |
| 198 |
\sortarr{index_listing}{index_listing}\_cmp_str% |
| 199 |
\arraymap{index_listing}\print_index_category% |
| 200 |
\par\vfill\penalty-\@MM\eject}% |
| 201 |
} |
| 202 |
|
| 203 |
\def\@defaultindexval{\the\pageno} |
| 204 |
\def\_addtoindex#1[#2]{\indexize{category=#1, item=#2, value=\@defaultindexval, expand value, add hyperlink}} |
| 205 |
\def\addtoindex#1{\_ifnextchar[ {\_addtoindex{#1}}{\_addtoindex{#1}[]}} |
| 206 |
|
| 207 |
|