Debian Codegraph @

texmf-dist/source/latex/indextra/indextra.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 2025 Alan J. Cain
4 %
5 % This file may be distributed and/or modified under the conditions of the LaTeX Project Public License, either version
6 % 1.3c of this license or (at your option) any later version. The latest version of this license is in:
7 %
8 % http://www.latex-project.org/lppl.txt
9 %
10 % and version 1.3c or later is part of all distributions of LaTeX version 2008-05-04 or later.
11 %
12 % \fi
13 %
14 % \iffalse
15 %<*driver>
16 \PassOptionsToPackage{inline}{enumitem}
17 \documentclass{l3doc}
18
19
20 \makeatletter
21 \ExplSyntaxOn
22
23 \cs_gset:Npn \l@subsection { \@dottedtocline{2}{2.5em}{2.8em} } % #2 = 1.5em
24 \cs_gset:Npn \l@subsubsection { \@dottedtocline{3}{5.3em}{3.2em} } % #2 = 1.5em
25
26 \ExplSyntaxOff
27 \makeatother
28
29
30 \usepackage{xcolor}
31
32 \definecolor{linkcolor}{rgb}{0.0,0.4,0.7}
33 \colorlet{citecolor}{linkcolor}
34 \colorlet{urlcolor}{linkcolor}
35
36 \hypersetup{
37 linkcolor=linkcolor,%
38 citecolor=citecolor,%
39 urlcolor=urlcolor,%
40 }
41
42
43 \newcommand*\fullref[2]{%
44 \hyperref[#2]{#1\penalty 200\ \ref*{#2}}%
45 }
46
47
48 \numberwithin{figure}{section}
49 \numberwithin{table}{section}
50
51
52
53 \usepackage{mathtools}
54 \DeclarePairedDelimiter{\abs}{\lvert}{\rvert}
55 \DeclarePairedDelimiter{\set}{\lbrace}{\rbrace}
56
57
58
59 \newcommand*\key[1]{\texttt{#1}}
60 \newcommand*\val[1]{\texttt{#1}}
61 \newcommand*\keyval[2]{\texttt{#1=#2}}
62 \newcommand*\ttdashdash{\texttt{-}\texttt{-}\hskip 0pt\relax}
63
64
65 \NewDocumentCommand{\default}{ m }{(\textit{Default:} #1)}
66
67
68 \newcommand*\mcode[1]{\texttt{#1}}
69
70
71 \newcommand*\param[1]{\texttt{\##1}}
72
73
74 \newcommand*\MakeIndex{\textit{MakeIndex}}
75 \newcommand*\upmendex{\texttt{upmendex}}
76 \newcommand*\xindy{\texttt{xindy}}
77
78
79 \usepackage{siunitx}
80 \sisetup{
81 mode=match,
82 }
83 \DeclareSIUnit\point{pt}
84 \DeclareSIUnit\spoint{sp}
85
86
87 \newcommand*\purl[1]{\textsc{url:}~\url{#1}}
88
89
90 \usepackage{listings}
91
92
93
94 \usepackage{indextra}
95
96
97
98 \begin{document}
99 \DocInput{indextra.dtx}
100 \end{document}
101 %</driver>
102 % \fi
103 %
104 %
105 %
106 % \GetFileInfo{indextra.sty}
107 %
108 % \makeatletter
109 % \lstset{
110 % language=[LaTeX]TeX,
111 % columns=fullflexible,
112 % keepspaces=true,
113 % commentstyle=\slshape,
114 % basicstyle=\ttfamily\lst@ifdisplaystyle\small\fi,
115 % }
116 % \makeatother
117 %
118 %
119 %
120 % \title{^^A
121 % \pkg{indextra} ^^A
122 % --- Enhanced index typesetting^^A
123 % \thanks{This file describes \fileversion, last revised \filedate.}^^A
124 % }
125 %
126 % \author{^^A
127 % Alan J. Cain\thanks{Email:~\texttt{a.j.cain (AT) gmail.com}}^^A
128 % }
129 %
130 % \date{Released \filedate}
131 %
132 % \maketitle
133 %
134 %
135 %
136 % \begin{abstract}
137 % This package provides some enhanced features for typesetting indexes, notably: (1) Continuation text when entries or
138 % sub-entries continue from one page or column to the next. (2) An interface for accessing marks created from index
139 % entries, so that (for example) a running head can include the range of index entries that appears on the page.
140 % \end{abstract}
141 %
142 %
143 %
144 % \tableofcontents
145 %
146 %
147 %
148 % \begin{documentation}
149 %
150 % \section{Introduction}
151 %
152 % By default, an index in a \LaTeX\ document is typeset in two columns and provides no indication if a page or column
153 % break occurs inside an index entry or sub-entry. The package
154 % \pkg{repeatindex}\footnote{\purl{https://ctan.org/pkg/repeatindex}} handles a page or column break that occurs between
155 % sub-entries within the same entry by repeating the keyword of the main entry. But it does not repeat the keyword of a
156 % sub-entry when a page or column break occurs within it. Nor does it repeat the keyword of an entry (at the top level)
157 % % if the break occurs mid-way through a long list of pages or ranges for that entry directly.
158 % In \emph{The \TeX book}, Knuth described a plain \TeX\ method to create continuation texts using the mark mechanism
159 % \cite[pp.~261--3]{knuth_texbook}, which does not have these limitations. But there are still situations in which this
160 % method can cause problems: for instance, if the keyword in the index entry spans two or more lines, it may break
161 % across a page or column and the continuation text would appear in the middle of the keyword.
162 %
163 % The \pkg{indextra} package is intended to create suitable continuation texts for all of these possibilities. An
164 % example is shown in \fullref{Figure}{fig:indextra-doc-demo}, where the list of locations within a sub-entry is too
165 % long to fit in the left-hand column. At the top of the right-hand column, \pkg{indextra} has indicated that both the
166 % main entry and the sub-entry have both been continued. If there had been a page break as well as a column break, the
167 % same indicators would have been placed at the start of the left-hand column of the next page.
168 %
169 % \begin{figure}[t]
170 % \centering
171 % \includegraphics{indextra-doc-demo.pdf}
172 % \caption{An example of how \pkg{indextra} continues an entry and a sub-entry after a column or page break.}
173 % \label{fig:indextra-doc-demo}
174 % \end{figure}
175 %
176 % \pkg{indextra} tries to break columns intelligently. If only one line of a multi-line index entry would fit in the
177 % remaining space of the current column, the column break is inserted first, since there would be no saving in space
178 % because the continutation text would occupy (at least) one line of the next column. Similarly, it will not break a
179 % column before or during any cross-references in the index entry.
180 %
181 % \pkg{indextra} also supplies a system for retrieving index entry keywords as marks, for use in running heads to show
182 % the range of index entries on the current page. The keywords of the first and last top-level entries on each page are
183 % available as \cs{indextrafirstmark} and \cs{indextralastmark}.
184 %
185 % \medskip
186 % \noindent\textit{Caveat:}~~Although \pkg{indextra} has been used successfully for the indexes of the author's
187 % books,\footnote{Available on the Internet Archive under Creative Commons licences:\par
188 % (1)~A.J. Cain, \textit{Form \& Number: A History of Mathematical Beauty}. Lisbon, 2024.
189 % \purl{https://archive.org/details/cain_formandnumber_ebook_large}\par
190 % (2)~G.H. Hardy, \textit{An Annotated Mathematician's Apology}. With annotations and commentary by A.J. Cain. Lisbon,
191 % 2019. \purl{https://archive.org/details/hardy_annotated}} in its current state it should be regarded as
192 % semi-experimental, requiring further development, and having many limitations and some incompatibilites (see
193 % \fullref{Subsection}{subsec:limitations}).
194 %
195 %
196 %
197 % \section{Requirements}
198 %
199 % \pkg{indextra} does not depend on any other packages, but requires a recent \LaTeX\ kernel with \pkg{expl3} support.
200 % (Any kernel version since 2020-02-02 should suffice.)
201 %
202 %
203 %
204 % \section{Installation}
205 %
206 % To install \pkg{indextra} manually, run \texttt{tex indextra.ins} and copy the file \texttt{indextra.sty} to somewhere
207 % \LaTeX\ can find it, \texttt{indextra.ist} to somewhere \MakeIndex\ and/or \upmendex\ can find it, and
208 % \texttt{indextra.xdy} to somewhere \xindy\ can find it. To build the documentation, first compile
209 % \texttt{indextra-doc-demo.tex} to a PDF, then compile \texttt{indextra-doc.tex}.
210 %
211 %
212 %
213 % \section{Getting started}
214 %
215 % \subsection{\LaTeX}
216 %
217 % On the \LaTeX\ side, simply use the package with \lstinline!\usepackage{indextra}!. (There are no package options.)
218 % Use \cs{makeindex} and \cs{index} as as usual. Note that \pkg{indextra} is incompatible with \pkg{imakeindex}.
219 %
220 % If the \pkg{hyperref} package is used, set \keyval{hyperindex}{false} in its package options or in \cs{hypersetup},
221 % because \pkg{indextra} has its own mechanism to add index hyperlinks, activated by its own \key{hyperindex} key.
222 %
223 %
224 %
225 % \subsection{Index generation}
226 %
227 % The \file{.ind} file (generated by \MakeIndex, \upmendex, or \xindy) must be specially formatted for \pkg{indextra}.
228 % The style file \file{indextra.ist} is supplied for use with \MakeIndex\ and \upmendex. It can be used with:\par
229 % \texttt{makeindex -s indextra.ist \meta{filename}.idx}\par
230 % \noindent or\par
231 % \texttt{upmendex -s indextra.ist \meta{filename}.idx}\par
232 % \noindent Also supplied is a barebones \xindy\ module \file{indextra.xdy} style file, which should be used with other
233 % modules to set up sorting and attributes. The module \file{indextra.xdy} should be specified last when invoking
234 % \xindy, to override any previous specification of how to write to the \file{.idx} file. For example, one might
235 % use:\par
236 % \texttt{xindy -M makeidx.xdy -M utf8.xdy -M indextra.xdy \meta{filename}.idx}
237 %
238 %
239 %
240 % \section{Configuration}
241 %
242 % \begin{function}{\indextrasetup}
243 % \begin{syntax}
244 % \cs{indextrasetup}\marg{options}
245 % \end{syntax}
246 % This command is used to specify options. The argument \meta{options} is a key--value list. The options are described
247 % in the subsections below and are summarized in \fullref{Table}{tbl:keys-summary}.
248 % \end{function}
249 %
250 % \begin{table}[t]
251 % \addtolength{\leftskip}{-12mm}%
252 % \addtolength{\textwidth}{12mm}%
253 % \caption{Summary of keys that can be set using \cs{indextrasetup}.}
254 % \label{tbl:keys-summary}
255 % \begin{tabular*}{\textwidth}{lll@{\extracolsep{\fill}}}
256 % \toprule
257 % \textsf{Key name} & \textsf{Value} & \textsf{Default} \\
258 % \midrule
259 % \key{before code} & \LaTeX\ code & \val{\cs{begin}\{theindex\}} \\
260 % \key{after code} & \LaTeX\ code & \val{\cs{end}\{theindex\}} \\
261 % \key{level 0 style} & \LaTeX\ code & \val{\cs{parindent}=0em\cs{hangindent}=3.75em} \\
262 % \key{level 1 style} & \LaTeX\ code & \val{\cs{parindent}=1.5em\cs{hangindent}=5.25em} \\
263 % \key{level 2 style} & \LaTeX\ code & \val{\cs{parindent}=3em\cs{hangindent}=6.75em} \\
264 % \key{separator keyword crossref} & \LaTeX\ code & \cs{break} \\
265 % \key{separator keyword location} & \LaTeX\ code & \cs{space}\cs{space} \\
266 % \key{separator crossref crossref} & \LaTeX\ code & \cs{break} \\
267 % \key{separator crossref location} & \LaTeX\ code & \cs{break} \\
268 % \key{separator location location} & \LaTeX\ code & \val{,\textvisiblespace} \\
269 % \key{crossref macros} & List of macros & \cs{see}\cs{seealso} \\
270 % \key{hyperindex} & \(\set{\val{true},\val{false}}\) & \val{true} \\
271 % \key{bookmarks} & \(\set{\val{true},\val{false}}\) & \val{true} \\
272 % \bottomrule
273 % \end{tabular*}
274 % \end{table}
275 %
276 %
277 %
278 % \subsection{Before and after code}
279 %
280 % \DescribeOption{before code}
281 % This option specifies code that is executed at the start of the index (more specifically,
282 % at the start of the \env{theindextra} environment in the generated \file{.ind} file). The code will be executed before
283 % \pkg{indextra} sets various parameters and makes available the commands described in
284 % \fullref{Section}{sec:ind-macros}. The user may wish to use this option to set up running heads using \pkg{indextra}'s
285 % marks (see \fullref{Subsection}{subsec:example-marks} for an example). \default{\cs{begin}\mcode{\{theindex\}}}
286 %
287 % \DescribeOption{after code}
288 % This option specifies code that is executed at end start of the index (more specifically,
289 % at the end of the \env{theindextra} environment in the generated \file{.ind} file).
290 % \default{\cs{begin}\mcode{\{theindex\}}}
291 %
292 %
293 %
294 % \subsection{Styles}
295 %
296 % \DescribeOption{level \(n\) style} The style applied to an index entry at level \(n = 0,1,2\) (that is, respectively
297 % to an entry, a sub-entry, and a sub-sub-entry).
298 %
299 % \noindent
300 % \begin{tabular}{@{}r@{~}l}
301 % (\textit{Default:} & \keyval{level 0 style}{\cs{parindent}=0em\allowbreak\cs{hangindent}=3.75em}; \\
302 % & \keyval{level 1 style}{\cs{parindent}=1.5em\cs{hangindent}=5.25em}; \\
303 % & \keyval{level 2 style}{\cs{parindent}=3em\allowbreak\cs{hangindent}=6.75em})
304 % \end{tabular}
305 %
306 %
307 %
308 % \subsection{Separators}
309 %
310 % \pkg{indextra} always typesets cross-references before locations in each index entry, sub-entry, or sub-sub-entry. The
311 % following options specify the separators to be used.
312 %
313 % \DescribeOption{separator keyword crossref}
314 % The separator to be placed between the keyword of an index entry and a cross-reference. \default{\cs{break}}
315 %
316 % \DescribeOption{separator keyword location}
317 % The separator to be placed between the keyword of an index entry and a location (that is, a page or range of pages),
318 % when the first location immediately follows the keyword (when there are no cross-references).
319 % \default{\cs{space}\cs{space}}
320 %
321 % \DescribeOption{separator crossref crossref}
322 % The separator to be placed between the two cross-references in an index entry. \default{\cs{break}}
323 %
324 % \DescribeOption{separator crossref location}
325 % The separator to be placed between the last cross-reference in an entry and the first location. \default{\cs{break}}
326 %
327 % \DescribeOption{separator location location}
328 % The separator to be placed between two locations in an index entry. \default{\texttt{,\textvisiblespace}}
329 %
330 %
331 %
332 % \subsection{Specification of cross-references}
333 %
334 % \DescribeOption{crossref macros}
335 % A list of macros that signify cross-references. \default{\cs{see}\cs{seealso}}
336 %
337 %
338 %
339 % \subsection{Hyperlinks}
340 %
341 % \DescribeOption{hyperindex}
342 % A boolean \val{true}/\val{false} that indicates whether index locations should be hyperlinked if the \cs{hyperpage}
343 % macro from the \pkg{hyperref} package is available. Note that a user redefinition of \cs{indextrapage} or
344 % \cs{indextrarange} (see \fullref{Subsection}{subsec:user-redefinable-page-range}) will override this setting. If
345 % hyperlinks are required in this case, the user's redefinition should create them. \default{\val{true}}
346 %
347 %
348 %
349 % \subsection{Bookmarks}
350 %
351 % \DescribeOption{bookmarks}
352 % A boolean \val{true}/\val{false} that indicates whether the beginning of each group of index entries (usually terms
353 % beginning with a particular letter) should be bookmarked if the \cs{belowpdfbookmark} macro from the \pkg{hyperref}
354 % package is available. \default{\val{true}}
355 %
356 %
357 %
358 % \subsection{Headings}
359 %
360 % \DescribeOption{headings} A boolean \val{true}/\val{false} that indicates whether there should be a heading at the
361 % beginning of each group of index entries (usually terms beginning with a particular letter). This heading will be
362 % created by the user-redefinable macro \cs{indextramakegroupheading} (see
363 % \fullref{Subsection}{subsec:user-redefinable-heading}). \default{\val{true}}
364 %
365 %
366 %
367 % \section{Marks}
368 %
369 % \pkg{indextra} uses the keyword of each (top-level) index entry to insert a mark. The following macros make available
370 % the first and last marks on the current page. They are intended for use in a running header to show the range of
371 % entries on the current page.
372 %
373 % \begin{function}{\indextrafirstmark}
374 % The first mark on the current page, with the macro \cs{indextramakemark} applied.
375 % \end{function}
376 %
377 % \begin{function}{\indextralastmark}
378 % The last mark on the current page, with the macro \cs{indextramakemark} applied.
379 % \end{function}
380 %
381 %
382 %
383 % \section{User-redefinable macros}
384 %
385 % \subsection{Keywords}
386 %
387 % The following macros is used to typeset keywords of entries, sub-entries, and sub-sub-entries. It can be redefined by
388 % the user.
389 %
390 % \begin{function}{\indextrakeyword}
391 % \begin{syntax}
392 % \cs{indextrakeyword}\marg{level}\marg{keyword}
393 % \end{syntax}
394 % This macro is used to typeset a keyword for an entry of level \meta{level}. The default definition simply yields
395 % \meta{keyword}. Users may wish to use a redefinition to apply styling or for other purposes. The result will already
396 % have the code specified in \key{level \meta{level} style} applied.
397 % \end{function}
398 %
399 %
400 %
401 % \subsection{Page and range typesetting}
402 % \label{subsec:user-redefinable-page-range}
403 %
404 % The following two macros are actually used to typeset locations. They can be redefined by the user.
405 %
406 % \begin{function}{\indextrapage}
407 % \begin{syntax}
408 % \cs{indextrapage}\marg{encapsulation}\marg{page}
409 % \end{syntax}
410 % This command is used to typeset a reference to a single page. The default definition is effectively
411 % \meta{encapsulation}\texttt{\{}\meta{page}\texttt{\}}, but using the configuration option \keyval{hyperindex}{true}
412 % will create a hyperlink to the actual page. Any redefinition of this command will override the effect of
413 % \keyval{hyperindex}{true}, so if the user still wishes the reference to be a hyperlink to the actual page, the new
414 % definition must create the hyperlink.
415 % \end{function}
416 %
417 % \begin{function}{\indextrarange}
418 % \begin{syntax}
419 % \cs{indextrarange}\marg{encapsulation}\marg{start}\marg{end}
420 % \end{syntax}
421 % This command is used to typeset a reference to a range of pages. The default definition is effectively
422 % \meta{encapsulation}\texttt{\{}\meta{page}\texttt{\}}\ttdashdash\meta{encapsulation}\texttt{\{}\meta{page}\texttt{\}},
423 % but using the configuration option \keyval{hyperindex}{true} will create a hyperlink to the actual pages. Users may
424 % wish to redefine \cs{indextrarange} to abbreviate ranges (so that, for instance, 1024--1025 is replaced by 1024--5).
425 % Any redefinition of this command will override the effect of \keyval{hyperindex}{true}, so if the user still wishes
426 % the references to be hyperlinks to the actual pages, the new definition must create the hyperlinks.
427 % \end{function}
428 %
429 %
430 %
431 % \subsection{Continuation text}
432 %
433 % \pkg{indextra} inserts continuation text for each entry, sub-entry, and sub-sub-entry that has been interrupted by a
434 % page or column break. The following macro creates the continuation text and can be redefined by the user.
435 %
436 % \begin{function}{\indextramakecontinuation}
437 % \begin{syntax}
438 % \cs{indextramakecontinuation}\marg{level}\marg{keyword}
439 % \end{syntax}
440 % This macro is used to generate a continuation text when the entry at \meta{level} with the supplied \meta{keyword}
441 % contains a column break. The default definition simply yields \meta{keyword}\texttt{ (cont.)}. Users may wish to use
442 % a redefinition to apply styling. The continuation text will already have the code specified in \key{level
443 % \meta{level} style} applied.
444 % \end{function}
445 %
446 %
447 %
448 % \subsection{Marks}
449 %
450 % \begin{function}{\indextramakemark}
451 % \begin{syntax}
452 % \cs{indextramakemark}\marg{text}
453 % \end{syntax}
454 % This command is applied to any mark retrieved via either \cs{indextrafirstmark} or \cs{indextralastmark}. The
455 % default definition simply yields \meta{text}. A redefinition could be used to abbreviate or otherwise process
456 % \meta{text}.
457 % \end{function}
458 %
459 %
460 %
461 % \subsection{Headings}
462 % \label{subsec:user-redefinable-heading}
463 %
464 % If the option \keyval{headings}{true} is set, the following macro generates the group heading and can be
465 % redefined by the user.
466 %
467 % \begin{function}{\indextramakegroupheading}
468 % \begin{syntax}
469 % \cs{indextramakegroupheading}\marg{group}
470 % \end{syntax}
471 % This macro is used to generate a heading for \meta{group}. The default definition yields \cs{textbf}\marg{group}.
472 % Users may wish to use a redefinition to apply a different style. Note that even if this command is redefined to
473 % yield nothing, an extra vertical space will still be produced in the index where the heading would have been. To
474 % disable headings and avoid this extra space, set \keyval{headings}{false} using \cs{indextrasetup}.
475 % \end{function}
476 %
477 %
478 %
479 % \section{Macros used in the generated \texorpdfstring{\file{.ind}}{.ind} file}
480 % \label{sec:ind-macros}
481 %
482 % For completeness, this section documents the commands and the enclosing environment used in the generated \file{.ind}
483 % file. None of these is intended to be used or redefined by the user.
484 %
485 % \begin{environment}{theindextra}
486 % Environment containing the generated index.
487 % \end{environment}
488 %
489 % The commands below are only defined inside the \env{theindextra} environment.
490 %
491 % \begin{function}{\indextrastyleversion}
492 % \begin{syntax}
493 % \cs{indextrastyleversion}\marg{version}
494 % \end{syntax}
495 % Specify the \pkg{indextra} version of the style used to generate the \file{.ind} file. (This macro exists in case
496 % future updates change the required format of the \file{.ind} file.)
497 % \end{function}
498 %
499 % \begin{function}{\indextraprocessortype}
500 % \begin{syntax}
501 % \cs{indextraprocessortype}\marg{type}
502 % \end{syntax}
503 % Specify the type of the processor used to generate the \file{.ind} file. (Different encapsulations of ranges, which
504 % must be handled differently, are generated by \MakeIndex/\upmendex\ and by \xindy.) \marg{type} is either
505 % \mcode{ist}, indicating that \MakeIndex\ or \upmendex\ was used, or \mcode{xdy}, indicating that \xindy\ was used.
506 % \end{function}
507 %
508 % \begin{function}{\indextraentry}
509 % \begin{syntax}
510 % \cs{indextraentry}\marg{level}\marg{keyword}\marg{crossrefs-and-locations}
511 % \end{syntax}
512 % This command typesets an index entry, sub-entry, or sub-sub-entry (if \meta{level} is respectively \mcode{0},
513 % \mcode{1}, or \mcode{2}) with the given \meta{keyword}. The parameter \meta{crossrefs-and-locations} is a
514 % comma-separated list of cross-references (using macros such as \cs{see} or \cs{seealso} as specified in the
515 % \key{crossref macros} option) and locations (meaning pages or ranges).
516 % \end{function}
517 %
518 % \begin{function}{\indextraspace}
519 % \begin{syntax}
520 % \cs{indextraspace}
521 % \end{syntax}
522 % This command produces a space of one line in the index.
523 % \end{function}
524 %
525 % \begin{function}{\indextragroup}
526 % \begin{syntax}
527 % \cs{indextragroup}\marg{letter}
528 % \end{syntax}
529 % This command begins the new group \meta{letter}. Depending on configuration, it may produce a heading and/or a
530 % bookmark.
531 % \end{function}
532 %
533 %
534 %
535 % \section{Usage notes and caveats}
536 % \label{sec:usage-notes}
537 %
538 % \subsection{Typesetting process}
539 %
540 % \pkg{indextra} works by tracking how much space is left in each column and intially typesetting each index entry into
541 % a buffer and measuring it. If there is enough space left in the column, the buffer contents are added to the output
542 % and the amount of space left is adjusted appropriately. Otherwise, enough of the buffer as will fit is split off and
543 % output, then a column break is called, the continuation text is added to the top of the remaining content in the
544 % buffer, and the process continues in a new column.
545 %
546 % This process relies on the fact that an index is a highly structured text with a restricted format. Any `exotic' index
547 % entries may break the process.
548 %
549 %
550 %
551 % \subsection{Limitations and incompatibilies}
552 % \label{subsec:limitations}
553 %
554 % \begin{itemize}
555 %
556 % \item When choosing where to break a column, \pkg{indextra} only considers the current entry at the current level.
557 % It does not, for example, automatically decide to insert a column break before a one-line top-level entry
558 % that contains a sub-entry, even though this would be a more desirable result.
559 %
560 % \item \pkg{indextra} cannot cope with \cs{verb} commands in index keywords. (But succeeding in generating such an
561 % \file{.ind} via the usual \LaTeX\ indexing commands would be a challenge.)
562 %
563 % \item \pkg{indextra} is incompatible with \pkg{imakeidx}, which uses the \pkg{multicols} package to set the index
564 % instead of the native \LaTeX\ two-column mode. In particular, \LaTeX\ marks cannot be set from within
565 % the \env{multicols} environment.
566 %
567 % \item \pkg{indextra} should not be used with \pkg{repeatindex}, and in any case replaces its functionality.
568 %
569 % \item \pkg{indextra} cannot be used if the usual indexing system is heavily customized. For example, the
570 % \cls{l3doc} class uses its own specialized implementation of indexing and so \pkg{indextra} cannot be used
571 % alongside it.
572 %
573 % \end{itemize}
574 %
575 %
576 %
577 % \subsection{Example of using marks}
578 % \label{subsec:example-marks}
579 %
580 % One could incorporate marks into the index running heads using by appending suitable code to the default value
581 % (\cs{begin}\mcode{\{theindex\}}) of the \key{before code} key:
582 % \iffalse
583 %<*example>
584 % \fi
585 \begin{lstlisting}
586 \indextrasetup{
587 before code={%
588 \begin{theindex}%
589 \markboth
590 {\MakeUppercase\indexname~%
591 \noexpand\indextrafirstmark--\noexpand\indextralastmark}
592 {\MakeUppercase\indexname~%
593 \noexpand\indextrafirstmark--\noexpand\indextralastmark}%
594 },
595 }
596 \end{lstlisting}
597 % \iffalse
598 %</example>
599 % \fi
600 % (The \cs{noexpand} macros ensure that \cs{indextrafirstmark} and \cs{indextralastmark} are expanded when
601 % the page is shipped out, not when \cs{markboth} is used.)
602 %
603 %
604 %
605 % \begin{thebibliography}{1}
606 %
607 % \bibitem{knuth_texbook}
608 % D.E.~Knuth.
609 % \newblock \emph{{T}he {\TeX book}}.
610 % \newblock Addison--Wesley, 2021.
611 % \newblock \emph{{C}omputers {\&} {T}ypesetting}, vol.~A.
612 %
613 % \end{thebibliography}
614 %
615 %
616 %
617 % \end{documentation}
618 %
619 %
620 %
621 % \begin{implementation}
622 %
623 %
624 %
625 % \section{Implementation}
626 %
627 % \begin{macrocode}
628 %<*package>
629 %<@@=indextra>
630 % \end{macrocode}
631 %
632 %
633 %
634 % \subsection{Initial set-up}
635 %
636 % Package identification/version information.
637 % \begin{macrocode}
638 \NeedsTeXFormat{LaTeX2e}[2020-02-02]
639 \ProvidesExplPackage{indextra}{2025-10-26}{0.21.6}
640 {Enhanced index typesetting}
641 % \end{macrocode}
642 %
643 %
644 %
645 % \subsection{User configuration}
646 %
647 % Set up the key--value options and the variables in which the settings will be stored.
648 %
649 % \begin{variable}{
650 % \l_@@_before_code_tl,
651 % \l_@@_after_code_tl,
652 % }
653 % Token list keys that store code to be executed before and after the index is typeset.
654 % \begin{macrocode}
655 \keys_define:nn { indextra }
656 {
657 before~code .tl_set:N = \l_@@_before_code_tl,
658 after~code .tl_set:N = \l_@@_after_code_tl,
659 before~code .initial:n = {\begin{theindex}},
660 after~code .initial:n = {\end{theindex}},
661 }
662 % \end{macrocode}
663 % \end{variable}
664 %
665 %
666 % \begin{variable}{
667 % \l_@@_level_0_style_tl,
668 % \l_@@_level_1_style_tl,
669 % \l_@@_level_2_style_tl,
670 % }
671 % Token list keys that store the style to be applied to entries at each level.
672 % \begin{macrocode}
673 \keys_define:nn { indextra }
674 {
675 level~0~style .tl_set:c = {l_@@_level_0_style_tl},
676 level~1~style .tl_set:c = {l_@@_level_1_style_tl},
677 level~2~style .tl_set:c = {l_@@_level_2_style_tl},
678 level~0~style .initial:n = {\parindent=0em\hangindent=3.75em},
679 level~1~style .initial:n = {\parindent=1.5em\hangindent=5.25em},
680 level~2~style .initial:n = {\parindent=3em\hangindent=6.75em},
681 }
682 % \end{macrocode}
683 % \end{variable}
684 %
685 %
686 % \begin{variable}{
687 % \l_@@_separator_kw_cr_tl,
688 % \l_@@_separator_kw_loc_tl,
689 % \l_@@_separator_cr_cr_tl,
690 % \l_@@_separator_cr_loc_tl,
691 % \l_@@_separator_loc_loc_tl,
692 % }
693 % Token list keys to store separators. Macros are abbreviated as follows \mcode{kw}: keyword; \mcode{cr}:
694 % cross-reference; \mcode{loc}: location (page or range).
695 % \begin{macrocode}
696 \keys_define:nn { indextra }
697 {
698 separator~keyword~crossref .tl_set:N = \l_@@_separator_kw_cr_tl,
699 separator~keyword~location .tl_set:N = \l_@@_separator_kw_loc_tl,
700 separator~crossref~crossref .tl_set:N = \l_@@_separator_cr_cr_tl,
701 separator~crossref~location .tl_set:N = \l_@@_separator_cr_loc_tl,
702 separator~location~location .tl_set:N = \l_@@_separator_loc_loc_tl,
703 separator~keyword~crossref .initial:n = {\break},
704 separator~keyword~location .initial:n = {\space\space},
705 separator~crossref~crossref .initial:n = {\break},
706 separator~crossref~location .initial:n = {\break},
707 separator~location~location .initial:n = {,~},
708 }
709 % \end{macrocode}
710 % \end{variable}
711 %
712 %
713 % \begin{variable}{
714 % \l_@@_crossref_macros_tl,
715 % }
716 % Token list key to store macros that should count as cross-references.
717 % \begin{macrocode}
718 \keys_define:nn { indextra }
719 {
720 crossref~macros .tl_set:N = \l_@@_crossref_macros_tl,
721 crossref~macros .initial:n = {\see\seealso},
722 }
723 % \end{macrocode}
724 % \end{variable}
725 %
726 %
727 % \begin{variable}{
728 % \l_@@_hyperindex_bool,
729 % }
730 % Boolean indicating whether locations should be hyperlinked to pages, if \cs{hyperpage} is available and the user has
731 % not redefined \cs{indextrapage} and \cs{indextrarange}.
732 % \begin{macrocode}
733 \keys_define:nn { indextra }
734 {
735 hyperindex .bool_set:N = \l_@@_hyperindex_bool,
736 hyperindex .initial:n = {true},
737 }
738 % \end{macrocode}
739 % \end{variable}
740 %
741 %
742 % \begin{variable}{
743 % \l_@@_bookmarks_bool,
744 % }
745 % Boolean indicating whether groups should be bookmarked, if \cs{belowpdfbookmark} is available.
746 % \begin{macrocode}
747 \keys_define:nn { indextra }
748 {
749 bookmarks .bool_set:N = \l_@@_bookmarks_bool,
750 bookmarks .initial:n = {true},
751 }
752 % \end{macrocode}
753 % \end{variable}
754 %
755 %
756 % \begin{variable}{
757 % \l_@@_headings_bool,
758 % }
759 % Boolean indicating whether group headings should appear.
760 % \begin{macrocode}
761 \keys_define:nn { indextra }
762 {
763 headings .bool_set:N = \l_@@_headings_bool,
764 headings .initial:n = {true},
765 }
766 % \end{macrocode}
767 % \end{variable}
768 %
769 %
770 % \begin{macro}{
771 % \indextrasetup,
772 % }
773 % User command to set key--value configuration.
774 % \begin{macrocode}
775 \NewDocumentCommand{\indextrasetup}{ m }
776 {
777 \keys_set:nn{ indextra }{ #1 }
778 }
779 % \end{macrocode}
780 % \end{macro}
781 %
782 %
783 %
784 % \subsection{Environment and commands for the \texorpdfstring{\file{.ind}}{.ind} file}
785 %
786 % Define the environment and commands used in the generated \file{.ind} file.
787 %
788 % \begin{macro}{
789 % theindextra
790 % }
791 % This environment is the analogue of the \env{theindex} environment defined by basic \LaTeX.
792 % \begin{macrocode}
793 \NewDocumentEnvironment{theindextra}{}
794 { \@@_main_begin: }
795 { \@@_main_end: }
796 %
797 % \end{macrocode}
798 % \end{macro}
799 %
800 % \begin{macro}{
801 % \@@_main_begin:
802 % }
803 % This macro (locally) sets various \TeX\ dimensions and defines the commands that are actually used in the index,
804 % namely \cs{indextrastyleversion}, \cs{indextraprocessortype}, \cs{indextraspace}, \cs{indextragroup}, and
805 % \cs{indextraentry}.%
806 % \begin{macrocode}
807 \cs_new:Npn \@@_main_begin:
808 {
809 % \end{macrocode}
810 % Open a group and execute code for before the index has been typeset.
811 % \begin{macrocode}
812 \group_begin:
813 \tl_use:N\l_@@_before_code_tl
814 % \end{macrocode}
815 % Since column breaks will be inserted manually, zero the penalties which influence column/page breaking.
816 % \begin{macrocode}
817 \int_zero:N\clubpenalty
818 \int_zero:N\widowpenalty
819 % \end{macrocode}
820 % Set \cs{splittopskip}, \cs{topskip}, and \cs{parskip} to the needed values, and set
821 % \cs{g_@@_remaining_space_dim}, which tracks the space left in the current column, to the initial value of
822 % \cs{@colht}, which will be the height of the column after any initial two-column text has been typeset.
823 % \begin{macrocode}
824 \dim_gset:Nn\g_@@_remaining_space_dim{\@colht}
825 \dim_set:Nn\splittopskip{.7\baselineskip}
826 \dim_set:Nn\topskip{.7\baselineskip}
827 \dim_set:Nn\parskip{0pt}
828 % \end{macrocode}
829 % Make available the appropriate macros.
830 % \begin{macrocode}
831 \cs_set_eq:NN\indextrastyleversion\@@_style_version:n
832 \cs_set_eq:NN\indextraprocessortype\@@_processor_type:n
833 \cs_set_eq:NN\indextraspace\@@_space:
834 \cs_set_eq:NN\indextragroup\@@_group:n
835 \cs_set_eq:NN\indextraentry\@@_entry:nnn
836 % \end{macrocode}
837 % If user settings require it, or \cs{belowpdfbookmark} is unavailable, disable group bookmarks and/or headings.
838 % \begin{macrocode}
839 \bool_if:nF
840 { \l_@@_bookmarks_bool && \cs_if_exist_p:N\belowpdfbookmark }
841 {
842 \cs_set_eq:NN\@@_bookmark_stored_group:\prg_do_nothing:
843 }
844 \bool_if:NF\l_@@_headings_bool
845 {
846 \cs_set_eq:NN\@@_typeset_stored_group_heading:\prg_do_nothing:
847 }
848 % \end{macrocode}
849 % Depending on user configuration, if \cs{hyperpage} is available and \cs{indextrapage} or \cs{indextrapage} have not
850 % been redefined, then change them to create hyperlinks.
851 % \begin{macrocode}
852 \bool_if:nT{ \l_@@_hyperindex_bool && \cs_if_exist_p:N\hyperpage }
853 {
854 \cs_if_eq:NNT\indextrapage\@@_page_basic:nn
855 {
856 \cs_set_eq:NN\indextrapage\@@_page_hyperref:nn
857 }
858 \cs_if_eq:NNT\indextrarange\@@_range_basic:nnn
859 {
860 \cs_set_eq:NN\indextrarange\@@_range_hyperref:nnn
861 }
862 }
863 }
864 % \end{macrocode}
865 % \end{macro}
866 %
867 % \begin{macro}{
868 % \@@_main_end:
869 % }
870 % Execute code for after the index has been typeset and close the group opened in \cs{@@_main_begin:}.
871 % \begin{macrocode}
872 \cs_new:Npn \@@_main_end:
873 {
874 \tl_use:N\l_@@_after_code_tl
875 \group_end:
876 }
877 % \end{macrocode}
878 % \end{macro}
879 %
880 % \begin{macrocode}
881 \msg_new:nnn{ indextra }{ incompatible_version }
882 { The~.ind~file~was~generated~using~a~style~from~a~different~version~of~indextra. }
883 % \end{macrocode}%
884 %
885 % \begin{macro}{
886 % \@@_style_version:n,
887 % }
888 % Specify the version of \pkg{indextra}'s index processor style file (\file{.ist} or \file{.xdy}) that was used to
889 % generate the \file{.ind} file. If is incompatible with version of \pkg{indextra} in use, an error will result.
890 % \begin{macrocode}
891 \cs_new:Npn\@@_style_version:n #1
892 {
893 \str_if_eq:nnF{#1}{0.1}
894 {
895 \msg_error:nn{ indextra }{ incompatible_version }
896 }
897 }
898 % \end{macrocode}
899 % \end{macro}
900 %
901 %
902 %
903 % \begin{macro}{
904 % \@@_processor_type:n,
905 % }
906 % Set the type of the processor used to generate the \file{.ind} file. \MakeIndex\ and \upmendex\ produce ranges of
907 % the form \cs{encapsulation}\texttt{\{}\meta{start}\ttdashdash\meta{end}\texttt{\}}, while \xindy\ produces ranges of
908 % the form \cs{encapsulation}\texttt{\{}\texttt{\}}\ttdashdash\cs{encapsulation}\texttt{\{}\texttt{\}}. These kinds of
909 % ranges must be parsed differently, and while the kind of range could be detected when typesetting each location,
910 % there are efficiency savings from using a dedicated parser in each case. \param{1} should be either \mcode{ist},
911 % indicating that the processor was either \MakeIndex\ or \upmendex, or \mcode{xdy}, that the processor was \xindy.
912 % This macro will be set equal to \cs{indextrasetprocessortype} inside the \env{theindextra} environment.
913 % \begin{macrocode}
914 \cs_new:Npn\@@_processor_type:n #1
915 {
916 \cs_set_eq:Nc\@@_typeset_aux_location:n
917 { @@_typeset_#1_location:n }
918 }
919 % \end{macrocode}
920 % \end{macro}
921 %
922 %
923 %
924 %
925 % \subsection{Column handling}
926 %
927 % \begin{variable}{
928 % \g_@@_remaining_space_dim,
929 % }
930 % Dimension variable to hold the amount of space left in the current column.
931 % \begin{macrocode}
932 \dim_new:N\g_@@_remaining_space_dim
933 % \end{macrocode}
934 % \end{variable}
935 %
936 % \begin{macro}{
937 % \@@_new_column:
938 % }
939 % Fill any remaining space in the current column, start a new column, and set \cs{g_@@_remaining_space_dim} to
940 % \cs{@colht} (which is the amount of space available in the new column).
941 % \begin{macrocode}
942 \cs_new:Npn\@@_new_column:
943 {
944 \vfill
945 \newpage
946 \dim_gset:Nn\g_@@_remaining_space_dim{\@colht}
947 }
948 % \end{macrocode}
949 % \end{macro}
950 %
951 %
952 %
953 % \subsection{Spaces}
954 %
955 % \begin{macro}{
956 % \@@_space:,
957 % }
958 % Create a space in the index, which will usually signify the end of one letter group and the beginning of another.
959 % This takes up space in the column, so the space (a \cs{strut}) is typeset via the same mechanism as index entries,
960 % namely \cs{@@_typeset_buffer:}.
961 % \begin{macrocode}
962 \cs_new:Npn\@@_space:
963 {
964 \dim_compare:nNnT{\g_@@_remaining_space_dim}<{\baselineskip}{
965 \@@_new_column:
966 }
967 \vbox_set:Nn\l_@@_buffer_box{\leavevmode\strut\par}
968 \@@_typeset_buffer:
969 }
970 % \end{macrocode}
971 % \end{macro}
972 %
973 %
974 %
975 % \subsection{Groups}
976 %
977 % \begin{variable}{
978 % \l_@@_group_tl
979 % }
980 % Token-list variable to store the current group.
981 % \begin{macrocode}
982 \tl_new:N\l_@@_group_tl
983 % \end{macrocode}
984 % \end{variable}
985 %
986 %
987 % \begin{macro}{
988 % \@@_group:,
989 % }
990 % Begin a letter group in the index. The macro simply stores the group title; the bookmark and/or heading will be
991 % created by the next index entry. This macro will be set equal to \cs{indextragroup} inside the \env{theindextra}
992 % environment.
993 % \begin{macrocode}
994 \cs_new:Npn\@@_group:n #1
995 {
996 \tl_set:Nn\l_@@_group_tl{#1}
997 }
998 % \end{macrocode}
999 % \end{macro}
1000 %
1001 %
1002 % \begin{variable}{
1003 % \g_@@_group_bookmark_int
1004 % }
1005 % Integer variable to index groups; used in the creation of bookmarks in \cs{@@_bookmark_stored_group:}.
1006 % \begin{macrocode}
1007 \int_new:N\g_@@_group_bookmark_int
1008 % \end{macrocode}
1009 % \end{variable}
1010 %
1011 %
1012 % \begin{macro}{
1013 % \@@_bookmark_stored_group:
1014 % }
1015 % If \cs{l_@@_group_tl} is non-empty, create a bookmark below the current level (i.e., using \cs{belowpdfbookmark}),
1016 % using \cs{l_@@_group_tl} for the bookmark text. The variable \cs{g_@@_group_bookmark_int} is incremented at each
1017 % call and used to create distinct bookmark names. (One cannot use the the content of \cs{l_@@_group_tl} for the
1018 % bookmark name, because (1) it might not be suitable as a name, and (2) there may be two indexes (e.g. names and
1019 % subjects) which contain the same groups.)
1020 % \begin{macrocode}
1021 \cs_new:Npn\@@_bookmark_stored_group:
1022 {
1023 \tl_if_empty:NF\l_@@_group_tl
1024 {
1025 \int_gincr:N\g_@@_group_bookmark_int
1026 \belowpdfbookmark
1027 {\tl_use:N\l_@@_group_tl}
1028 {pdf:indextra:\int_value:w\g_@@_group_bookmark_int}
1029 }
1030 }
1031 % \end{macrocode}
1032 % \end{macro}
1033 %
1034 %
1035 % \begin{macro}{
1036 % \@@_typeset_stored_group_heading:
1037 % }
1038 % If \cs{l_@@_group_tl} is non-empty, typeset its contents as a heading for the group.
1039 % \begin{macrocode}
1040 \cs_new:Npn\@@_typeset_stored_group_heading:
1041 {
1042 \tl_if_empty:NF\l_@@_group_tl
1043 {
1044 \group_begin:
1045 \noindent\strut
1046 \indextramakegroupheading{\tl_use:N\l_@@_group_tl}
1047 \strut\par
1048 \group_end:
1049 }
1050 }
1051 % \end{macrocode}
1052 % \end{macro}
1053 %
1054 %
1055 % \begin{macro}{
1056 % \indextramakegroupheading
1057 % }
1058 % Typeset a heading for the letter group passed as \param{1}.
1059 % \begin{macrocode}
1060 \cs_new:Npn\indextramakegroupheading #1
1061 {
1062 \textbf{#1}
1063 }
1064 % \end{macrocode}
1065 % \end{macro}
1066 %
1067 %
1068 %
1069 %
1070 %
1071 % \subsection{Entries}
1072 %
1073 % \begin{variable}{
1074 % \l_@@_level_int
1075 % }
1076 % Integer variable to hold the level of the current entry.
1077 % \begin{macrocode}
1078 \int_new:N\l_@@_level_int
1079 % \end{macrocode}
1080 % \end{variable}
1081 %
1082 %
1083 % \begin{variable}{
1084 % \l_@@_saved_keyword_0,
1085 % \l_@@_saved_keyword_1,
1086 % \l_@@_saved_keyword_2,
1087 % }
1088 % Token list variables to save keywords at each level.
1089 % \begin{macrocode}
1090 \tl_new:c{l_@@_saved_keyword_0}
1091 \tl_new:c{l_@@_saved_keyword_1}
1092 \tl_new:c{l_@@_saved_keyword_2}
1093 % \end{macrocode}
1094 % \end{variable}
1095 %
1096 %
1097 % \begin{variable}{
1098 % \l_@@_crossref_seq,
1099 % \l_@@_location_seq,
1100 % }
1101 % Comma-separated list variables to hold the cross-references and locations of the current entry. These will be
1102 % populated via a call to \cs{@@_filter_crossref_location_seqs:n}
1103 % \begin{macrocode}
1104 \seq_new:N\l_@@_crossref_seq
1105 \seq_new:N\l_@@_location_seq
1106 % \end{macrocode}
1107 % \end{variable}
1108 %
1109 %
1110 % \begin{macro}{
1111 % \@@_entry:nnn,
1112 % }
1113 % Typeset an index entry. The three parameters are the level (\param{1}), the keyword (\param{2}), and the rest of the
1114 % entry (\param{3}), which should be a comma-separated list of cross-references and/or locations.
1115 % \begin{macrocode}
1116 \cs_new:Npn\@@_entry:nnn #1#2#3
1117 {
1118 % \end{macrocode}
1119 % First save the level and the keyword, and sort the rest of the entry into the cross-reference and location seqs.
1120 % \begin{macrocode}
1121 \int_set:Nn\l_@@_level_int{#1}
1122 \tl_set:cn{l_@@_saved_keyword_#1}{#2}
1123 \@@_filter_crossref_location_seqs:n{#3}
1124 % \end{macrocode}
1125 % Typeset the entire entry (prefixed by any stored group heading) into \cs{l_@@_buffer_box}. The bookmarking command
1126 % is also executed here, since it is the contents of this box that will ultimately be shipped out.
1127 % \begin{macrocode}
1128 \vbox_set:Nn\l_@@_buffer_box{
1129 \@@_bookmark_stored_group:
1130 \@@_typeset_stored_group_heading:
1131 \group_begin:
1132 \@@_set_style:n{#1}
1133 \leavevmode
1134 \strut
1135 \indextrakeyword{#1}{#2}
1136 \@@_typeset_between:
1137 \@@_typeset_locations:
1138 \strut
1139 \par
1140 \goodbreak
1141 \group_end:
1142 }
1143 % \end{macrocode}
1144 % Now typeset some material into \cs{l_tmpa_box} and \cs{l_tmpb_box}, the dimensions of which will be used in
1145 % computing the minimum acceptable portion of the entry to typeset into the current column. First, typeset the part of
1146 % the entry where a column break is unacceptable (prefixed by any stored group heading) into \cs{l_tmpa_box}.
1147 % \begin{macrocode}
1148 \vbox_set:Nn\l_tmpa_box{
1149 \@@_typeset_stored_group_heading:
1150 \group_begin:
1151 \@@_set_style:n{#1}
1152 \leavevmode
1153 \strut
1154 \indextrakeyword{#1}{#2}
1155 \@@_typeset_between:
1156 \@@_typeset_first_location:
1157 \strut
1158 \par
1159 \group_end:
1160 }
1161 % \end{macrocode}
1162 % Typeset any stored group heading into \cs{l_tmpb_box}.
1163 % \begin{macrocode}
1164 \vbox_set:Nn\l_tmpb_box{
1165 \@@_typeset_stored_group_heading:
1166 }
1167 % \end{macrocode}
1168 % Measuring \cs{l_tmpa_box}, \cs{l_tmpb_box}, and \cs{l_@@_buffer_box}, check whether there is enough space in the
1169 % current column to typeset any stored heading and the minimum acceptable portion of the entry. Basically, a split
1170 % should not occur within the part typeset into \cs{l_tmpa_box}, and if the entry as a whole is longer than one line,
1171 % then at least two lines should be typeset (because if only one line can fit into the current column, there is
1172 % probably no overall saving of space by putting it in the current column with a continuation in the next column).
1173 % Note that if there is no stored heading, the height and depth of \cs{l_tmpb_box} are both \qty{0}{\point}, so no
1174 % conditional is needed.
1175 % \begin{macrocode}
1176 \dim_compare:nNnT
1177 {\g_@@_remaining_space_dim}
1178 <
1179 {
1180 \dim_min:nn{
1181 \dim_max:nn{
1182 \box_ht:N\l_tmpa_box
1183 +\box_dp:N\l_tmpa_box
1184 }{
1185 \box_ht:N\l_tmpb_box
1186 +\box_dp:N\l_tmpb_box
1187 +2\baselineskip
1188 }
1189 }{
1190 \box_ht:N\l_@@_buffer_box
1191 +\box_dp:N\l_@@_buffer_box
1192 }
1193 }
1194 {
1195 % \end{macrocode}
1196 % \textit{Case: not enough space in the current column.} Start a new column and, unless this is a top-level
1197 % entry, insert the appropriate continuation into the \cs{l_@@_buffer_box}.
1198 % \begin{macrocode}
1199 \@@_new_column:
1200 \int_compare:nNnT{#1}>{0}{
1201 \@@_vbox_prepend:Nn\l_@@_buffer_box{
1202 \@@_make_continuation:n{\l_@@_level_int-1}
1203 }
1204 }
1205 }
1206 % \end{macrocode}
1207 % \cs{l_@@_buffer_box} now contains the material that should be typeset onto the page, and there is enough space in
1208 % the current column to typeset a minimal acceptable portion of it. Typesetting is handled by \cs{@@_set_buffer:},
1209 % which may use \tn{vsplit}, which produces a warning `\texttt{Underfull \tn{vbox} (badness 10000)}' with even a
1210 % \qty{1}{\spoint} mismatch between available breakpoints and desired height. For efficiency, \cs{@@_set_buffer:} uses
1211 % an approximation to the desired height, so set \tn{vbadness} to 10000 to suppress these warnings.
1212 % \begin{macrocode}
1213 \group_begin:
1214 \int_set:Nn\vbadness{10000}
1215 \@@_typeset_buffer:
1216 \group_end:
1217 % \end{macrocode}
1218 % Finally, clear any stored group.
1219 % \begin{macrocode}
1220 \tl_clear:N\l_@@_group_tl
1221 }
1222 % \end{macrocode}
1223 % \end{macro}
1224 %
1225 %
1226 %
1227 % \subsubsection{Filtering cross-references and locations}
1228 %
1229 % In each entry, cross-references and locations may be mixed up and need to be filtered into separate lists.
1230 %
1231 % \begin{macro}{
1232 % \@@_filter_crossref_location_seqs:n
1233 % }
1234 % Use the supplied list of cross-references and location (\param{1}), which is a clist, to populate
1235 % \cs{l_@@_crossref_seq} and \cs{l_@@_location_seq}. The list of macros that are the first tokens in
1236 % cross-references is contained in \cs{l_@@_crossref_macros_tl}. All that is required is to check whether the head
1237 % token in each item in the \param{1} is in \cs{l_@@_crossref_macros_tl}. and assign that item to the correct seq.
1238 % \begin{macrocode}
1239 \cs_new:Npn\@@_filter_crossref_location_seqs:n #1
1240 {
1241 \seq_clear:N\l_@@_crossref_seq
1242 \seq_clear:N\l_@@_location_seq
1243
1244 \clist_map_inline:nn{#1}
1245 {
1246 \tl_if_in:NoTF
1247 \l_@@_crossref_macros_tl{ \tl_head:w ##1 {} \q_stop }
1248 {
1249 \seq_put_right:Nn\l_@@_crossref_seq{##1}
1250 }
1251 {
1252 \seq_put_right:Nn\l_@@_location_seq{##1}
1253 }
1254 }
1255 }
1256 % \end{macrocode}
1257 % \end{macro}
1258 %
1259 %
1260 %
1261 % \subsubsection{Style}
1262 %
1263 % \begin{macro}{
1264 % \@@_set_style:n,
1265 % }
1266 % Set up the style for an index entry at the given level.
1267 % \begin{macrocode}
1268 \cs_new:Npn \@@_set_style:n #1
1269 {
1270 \tl_use:c{l_@@_level_#1_style_tl}
1271 }
1272 % \end{macrocode}
1273 % \end{macro}
1274 %
1275 %
1276 %
1277 % \subsubsection{Typesetting keywords}
1278 %
1279 % \begin{macro}{
1280 % \indextrakeyword
1281 % }
1282 % Take a level (\param{1}) and a keyword (\param{2}) and return a (possibly styled) keyword.
1283 % \begin{macrocode}
1284 \cs_new:Npn\indextrakeyword #1#2
1285 {
1286 #2
1287 }
1288 % \end{macrocode}
1289 % \end{macro}
1290 %
1291 %
1292 %
1293 % \subsubsection{Typesetting cross-references}
1294 %
1295 % \begin{macro}{
1296 % \@@_typeset_between:
1297 % }
1298 % Typeset everything between the keyword and the locations. If there are no cross-references, this means typesetting
1299 % just the keyword--location separator if the list of locations is non-empty (it is possible that there are no
1300 % locations; practically, this would happen when all the locations are in sub-entries); otherwise, it means
1301 % typesetting the cross-references with the relevant separators before, after, and between.
1302 % \begin{macrocode}
1303 \cs_new:Npn\@@_typeset_between:
1304 {
1305 \seq_if_empty:NTF\l_@@_crossref_seq
1306 {
1307 \seq_if_empty:NF\l_@@_location_seq
1308 { \tl_use:N\l_@@_separator_kw_loc_tl }
1309 }
1310 {
1311 \tl_use:N\l_@@_separator_kw_cr_tl
1312 \seq_use:Nn
1313 \l_@@_crossref_seq
1314 { \tl_use:N\l_@@_separator_cr_cr_tl }
1315 \seq_if_empty:NF\l_@@_location_seq
1316 { \tl_use:N\l_@@_separator_cr_loc_tl }
1317 }
1318 }
1319 % \end{macrocode}
1320 % \end{macro}
1321 %
1322 %
1323 %
1324 % \subsubsection{Typesetting locations}
1325 %
1326 % \begin{variable}{
1327 % \l_@@_first_item_bool,
1328 % }
1329 % Boolean variable to track whether the current location is the first one in the entry, so that a separator can be
1330 % inserted before every non-first location.
1331 % \begin{macrocode}
1332 \bool_new:N\l_@@_first_item_bool
1333 % \end{macrocode}
1334 % \end{variable}
1335 %
1336 % \begin{macro}{
1337 % \@@_typeset_locations:
1338 % }
1339 % Typeset locations stored in \cs{l_@@_locations_seq}. Using \cs{seq_use:Nn} is not enough, because each entry must be
1340 % processed separately. Thus separators must be inserted `manually'.
1341 % \begin{macrocode}
1342 \cs_new:Npn\@@_typeset_locations:
1343 {
1344 \bool_set_true:N\l_@@_first_item_bool
1345 \seq_map_inline:Nn\l_@@_location_seq
1346 {
1347 \bool_if:nF{\l_@@_first_item_bool}
1348 { \tl_use:N\l_@@_separator_loc_loc_tl }
1349 \@@_typeset_aux_location:n{##1}
1350 \bool_set_false:N\l_@@_first_item_bool
1351 }
1352 }
1353 % \end{macrocode}
1354 % \end{macro}
1355 %
1356 % \begin{macro}{
1357 % \@@_typeset_first location:
1358 % }
1359 % Typeset the first location stored in \cs{l_@@_locations_seq}.
1360 % \begin{macrocode}
1361 \cs_new:Npn\@@_typeset_first_location:
1362 {
1363 \exp_args:Ne\@@_typeset_aux_location:n
1364 {\seq_item:Nn\l_@@_location_seq{1}}
1365 }
1366 % \end{macrocode}
1367 % \end{macro}
1368 %
1369 % \begin{macro}{
1370 % \@@_is_nonrange_p:w
1371 % }
1372 % To be called in the form \cs{@@_is_nonrange_p:w}\meta{parameter}\ttdashdash\cs{q_stop}; uses \TeX\ parsing to check
1373 % whether \meta{parameter} does not contain a range marker \ttdashdash.
1374 % \begin{macrocode}
1375 \cs_new:Npn\@@_is_nonrange_p:w #1--#2\q_stop
1376 {
1377 \tl_if_empty_p:n{#2}
1378 }
1379 % \end{macrocode}
1380 % \end{macro}
1381 %
1382 % \begin{macro}{
1383 % \cs_new:Npn\@@_typeset_ist_location:n
1384 % }
1385 % Typeset a \MakeIndex- or \upmendex-style location. The location might be a
1386 % \begin{itemize}
1387 % \item a single page;
1388 % \item an encapsulated single page \cs{encapsulation}\mcode{\{}\meta{page}\mcode{\}};
1389 % \item a range; or
1390 % \item an encapsulated range \cs{encapsulation}\mcode{\{}\meta{start}\ttdashdash\meta{end}\mcode{\}}.
1391 % \end{itemize}
1392 % \begin{macrocode}
1393 \cs_new:Npn\@@_typeset_ist_location:n #1
1394 {
1395 % \end{macrocode}
1396 % Check for an encapsulation (a leading control sequence, comparing catcode with \cs{prg_do_nothing:} simply as a
1397 % convenience). Either call \cs{@@_typeset_ist_encap_page_or_range:Nn} with this encapsulation or with a `do-nothing'
1398 % encapsulation and the braced parameter.
1399 % \begin{macrocode}
1400 \tl_if_head_eq_catcode:nNTF{#1}\prg_do_nothing:
1401 {
1402 \@@_typeset_ist_encap_page_or_range:Nn #1
1403 }
1404 {
1405 \@@_typeset_ist_encap_page_or_range:Nn \prg_do_nothing:{#1}
1406 }
1407 }
1408 % \end{macrocode}
1409 % \end{macro}
1410 %
1411 % \begin{macro}{
1412 % \@@_typeset_ist_encap_page_or_range:Nn
1413 % }
1414 % Take an encapsulation and a parameter and typeset the parameter as a page or range, as appropriate.
1415 % \begin{macrocode}
1416 \cs_new:Npn\@@_typeset_ist_encap_page_or_range:Nn #1#2
1417 {
1418 \bool_if:nTF{\@@_is_nonrange_p:w #2--\q_stop}
1419 {
1420 % \end{macrocode}
1421 % \textit{Case: not a range.} Parameter \param{2} a single page.
1422 % \begin{macrocode}
1423 \indextrapage{#1}{#2}
1424 }
1425 {
1426 % \end{macrocode}
1427 % \textit{Case: range.} Parameter \param{2} is a range. Call \cs{@@_typeset_ist_encap_range:w} to parse and
1428 % typeset it.
1429 % \begin{macrocode}
1430 \@@_typeset_ist_encap_range:w#1\q_mark #2\q_stop
1431 }
1432 }
1433 % \end{macrocode}
1434 % \end{macro}
1435 %
1436 % \begin{macro}{
1437 % \@@_typeset_ist_encap_range:w
1438 % }
1439 % This is effectively just a helper macro so that \TeX\ parsing can be used to convert the parameters into the form
1440 % required by \cs{indextrarange}.
1441 % \begin{macrocode}
1442 \cs_new:Npn\@@_typeset_ist_encap_range:w #1\q_mark #2--#3\q_stop
1443 {
1444 \indextrarange{#1}{#2}{#3}
1445 }
1446 % \end{macrocode}
1447 % \end{macro}
1448 %
1449 % \begin{macro}{
1450 % \cs_new:Npn\@@_typeset_xdy_location:n
1451 % }
1452 % Typeset a \xindy-style location. The location might be
1453 % \begin{itemize}
1454 % \item a single page;
1455 % \item an encapsulated single page \cs{encapsulation}\mcode{\{}\meta{page}\mcode{\}};
1456 % \item a range; or
1457 % \item an encapsulated range \cs{encapsulation}\mcode{\{}\meta{start}\mcode{\}}\ttdashdash\cs{encapsulation}\mcode{\{}\meta{end}\mcode{\}}.
1458 % \end{itemize}
1459 % \begin{macrocode}
1460 \cs_new:Npn\@@_typeset_xdy_location:n #1
1461 {
1462 \bool_if:nTF{\@@_is_nonrange_p:w #1--\q_stop}
1463 {
1464 % \end{macrocode}
1465 % \textit{Case: not a range.} Check for an encapsulation (a leading control sequence, comparing catcode with
1466 % \cs{prg_do_nothing:} simply as a convenience). Either call \cs{@@_typeset_ist_encap_page_or_range:Nn} with this
1467 % encapsulation or with a `do-nothing' encapsulation and the braced parameter.
1468 % \begin{macrocode}
1469 \tl_if_head_eq_catcode:nNTF{#1}\prg_do_nothing:
1470 {
1471 \indextrapage #1
1472 }
1473 {
1474 \indextrapage \prg_do_nothing:{#1}
1475 }
1476 }
1477 {
1478 % \end{macrocode}
1479 % \textit{Case: range.}
1480 % \begin{macrocode}
1481 \@@_typeset_xdy_range:w #1\q_stop
1482 }
1483 }
1484 % \end{macrocode}
1485 % \end{macro}
1486 %
1487 % \begin{macro}{
1488 % \@@_typeset_xdy_range:w
1489 % }
1490 % To be called in the form \cs{@@_typeset_xdy_range:w}\meta{parameter}\cs{q_stop}, so that \param{1} and \param{2}
1491 % will be the start and end of the range, possibly with encapsulations. Check \param{1} for a leading control
1492 % sequence. If it exists, assume the same holds for \param{2}, and the parameters are of the form
1493 % \cs{encapsulation}\texttt{\{}\meta{start}\texttt{\}} and \cs{encapsulation}\texttt{\{}\meta{end}\texttt{\}} and can
1494 % be passed to \cs{@@_typeset_xdy_encap_range:w}. Otherwise, each parameter is a page, so call \cs{indextrarange} with
1495 % `do-nothing' encapsulations and braced parameters.
1496 % \begin{macrocode}
1497 \cs_new:Npn\@@_typeset_xdy_range:w #1--#2\q_stop
1498 {
1499 \tl_if_head_eq_catcode:nNTF{#1}\prg_do_nothing:
1500 {
1501 \@@_typeset_xdy_encap_range:NnNn #1#2
1502 }
1503 {
1504 \indextrarange\prg_do_nothing:{#1}{#2}
1505 }
1506 }
1507 % \end{macrocode}
1508 % \end{macro}
1509 %
1510 % \begin{macro}{
1511 % \@@_typeset_xdy_encap_range:NnNn
1512 % }
1513 % This is effectively just a helper macro so that \TeX\ parsing can be used to convert the parameters into the form
1514 % required by \cs{indextrarange}.
1515 % \begin{macrocode}
1516 \cs_new:Npn\@@_typeset_xdy_encap_range:NnNn #1#2#3#4
1517 {
1518 \indextrarange{#1}{#2}{#4}
1519 }
1520 % \end{macrocode}
1521 % \end{macro}
1522 %
1523 %
1524 %
1525 % \begin{macro}{
1526 % \@@_page_basic:nn,
1527 % \@@_range_basic:nnn,
1528 % \@@_page_hyperref:nn,
1529 % \@@_range_hyperref:nnn,
1530 % }
1531 % Default macros for typesetting a page and a range, depending on whether \pkg{hyperref} is loaded.
1532 % \begin{macrocode}
1533 \cs_new:Npn\@@_page_basic:nn #1#2
1534 {
1535 #1{#2}
1536 }
1537 \cs_new:Npn\@@_range_basic:nnn #1#2#3
1538 {
1539 #1{#2}--#1{#3}
1540 }
1541 \cs_new:Npn\@@_page_hyperref:nn #1#2
1542 {
1543 #1{\hyperpage{#2}}
1544 }
1545 \cs_new:Npn\@@_range_hyperref:nnn #1#2#3
1546 {
1547 #1{\hyperpage{#2}}--#1{\hyperpage{#3}}
1548 }
1549 % \end{macrocode}
1550 % \end{macro}
1551 %
1552 % Set \cs{indextrapage} and \cs{indextrarange} to the `basic' versions of the above macros. They may be set to the
1553 % `hyperref' versions at the start of the \env{theindextra} environment depending on user settings.
1554 % \begin{macrocode}
1555 \cs_set_eq:NN\indextrapage\@@_page_basic:nn
1556 \cs_set_eq:NN\indextrarange\@@_range_basic:nnn
1557 % \end{macrocode}
1558 %
1559 %
1560 % \subsection{Continuations}
1561 %
1562 % \begin{macro}{
1563 % \@@_make_continuation:n
1564 % }
1565 % Return a continuation text for the level specified in \param{1}, indicating that this (and higher) levels are
1566 % continued from the previous column. The continuation text is created using the stored keywords with
1567 % \cs{indextramakecontinuation} applied to each.
1568 % \begin{macrocode}
1569 \cs_new:Npn\@@_make_continuation:n #1
1570 {
1571 \int_step_inline:nnn{0}{#1}{
1572 \group_begin:
1573 \@@_set_style:n{##1}
1574 \leavevmode\strut
1575 \indextramakecontinuation{##1}{\tl_use:c{l_@@_saved_keyword_##1}}
1576 \strut\par
1577 \group_end:
1578 }
1579 }
1580 % \end{macrocode}
1581 % \end{macro}
1582 %
1583 % \begin{macro}{
1584 % \indextramakecontinuation
1585 % }
1586 % Take a level (\param{1}) and a keyword (\param{2}) and return a continuation text.
1587 % \begin{macrocode}
1588 \cs_new:Npn\indextramakecontinuation #1#2
1589 {
1590 #2~(cont.)
1591 }
1592 % \end{macrocode}
1593 % \end{macro}
1594 %
1595 %
1596 %
1597 % \subsection{Marks}
1598 %
1599 % Define a new mark class for use by \pkg{indextra}.
1600 % \begin{macrocode}
1601 \mark_new_class:n{indextra}
1602 % \end{macrocode}
1603 %
1604 % \begin{macro}{
1605 % \@@_mark_insert:
1606 % }
1607 % Insert the top-level saved keyword as a mark.
1608 % \begin{macrocode}
1609 \cs_new:Npn\@@_mark_insert:
1610 {
1611 \mark_insert:nn{indextra}{\tl_use:c{l_@@_saved_keyword_0}}
1612 }
1613 % \end{macrocode}
1614 % \end{macro}
1615 %
1616 % \begin{macro}{
1617 % \indextramakemark
1618 % }
1619 % Macro to process an \pkg{indextra} mark for use. Any mark retrieved by \cs{indextrafirstmark} or
1620 % \cs{indextralastmark} will have \cs{indextramakemark} applied.
1621 % \begin{macrocode}
1622 \cs_new:Npn\indextramakemark #1
1623 {
1624 #1
1625 }
1626 % \end{macrocode}
1627 % \end{macro}
1628 %
1629 % \begin{macro}{
1630 % \indextrafirstmark,
1631 % \indextralastmark,
1632 % }
1633 % Retrieve the first and last \pkg{indextra} marks on the page, where `first' and `last' have their standard \LaTeX\
1634 % meanings. The marks will be processed by \cs{indextramakemark}.
1635 % \begin{macrocode}
1636 \cs_new:Npn\indextrafirstmark
1637 {
1638 \indextramakemark{ \mark_use_first:nn{page}{indextra} }
1639 }
1640 \cs_new:Npn\indextralastmark
1641 {
1642 \indextramakemark{ \mark_use_last:nn{page}{indextra} }
1643 }
1644 % \end{macrocode}
1645 % \end{macro}
1646 %
1647 %
1648 %
1649 % \subsection{Buffer}
1650 %
1651 % \begin{variable}{
1652 % \l_@@_buffer_box,
1653 % }
1654 % Box variable to hold remaining material to be typeset for the current index entry, sub-entry, or sub-sub-entry.
1655 % \begin{macrocode}
1656 \box_new:N\l_@@_buffer_box
1657 % \end{macrocode}
1658 % \end{variable}
1659 %
1660 % \begin{macro}{
1661 % \@@_typeset_buffer:
1662 % }
1663 % Output material that has been typeset into \cs{l_@@_buffer_box} and update \cs{g_@@_remaining_space_dim} as
1664 % necessary. If necessary, split off as much material as will fit in the current column from \cs{l_@@_buffer_box},
1665 % typeset it, add continuation text to the top of \cs{l_@@_buffer_box}, then recursively call this macro. The
1666 % recursion ends when all material in \cs{l_@@_buffer_box} has been output.
1667 % \begin{macrocode}
1668 \cs_new:Npn\@@_typeset_buffer:
1669 {
1670 % \end{macrocode}
1671 % Insert a mark. This is either on the first call, or a recursive call, in which case the current position is at the
1672 % top of the column. A mark should be inserted in any case.
1673 % \begin{macrocode}
1674 \@@_mark_insert:
1675 % \end{macrocode}
1676 % Check whether it is necessary to split off some material for this column and start a new one. There is no need to
1677 % check about the minimum acceptable split: if necessary, a new column has already been started in \cs{@@_entry:nnn}.
1678 % \begin{macrocode}
1679 \dim_compare:nNnT
1680 {\g_@@_remaining_space_dim}
1681 <
1682 {\box_ht:N\l_@@_buffer_box+\box_dp:N\l_@@_buffer_box}
1683 {
1684 % \end{macrocode}
1685 % \textit{Case: A split is necessary.} Compute an approximation (definitely too large, but acceptably so) to the
1686 % amount to be split off, then split and rebox.
1687 % \begin{macrocode}
1688 \dim_set:Nn
1689 \l_tmpa_dim{\g_@@_remaining_space_dim-.3\baselineskip}
1690 \vbox_set_split_to_ht:NNn
1691 \l_tmpa_box\l_@@_buffer_box{\l_tmpa_dim}
1692 \vbox_set:Nn
1693 \l_tmpa_box{\vbox_unpack_drop:N\l_tmpa_box}
1694 % \end{macrocode}
1695 % Update \cs{g_@@_remaining_space_dim} and output the split material.
1696 % \begin{macrocode}
1697 \dim_gset:Nn\g_@@_remaining_space_dim
1698 {
1699 \g_@@_remaining_space_dim
1700 -\box_ht:N\l_tmpa_box
1701 -\box_dp:N\l_tmpa_box
1702 }
1703 \vbox_unpack_drop:N\l_tmpa_box
1704 % \end{macrocode}
1705 % Add a continuation text to the top of \cs{l_@@_buffer_box}, start a new column, and recurse.
1706 % \begin{macrocode}
1707 \@@_vbox_prepend:Nn
1708 \l_@@_buffer_box
1709 {\@@_make_continuation:n{\l_@@_level_int}}
1710 \@@_new_column:
1711 \@@_typeset_buffer:
1712 }
1713 {
1714 % \end{macrocode}
1715 % \textit{Case: No split is necessary.} Update \cs{g_@@_remaining_space_dim} and output the buffer contents.
1716 % \begin{macrocode}
1717 \dim_gset:Nn\g_@@_remaining_space_dim
1718 {
1719 \g_@@_remaining_space_dim
1720 -\box_ht:N\l_@@_buffer_box
1721 -\box_dp:N\l_@@_buffer_box
1722 }
1723 \vbox_unpack_drop:N\l_@@_buffer_box
1724 }
1725 }
1726 % \end{macrocode}
1727 % \end{macro}
1728 %
1729 %
1730 % \begin{macro}{
1731 % \@@_vbox_prepend
1732 % }
1733 % Takes a vertical box variable as \param{1} and typeset the material in \param{2} into it above the original content.
1734 % \begin{macrocode}
1735 \cs_new:Npn\@@_vbox_prepend:Nn #1#2
1736 {
1737 \vbox_set:Nn #1{
1738 \vbox{#2}
1739 \vbox_unpack_drop:N #1
1740 }
1741 }
1742 % \end{macrocode}
1743 % \end{macro}
1744 %
1745 % \begin{macrocode}
1746 %</package>
1747 % \end{macrocode}
1748 %
1749 %
1750 %
1751 % \subsection{Style files}
1752 %
1753 % \subsubsection{\texorpdfstring{\file{.ist}}{ist} -- \MakeIndex, \upmendex}
1754 %
1755 % \begin{macrocode}
1756 %<*ist>
1757 % \end{macrocode}
1758 %
1759 % \begin{macrocode}
1760 page_precedence "ArRn"
1761
1762 preamble "\\begin{theindextra}\n \\indextrastyleversion{0.1}\n \\indextraprocessortype{ist}\n"
1763 postamble "\n\n\n\\end{theindextra}\n"
1764
1765 group_skip "\n\n\n \\indextraspace"
1766
1767 heading_prefix "\n\n\n \\indextragroup{"
1768 heading_suffix "}\n"
1769 headings_flag 1
1770
1771 item_0 "\n \\indextraentry{0}{"
1772 item_1 "\n \\indextraentry{1}{"
1773 item_01 "\n \\indextraentry{1}{"
1774 item_x1 "}{}\n \\indextraentry{1}{"
1775 item_2 "\n \\indextraentry{2}{"
1776 item_12 "\n \\indextraentry{2}{"
1777 item_x2 "}{}\n \\indextraentry{2}{"
1778
1779 delim_0 "}{"
1780 delim_1 "}{"
1781 delim_2 "}{"
1782 delim_t "}"
1783
1784 encap_prefix "\\"
1785 encap_infix "{"
1786 encap_suffix "}"
1787 % \end{macrocode}
1788 %
1789 % \begin{macrocode}
1790 %</ist>
1791 % \end{macrocode}
1792 %
1793 %
1794 %
1795 % \subsubsection{\texorpdfstring{\file{.xdy}}{xdy} -- \xindy}
1796 %
1797 % \begin{macrocode}
1798 %<*xdy>
1799 % \end{macrocode}
1800 %
1801 % \begin{macrocode}
1802 (markup-index :open "\begin{theindextra}~n \indextrastyleversion{0.1}~n \indextraprocessortype{xdy}~n"
1803 :close "~n~n\end{theindextra}~n"
1804 :tree)
1805
1806 (markup-letter-group-list :sep "~n \indextraspace~n")
1807 (markup-letter-group :open-head "~n % "
1808 :close-head "~n"
1809 :group "default")
1810 (markup-letter-group :open-head "~n \indextragroup{"
1811 :close-head "}~n~n")
1812
1813 (markup-indexentry :open " \indextraentry{0}{"
1814 :close "}%~n"
1815 :depth 0)
1816 (markup-indexentry :open "}%~n \indextraentry{1}{"
1817 :close ""
1818 :depth 1)
1819 (markup-indexentry :open "}%~n \indextraentry{2}{"
1820 :close ""
1821 :depth 2)
1822
1823 (markup-keyword-list :open "" :close "}{" :sep ";")
1824
1825 (markup-locclass-list :open "" :sep ", " :close "")
1826 (markup-locref-list :open "" :sep ", " :close "")
1827
1828 (markup-range :sep "--")
1829
1830 (markup-crossref-list :class "see"
1831 :open "\see{"
1832 :sep "}{}, \see{"
1833 :close "}{}")
1834 (markup-crossref-list :class "seealso"
1835 :open "\seealso{"
1836 :sep "}{}, \seealso{"
1837 :close "}{}")
1838 % \end{macrocode}
1839 %
1840 % \begin{macrocode}
1841 %</xdy>
1842 % \end{macrocode}
1843 %
1844 % \end{implementation}
1845 %
1846 % \PrintIndex
1847 %
1848 %
1849 %
1850 % \iffalse
1851 %<*metadriver>
1852 \input{indextra.dtx}
1853 %</metadriver>
1854 %
1855 %<*demo>
1856 \documentclass{article}
1857
1858 \usepackage[
1859 paperwidth=105mm,
1860 paperheight=100mm,
1861 inner=5mm,
1862 width=90mm,
1863 height=90mm,
1864 top=5mm,
1865 nohead,
1866 nofoot,
1867 columnsep=5mm,
1868 twocolumn,
1869 ]{geometry}
1870
1871 \usepackage{xcolor}
1872 \definecolor{bg}{gray}{0.9}
1873 \pagecolor{bg}
1874
1875
1876 \parindent=1em
1877
1878 \usepackage{indextra}
1879
1880 \indextrasetup{
1881 before code={},
1882 after code={},
1883 }
1884
1885
1886 \newcommand\see[1]{\textit{see}~`#1'}
1887 \newcommand\seealso[1]{\textit{see also}~`#1'}
1888
1889
1890 \raggedright
1891 \pagestyle{empty}
1892
1893 \begin{document}
1894
1895 \begin{theindextra}
1896 \indextrastyleversion{0.1}
1897 \indextraprocessortype{ist}
1898
1899 \indextraentry{0}{neutron}{855, 862, 885--886}%
1900 \indextraentry{0}{\textit{New Astronomy} (Kepler)}{\see{\textit{Astronomia Nova}}{}}%
1901 \indextraentry{0}{Newtonian physics}{298, 376, 390, 589, 813, 830, 834, 842, 891, 894--895}%
1902 \indextraentry{0}{\textit{Nicomachean Ethics} (Aristotle)}{85}%
1903 \indextraentry{0}{Nim}{11}%
1904 \indextraentry{0}{nine-point circle}{584, 641, 662--663}%
1905 \indextraentry{0}{Nobel Prize}{}%
1906 \indextraentry{1}{chemistry}{495, 566, 815, 865, 937}%
1907 \indextraentry{1}{literature}{485}%
1908 \indextraentry{1}{peace}{865}%
1909 \indextraentry{1}{physics}{502, 598, 727, 834, 836, 838, 851, 853--854, 856, 865, 867, 877, 893, 903, 905, 918, 921}%
1910 \indextraentry{0}{nobility}{188, 240, 250, 464}%
1911 \indextraentry{0}{non-aesthetic property}{700, 715}%
1912 \indextraentry{0}{non-associative algebra}{848}%
1913 \indextraentry{0}{non-commutativity}{643}%
1914 \indextraentry{0}{non-constructive proof}{787}%
1915 \indextraentry{0}{non-determinism}{595}%
1916 \indextraentry{0}{non-euclidean geometry}{380, 401, 404--408, 436, 628, 643, 880, 896}%
1917 \indextraentry{0}{non-linearity}{882}%
1918 \indextraentry{0}{non-measurable set}{672}%
1919 \indextraentry{0}{non-sensory property}{695}%
1920 \indextraentry{0}{non-visual thinking}{633}%
1921 \indextraentry{0}{nonagon}{220}%
1922
1923 \end{theindextra}
1924
1925 \end{document}
1926 % </demo>
1927 % \fi