| 1 |
|
| 2 |
%%# |
| 3 |
%%# Author: |
| 4 |
%%# |
| 5 |
%%# M. V\"ath [email protected] |
| 6 |
%%# |
| 7 |
%%# This package bases on ideas of indextwo.sty which was written jointly with |
| 8 |
%%# |
| 9 |
%%# O. Karch [email protected] |
| 10 |
%%# H.-C. Wirth [email protected] |
| 11 |
|
| 12 |
%%# The package may be distributed and/or modified under the conditions of |
| 13 |
%%# the LaTeX Project Public License (version 1.3c or later). |
| 14 |
|
| 15 |
%%############################################################################# |
| 16 |
%%# |
| 17 |
%%# This LaTeX package provides a luxury front-end for the \index command. |
| 18 |
%%# For example, it allows to generate multiple \index entries in |
| 19 |
%%# almost any form by a single command. Extremely customizable. |
| 20 |
%%# Works with all versions of LaTeX and probably most other TeX formats, too. |
| 21 |
%%# This package requires the toolbox package at least in version 3.1. |
| 22 |
%%# |
| 23 |
%%############################################################################# |
| 24 |
|
| 25 |
%%# |
| 26 |
%%# This package was tested with LaTeX 2.09 and LaTeX 2e and should work |
| 27 |
%%# with all other (future) versions of LaTeX and friends, too. |
| 28 |
%%# It should even run with other (non-LaTeX) formats if an \index command |
| 29 |
%%# with LaTeX-Syntax is provided. |
| 30 |
%%# |
| 31 |
|
| 32 |
|
| 33 |
%%# To use varindex, you have to put `varindex.sty' in a path where TeX looks |
| 34 |
%%# for its input files. You must also have the file `toolbox.sty' of the |
| 35 |
%%# toolbox package in your path. The TeX documents using varindex need the |
| 36 |
%%# following modifications in their header: |
| 37 |
%%# |
| 38 |
%%# a) If you use LaTeX2.09, use varindex as a style option, e.g. |
| 39 |
%%# \documentstyle[varindex]{article} |
| 40 |
%%# or |
| 41 |
%%# \documentstyle[varindex,12pt]{article} |
| 42 |
%%# b) If you use LaTeX2e, put in the preamble the command |
| 43 |
%%# \usepackage{varindex} |
| 44 |
%%# c) If you use some other (non-LaTeX) format, you will probably have to |
| 45 |
%%# insert a line like |
| 46 |
%%# \catcode`\@=11\input varindex.sty\catcode`\@=12\relax |
| 47 |
%%# |
| 48 |
%%# For TeX insiders: LaTeX-specific commands used in `varindex.sty' are only: |
| 49 |
%%# |
| 50 |
%%# \makeatother |
| 51 |
%%# \makeatletter |
| 52 |
%%# \typeout |
| 53 |
%%# \RequirePackage |
| 54 |
%%# \newcommand (only in the form \newcommand{\command}{} to ensure that |
| 55 |
%%# \command was not defined before) |
| 56 |
%%# \ProvidesPackage |
| 57 |
%%# |
| 58 |
%%# The above commands are used only if they are defined (otherwise, |
| 59 |
%%# natural substitutes are used (\newcommand and \Provides package are |
| 60 |
%%# then not used at all)) |
| 61 |
|
| 62 |
%%# |
| 63 |
%%# I strongly recommend to have additionally a look at the documentation |
| 64 |
%%# of the "toolbox" package, in particular the \toolboxMakeDef command |
| 65 |
%%# (provided since toolbox v3.1) which supplements \varindex. |
| 66 |
%%# |
| 67 |
|
| 68 |
%%# |
| 69 |
%%# The \varindex command is highly customizable. |
| 70 |
%%# So the following examples can only give you a rough impression of what |
| 71 |
%%# you can actually do with it. You do not need to understand them now: |
| 72 |
%%# The general usage is explained later. (Maybe you want to look up the |
| 73 |
%%# examples afterwards). |
| 74 |
%%# |
| 75 |
%%# |
| 76 |
%%# 1. Typical example of usage (using the \varindextwo macros): |
| 77 |
%%# |
| 78 |
%%# |
| 79 |
%%# |
| 80 |
%%# Suppose the following customization of the \varindex command was defined: |
| 81 |
%%# \def\Index{\varindex(){\varindextwoScan}{\varindextwo}[\emph]} |
| 82 |
%%# Since we used the \varindextwo macros here, by default |
| 83 |
%%# TWO index entries are generated with a single command: |
| 84 |
%%# |
| 85 |
%%# \Index{ring with $1$@one} |
| 86 |
%%# |
| 87 |
%%# ring |
| 88 |
%%# ~ with $1$ [sorted like: "with one"] |
| 89 |
%%# |
| 90 |
%%# $1$ [sorted like: "one" ] |
| 91 |
%%# ring with ~ [sorted like: "ring with" (without " ~") ] |
| 92 |
%%# |
| 93 |
%%# DIFFERENT entries may be generated by your own rules. E.g.: |
| 94 |
%%# |
| 95 |
%%# \Index{Hausdorff measure of noncompactness}[4,23 2!~34!1= ] |
| 96 |
%%# |
| 97 |
%%# generates THREE index entries: |
| 98 |
%%# |
| 99 |
%%# noncompactness, measure of ~ (sorted like "noncompactness, measure of") |
| 100 |
%%# |
| 101 |
%%# measure |
| 102 |
%%# ~ of noncompactness |
| 103 |
%%# Hausdorff = (here, = stands for the $\approx$ symbol) |
| 104 |
%%# |
| 105 |
%%# Hausdorff measure of noncompactness |
| 106 |
%%# |
| 107 |
%%# The last of these entries occurs only, because the last character in |
| 108 |
%%# the format argument [...] was a space. |
| 109 |
%%# |
| 110 |
%%# If you want only slight modification(s) of the default, you need also just |
| 111 |
%%# slight modifications of the command, e.g. |
| 112 |
%%# |
| 113 |
%%# \Index*,{ring with $1$@one} is as above, just that the second entry reads |
| 114 |
%%# |
| 115 |
%%# $1$, ring with ~ [sorted like "one, ring with" ] |
| 116 |
%%# |
| 117 |
%%# Moreover, since the `*' occured in the previous command, additionally |
| 118 |
%%# |
| 119 |
%%# \emph{ring with $1$} |
| 120 |
%%# |
| 121 |
%%# appears in the running text. Praxis shows that changes in the entries as |
| 122 |
%%# above have to be made frequently in the `fine tuning' of the index of a |
| 123 |
%%# book. Note that with the original \index the command would have to be |
| 124 |
%%# changed completely for the above entries, because we have a "sort" entry |
| 125 |
%%# for which a different rule applies if we use a subitem instead of a ",". |
| 126 |
%%# (BTW: \varindex produces sort entries only if they are necessary). |
| 127 |
%%# |
| 128 |
%%# Of course, you may combine the default with your own format: |
| 129 |
%%# |
| 130 |
%%# \Index{internal integrable function}[23,1~ +] generates |
| 131 |
%%# |
| 132 |
%%# integrable function, internal ~ |
| 133 |
%%# |
| 134 |
%%# internal |
| 135 |
%%# ~ integrable function |
| 136 |
%%# |
| 137 |
%%# function |
| 138 |
%%# internal integrable ~ |
| 139 |
%%# |
| 140 |
%%# |
| 141 |
%%# 2. A simple example without the \varindextwo macros: |
| 142 |
%%# |
| 143 |
%%# \varindex*{topology of a normed space}{5!4~!1= 45,12}[|see{norm}] |
| 144 |
%%# |
| 145 |
%%# produces the two index entries: |
| 146 |
%%# |
| 147 |
%%# space |
| 148 |
%%# normed ~ |
| 149 |
%%# topology = |
| 150 |
%%# |
| 151 |
%%# normed space, topology of |
| 152 |
%%# |
| 153 |
%%# In both entries not the pagenumber is cited, but the text "see also norm". |
| 154 |
%%# Additionally, the tokens {topology of a normed space} are |
| 155 |
%%# inserted into the running text (this would not happen if |
| 156 |
%%# \varindex is used in place of \varindex*). |
| 157 |
%%# Only in the first of the above entries, an `@' part will be added to the |
| 158 |
%%# *.idx file: This entry is sorted as if " ~" resp. " =" would not exist. |
| 159 |
%%# |
| 160 |
%%# |
| 161 |
%%# 3. Another example without the \varindextwo macros: |
| 162 |
%%# |
| 163 |
%%# \varindex[\emph][|textbf]% |
| 164 |
%%# {$\sigma$@sigma!$(\sigma-)$ finite {measure space}}% |
| 165 |
%%# {*1.23 23 23,1- 1-23} |
| 166 |
%%# |
| 167 |
%%# generates the three index entries: |
| 168 |
%%# |
| 169 |
%%# finite measure space |
| 170 |
%%# |
| 171 |
%%# finite measure space, $\sigma$- (sorted as "finite measure space, sigma-") |
| 172 |
%%# |
| 173 |
%%# $\sigma$-finite measure space (sorted as "sigma-finite measure space") |
| 174 |
%%# |
| 175 |
%%# In all three entries the pages are printed using \textbf. |
| 176 |
%%# |
| 177 |
%%# Moreover, the tokens |
| 178 |
%%# \emph{($\sigma$-)finite measure space} |
| 179 |
%%# are put into the running text. |
| 180 |
%%# |
| 181 |
%%# |
| 182 |
%%# 4. A simple example using a flag (without the \varindextwo macros): |
| 183 |
%%# |
| 184 |
%%# \varindex1{$L$ and $M$@L and M}{} |
| 185 |
%%# ^ |
| 186 |
%%# |
| 187 |
%%# generates the index entry "$L$ and $M$" which is sorted like "L and M". |
| 188 |
%%# In the form |
| 189 |
%%# \varindex1*{$L$ and $M$@L and M}{} |
| 190 |
%%# or |
| 191 |
%%# \varindex*1{$L$ and $M$@L and M}{} |
| 192 |
%%# additionally, {$L$ and $M$} is output into the running text. |
| 193 |
%%# |
| 194 |
%%# Note that without the `1', the index generated were |
| 195 |
%%# "$L$ and $M$ and M" which were sorted like "$L$ and L and M". |
| 196 |
%%# |
| 197 |
%%# |
| 198 |
%%# 5. An example for very primitive customized index commands (without the |
| 199 |
%%# \varindextwo macros): |
| 200 |
%%# |
| 201 |
%%# \def\myindexA{\varindex[\emph][|textbf]*} |
| 202 |
%%# \def\myindexB{\varindex(){}{}[\emph][|textbf]} |
| 203 |
%%# |
| 204 |
%%# \myindexA{Foo1}{} |
| 205 |
%%# \myindexB{Foo2}[][] |
| 206 |
%%# \myindexB*{Foo3!{Foo 3}} |
| 207 |
%%# |
| 208 |
%%# Generates the index entries Foo1, Foo2, and Foo3. Moreover, \emph{Foo1} |
| 209 |
%%# and \emph{Foo 3} is put into the running text. The pagenumber of Foo 2 in |
| 210 |
%%# the index is printed normal, the others with \textbf. |
| 211 |
%%# |
| 212 |
%%# |
| 213 |
%%# 6. An example of a primitive customized index command (without the |
| 214 |
%%# \varindextwo macros): |
| 215 |
%%# |
| 216 |
%%# \def\myindex{\varindex(\ifnum\varindexCount=2 1!2 2,1\fi){}{}[\emph]} |
| 217 |
%%# |
| 218 |
%%# \myindex{Foo Bar} |
| 219 |
%%# generates the index entries |
| 220 |
%%# Foo |
| 221 |
%%# Bar |
| 222 |
%%# |
| 223 |
%%# Bar, Foo |
| 224 |
%%# |
| 225 |
%%# \myindex*{Foo Bar} |
| 226 |
%%# generates the same index entries as above and additionally outputs |
| 227 |
%%# \emph{Foo Bar} into the running text. |
| 228 |
%%# |
| 229 |
%%# \myindex*{other format}[21] |
| 230 |
%%# generates the index entry |
| 231 |
%%# format other |
| 232 |
%%# and outputs \emph{other format} into the running text. |
| 233 |
%%# |
| 234 |
%%# \myindex[|textbf]*{BoBo} |
| 235 |
%%# generates the index entry |
| 236 |
%%# BoBo |
| 237 |
%%# where the pagenumber is printed with \textbf. |
| 238 |
%%# Moreover, \emph{BoBo} is output into the running text. |
| 239 |
%%# |
| 240 |
%%# |
| 241 |
%%# 7. A primitive varying customized index command (without the \varindextwo |
| 242 |
%%# macros): |
| 243 |
%%# |
| 244 |
%%# \def\myindex{\varindex(\ifnum\varindexCount=2 1!2 2,1\fi)% |
| 245 |
%%# (\ifnum\varindexCount=2*2,1 1!2 2,1\fi){}{}[\emph]} |
| 246 |
%%# |
| 247 |
%%# With the same commands as in 6. the same index entries are generated, |
| 248 |
%%# but the tokens \emph{Far, Boo}, \emph{other format}, and \emph{Bobo} |
| 249 |
%%# are output into the running text. |
| 250 |
%%# |
| 251 |
%%# |
| 252 |
%%# 8. Examples with the \varindextwo macros: |
| 253 |
%%# We use a similar definition for \Index as in 1., and define an \iemph |
| 254 |
%%# macro which has `*' as a default and outputs with \emph. |
| 255 |
%%# Both sort of definitions are highly recommended for you private style. |
| 256 |
%%# |
| 257 |
%%# \def\Index{\varindex(){\varindextwoScan}{\varindextwo}[]} |
| 258 |
%%# \def\iemph{\varindex(){\varindextwoScan\def\varindexStarPos{}}% |
| 259 |
%%# {\varindextwo}[\emph]} |
| 260 |
%%# (note that \def\iemph{\varindex(){\varindextwoScan}{\varindextwo}[\emph]*} |
| 261 |
%%# is not so good as the above definition of \iemph as is explained below). |
| 262 |
%%# |
| 263 |
%%# \Index*{measure of $\gamma$-noncompactness@gamma-noncompactness!FOO} |
| 264 |
%%# |
| 265 |
%%# generates the index entries |
| 266 |
%%# |
| 267 |
%%# measure |
| 268 |
%%# ~ of $\gamma$-noncompactness (sorted as "of gamma-noncompactness") |
| 269 |
%%# |
| 270 |
%%# $\gamma$-noncompacntess |
| 271 |
%%# measure of ~ |
| 272 |
%%# |
| 273 |
%%# and outputs the tokens {measure of FOO} into the running text. |
| 274 |
%%# |
| 275 |
%%# \Index*,?_'{flic of flac} generates |
| 276 |
%%# |
| 277 |
%%# flic of flac |
| 278 |
%%# |
| 279 |
%%# flac, flic |
| 280 |
%%# |
| 281 |
%%# and outputs {flic of flac}. |
| 282 |
%%# |
| 283 |
%%# \Index^={$\sigma$@sigma algebra} generates |
| 284 |
%%# |
| 285 |
%%# $\sigma$ (sorted as "sigma") |
| 286 |
%%# ~-algebra (sorted as "algebra" resp. "-algebra", see below) |
| 287 |
%%# |
| 288 |
%%# algebra |
| 289 |
%%# $\sigma$-~ (sorted as "sigma-") |
| 290 |
%%# |
| 291 |
%%# Here, the sorting "-algebra" is chosen when you used |
| 292 |
%%# \let\varindexOutSortDashBeg\varindexOutSortDash |
| 293 |
%%# as described later. |
| 294 |
%%# |
| 295 |
%%# \Index-^>{$\sigma$@sigma algebra} generates |
| 296 |
%%# |
| 297 |
%%# $\sigma$- (sorted as "sigma-") |
| 298 |
%%# ~ algebra (sorted as "algebra") |
| 299 |
%%# |
| 300 |
%%# \Index^.,:{ultra filter} generates |
| 301 |
%%# |
| 302 |
%%# ultra |
| 303 |
%%# ~filter (no space following ~) |
| 304 |
%%# filter, ultra~ (no space in front of ~) |
| 305 |
%%# |
| 306 |
%%# \iemph[|see{recursive recursion}],_{recursive recursion} generates |
| 307 |
%%# |
| 308 |
%%# recursive recursion, \see{recursive recursion} |
| 309 |
%%# |
| 310 |
%%# recursion, recursive ~, \see{recursive recursion} |
| 311 |
%%# |
| 312 |
%%# and outputs \emph{recursive recursion}. If we would have used instead the |
| 313 |
%%# definition \def\iemph{\varindex(){\varindextwoScan}{\varindextwo}[]*}, |
| 314 |
%%# the above call were not possible, since the optional arguments [|see...] |
| 315 |
%%# must occur in front of the flag `*'. |
| 316 |
%%# |
| 317 |
%%# \Index-;*{Flip Flop} generates |
| 318 |
%%# |
| 319 |
%%# Flip-Flop |
| 320 |
%%# |
| 321 |
%%# FlopFlip |
| 322 |
%%# |
| 323 |
%%# and outputs {Flip-Flop} (!!!!!!!) |
| 324 |
%%# |
| 325 |
%%# \Index>{Flippy Flop!GO}[*2-1-2 2!1-1 1-12 +] |
| 326 |
%%# |
| 327 |
%%# generates |
| 328 |
%%# |
| 329 |
%%# Flop |
| 330 |
%%# Flippy-Flippy (no tilde!) |
| 331 |
%%# |
| 332 |
%%# Flippy-Flippy Flop |
| 333 |
%%# |
| 334 |
%%# Flippy |
| 335 |
%%# ~ Flop |
| 336 |
%%# |
| 337 |
%%# and outputs {GO-Flippy-GO} (!!!) |
| 338 |
%%# |
| 339 |
%%# \Index*_,{shape {of a} of star} generates |
| 340 |
%%# |
| 341 |
%%# shape of a star |
| 342 |
%%# |
| 343 |
%%# star, shape of ~ (sorted like "star, shape of") |
| 344 |
%%# |
| 345 |
%%# and outputs {shape of a star}. |
| 346 |
%%# |
| 347 |
%%# \Index1*{$L$ feature@L feature} |
| 348 |
%%# \Index,{No $L$@L feature} |
| 349 |
%%# generate |
| 350 |
%%# |
| 351 |
%%# $L$ feature (sorted like "L feature") |
| 352 |
%%# |
| 353 |
%%# No |
| 354 |
%%# ~ $L$ feature (sorted like "L feature") |
| 355 |
%%# |
| 356 |
%%# feature, No $L$ ~ (sorted like "feature, No L") |
| 357 |
%%# |
| 358 |
%%# and outputs {$L$ feature}. |
| 359 |
%%# |
| 360 |
%%# |
| 361 |
%%# 9. Example of a simple modification of the \varindextwo macros: |
| 362 |
%%# |
| 363 |
%%# \def\myindextwoScan{% |
| 364 |
%%# \varindextwoScan |
| 365 |
%%# \varindexNewFlag ~\vxtSpaceA |
| 366 |
%%# \varindexNewFlag 1\vxtSpaceB |
| 367 |
%%# \varindexNewFlag !\varindexOneEntry |
| 368 |
%%# \varindexMakeSplitExpand{/}{vxtSplitAtMagic}% |
| 369 |
%%# \def\varindexStarPos{}% |
| 370 |
%%# } |
| 371 |
%%# \def\myIndex{\varindex(){\myindextwoScan}{\varindextwo}[]} |
| 372 |
%%# |
| 373 |
%%# \myIndex behaves similar to the previous example with |
| 374 |
%%# the following differences: |
| 375 |
%%# 1. The flag `1' now has the previous meaning of "~". |
| 376 |
%%# 2. One may now use "~" and "_" equivalently. |
| 377 |
%%# 3. The flag `!' now has the originial meaning of the flag `1'. |
| 378 |
%%# 4. Instead of `+' in the format string, the character `/' has to be used. |
| 379 |
|
| 380 |
%%# |
| 381 |
%%# |
| 382 |
%%# Description: |
| 383 |
%%# |
| 384 |
%%# There are two possible calls: |
| 385 |
%%# |
| 386 |
%%# a) \varindex[textstyle][pagestyleA]flags{main entries}{format}[pagestyleB] |
| 387 |
%%# |
| 388 |
%%# Here, [textstyle], [pagestyleA], [pagestyleB], and flags are optional. |
| 389 |
%%# (If [textstyle] is omitted, also [pagestyleA] must be omitted). |
| 390 |
%%# |
| 391 |
%%# textstyle: describes the textstyle used for the output into the |
| 392 |
%%# running text (typically, textstyle is \emph or empty). |
| 393 |
%%# pagestyle: describes the pagestyle used for the output of the pagenumber |
| 394 |
%%# (you may also use a construct like |see{...} here). |
| 395 |
%%# If [pagestyleB] is present, this is the value used. |
| 396 |
%%# Otherwise, the value of [pagestyleA] is used (resp. nothing). |
| 397 |
%%# flags can be one (or both) of the following tokens: |
| 398 |
%%# `*': "Output into running text": |
| 399 |
%%# If no * is used in the format string (see below), |
| 400 |
%%# then the format is automatically prepended by the tokens `* ' |
| 401 |
%%# resp. `*' (depending whether format starts with ` ' or not) |
| 402 |
%%# `1': The content of {main entries} is considered as a single entry |
| 403 |
%%# (see below). |
| 404 |
%%# {main entries} and |
| 405 |
%%# {format} are explained later. |
| 406 |
%%# |
| 407 |
%%# b) \varindex(formatA)(format*A){scanprogram}{mainprogram} |
| 408 |
%%# [textstyle][pagestyleA]flags{main entries}[formatB][pagestyleB] |
| 409 |
%%# |
| 410 |
%%# Concerning [textstyle], [pagestyleA], flags, [pagestyleB], the same |
| 411 |
%%# remarks as in a) hold. Also (format*A) and (formatA) are optional. |
| 412 |
%%# (if (formatA) is omitted, also (format*A) must be omitted). |
| 413 |
%%# |
| 414 |
%%# The "default" format is formatA resp. format*A (depending whether the |
| 415 |
%%# flag "*" has been used or not). If [formatB] is given, then this is |
| 416 |
%%# used as the format (i.e. it overrides the default). |
| 417 |
%%# |
| 418 |
%%# scanprogram is executed immediately when \varindex reads it. |
| 419 |
%%# This can be used to introduce FURTHER flags (other than '*' and `1'), |
| 420 |
%%# see below. |
| 421 |
%%# mainprogram is executed AFTER the format string(s) has been expanded. |
| 422 |
%%# |
| 423 |
%%# |
| 424 |
%%# |
| 425 |
%%# It is recommended to define personal macros which contain all parameters up |
| 426 |
%%# to the place where the flags occur (either with or without some flags, |
| 427 |
%%# depending on the intention). See the examples above. |
| 428 |
%%# |
| 429 |
%%# |
| 430 |
%%# |
| 431 |
%%# |
| 432 |
%%# The main argument (called {main entries} above) has the form |
| 433 |
%%# |
| 434 |
%%# entry1[`space' entry2][`space' entry3] ... |
| 435 |
%%# |
| 436 |
%%# where each of entry1 entry2 entry3 ... in turn has the form |
| 437 |
%%# indextext@sorttext!outputtext or |
| 438 |
%%# indextext!outputtext@sorttext |
| 439 |
%%# In each of these forms, @sorttext and !outputtext are optional. |
| 440 |
%%# Here, |
| 441 |
%%# indextext is the text which is put into the index for the entry |
| 442 |
%%# sorttext is what is used as a sort criterion for the entry |
| 443 |
%%# outputtext is what is output into the running text for the entry |
| 444 |
%%# |
| 445 |
%%# Note that the symbol @ has in a sense the opposite meaning as in the |
| 446 |
%%# original \index command: |
| 447 |
%%# BEFORE that symbol, the desired text appears, and |
| 448 |
%%# AFTER the symbol the place where it has to be sorted. |
| 449 |
%%# However, we chose the symbols @ and !, because these two |
| 450 |
%%# symbols are forbidden anyway (otherwise, makeindex will become confused). |
| 451 |
%%# |
| 452 |
%%# As usual, multiple spaces are considered as ONE space and do not generate |
| 453 |
%%# empty "ghost" entries. Moreover, a space after a TeX-command like \LaTeX |
| 454 |
%%# is eliminated by TeX and thus also not considered as a separator. |
| 455 |
%%# You may use braces {...} either around a whole entry or |
| 456 |
%%# around indextext resp. sorttext resp. outputtext to allow spaces |
| 457 |
%%# which do not act as "separators" in the corresponding part. The braces |
| 458 |
%%# around these parts will vanish. In particular, you may generate an |
| 459 |
%%# empty entry with {} or ! or @ (bordered by spaces). |
| 460 |
%%# If you want that braces occur in the OUTPUT, you have to add an |
| 461 |
%%# additional pair of braces. Be aware that you write sufficiently |
| 462 |
%%# many braces, if you really should need them: For example, |
| 463 |
%%# the command \varindex{{{{A B}}}}{} produces the index entry {A B}: |
| 464 |
%%# The outermost pair of braces is eliminated immediately by TeX. The second |
| 465 |
%%# pair is eliminated, because this is a pair around a complete entry. |
| 466 |
%%# Finally, another pair is eliminated, because it is a brace around |
| 467 |
%%# indextext. |
| 468 |
%%# With the flag `1', {main entries} is considered as one single entry. |
| 469 |
%%# Nevertheless, also with this flag, an additional pair of braces around |
| 470 |
%%# main entry is eliminated. |
| 471 |
%%# |
| 472 |
%%# |
| 473 |
%%# The format string has one of the following three forms |
| 474 |
%%# indexa[`space' indexb][`space' indexc] ... [*outputa][*outputb] ... |
| 475 |
%%# [*outputa][`space' indexa][`space' indexb][*outputc] ... |
| 476 |
%%# * |
| 477 |
%%# where the order of arguments can be arbitrarily mixed (except for the first |
| 478 |
%%# indexa in the first form). indexa indexb ... outputa ... describe the |
| 479 |
%%# format of the index entries resp. of the output into the running text. |
| 480 |
%%# The output is generated in the given order (this might be important, if |
| 481 |
%%# a pagebreak occurs during the output into the running text). |
| 482 |
%%# The last case is exceptional and equivalent to `*space'. |
| 483 |
%%# The following characters/strings describe the format: |
| 484 |
%%# |
| 485 |
%%# 1-9: entry1-9 |
| 486 |
%%# 0: entry 10 |
| 487 |
%%# ~: a placeholder sign |
| 488 |
%%# =: alternative placeholder sign |
| 489 |
%%# _: a space character |
| 490 |
%%# s: The token \space (but _ is used for the sort entry) |
| 491 |
%%# .: No space will follow |
| 492 |
%%# ,: The character , (space will follow) |
| 493 |
%%# -: The character - (no space will follow) |
| 494 |
%%# !: Create a new sublevel |
| 495 |
%%# All other tokens in this argument are forbidden. |
| 496 |
%%# The token ! makes no sense for the output in the running text and thus |
| 497 |
%%# is forbidden behind *. |
| 498 |
%%# |
| 499 |
%%# By a heuristic rule, a space is automatically inserted between two entries |
| 500 |
%%# which generate non-empty text. If the heuristic rule fails, you may always |
| 501 |
%%# force a space by either "_" or "s", or forbid a space by ".". |
| 502 |
%%# |
| 503 |
%%# If a format is empty, all entries are taken in the order of input. |
| 504 |
%%# Note that TeX eliminates concatenated spaces, and so you are able to |
| 505 |
%%# produce an empty format entry only at the end or in front of a `*'. |
| 506 |
%%# If you want to force an empty OUTPUT (is this ever useful?), you may use |
| 507 |
%%# just "." as the entry. |
| 508 |
%%# |
| 509 |
%%# A sort entry is only written to the *.idx file if it differs from the |
| 510 |
%%# text entry. |
| 511 |
|
| 512 |
%%# |
| 513 |
%%# |
| 514 |
%%# Description of the \varindextwo macros: |
| 515 |
%%# |
| 516 |
%%# The macros |
| 517 |
%%# |
| 518 |
%%# \varindextwoScan \varindextwo |
| 519 |
%%# |
| 520 |
%%# can be used together as parameters {scanprogram} resp. {mainprogram} |
| 521 |
%%# for the \varindex command. |
| 522 |
%%# If \varindex is called with these macros, and no |
| 523 |
%%# explicit format argument is given, these macros generate a format |
| 524 |
%%# depending on the number of entries in {main entries}: |
| 525 |
%%# |
| 526 |
%%# a) If there is only one entry in {main entries}, |
| 527 |
%%# then the format "1" resp. "*1 1" is generated |
| 528 |
%%# (depending whether the * flag was used or not), i.e. the |
| 529 |
%%# entry is put into the index, and printed if \varindex was |
| 530 |
%%# called with the * flag. |
| 531 |
%%# |
| 532 |
%%# b) If there are two main entries like {graulty bazola}, |
| 533 |
%%# then the format becomes { 1!~2 1!2~}, i.e. the index entries |
| 534 |
%%# |
| 535 |
%%# graulty |
| 536 |
%%# ~ bazola |
| 537 |
%%# |
| 538 |
%%# bazola |
| 539 |
%%# graulty ~ |
| 540 |
%%# |
| 541 |
%%# are produced. |
| 542 |
%%# |
| 543 |
%%# You can modify the first format entry with the following flags: |
| 544 |
%%# flags format used: If used with `*' additionally: |
| 545 |
%%# _ 12 *12 |
| 546 |
%%# - 1-2 *1-2 |
| 547 |
%%# ^ 1!~-2 resp. 1!-2 *1-2 |
| 548 |
%%# -^ 1-!~.2 resp. 1-!~2 *1-2 |
| 549 |
%%# . 1.2 *1.2 |
| 550 |
%%# .^ 1!~.2 *1.2 |
| 551 |
%%# / 1!2 (without ~) *12 |
| 552 |
%%# < no entry *12 |
| 553 |
%%# |
| 554 |
%%# Here, the combinations -^ and .^ mean that both flags are used |
| 555 |
%%# (the order plays no role). |
| 556 |
%%# The output for ^ respectively -^ is determined by the switches |
| 557 |
%%# \varindextwoDashTildetrue (default) |
| 558 |
%%# \varindextwoDashTildefalse |
| 559 |
%%# \varindextwoDashSpacetrue |
| 560 |
%%# \varindextwoDashSpacefalse (default) |
| 561 |
%%# |
| 562 |
%%# You can modify the second format entry with the following flags: |
| 563 |
%%# flags format used: |
| 564 |
%%# , 2,1~ resp. 2,1 |
| 565 |
%%# ~ 21 |
| 566 |
%%# = 2!1-~ |
| 567 |
%%# ,= 2,1-~ resp. 2,1- |
| 568 |
%%# + 2-1 |
| 569 |
%%# : 2!1.~ |
| 570 |
%%# ,: 2,1.~ resp. 2,1 |
| 571 |
%%# ; 2.1 |
| 572 |
%%# > no entry |
| 573 |
%%# ! Append ~ (if not already there) |
| 574 |
%%# ? Without ~ |
| 575 |
%%# |
| 576 |
%%# Whether the first or the second alternatives in the above forms is used |
| 577 |
%%# depends on the status of the switch |
| 578 |
%%# \varindextwoCommaTildetrue (default) |
| 579 |
%%# \varindextwoCommaTildefalse |
| 580 |
%%# We point out that "\varindextwoCommaTildefalse" was in earlier versions |
| 581 |
%%# of "varindex" the default (and could not be changed). |
| 582 |
%%# Note that this switch has no effect if the ! or ? flags are used. |
| 583 |
%%# |
| 584 |
%%# HINT for remembering the symbols: The symbols _ . - for the first entry |
| 585 |
%%# are the same flags as for the output and the same flags which are used |
| 586 |
%%# in the format string. The corresponding symbols ~ : (and ;) = (and +) |
| 587 |
%%# for the second entry "look similar". The "," is only useful in the |
| 588 |
%%# second entry (and is the same symbol as in the format string). |
| 589 |
%%# The two exceptional symbols ">" and "<" can be read as "generate only |
| 590 |
%%# the forward-directed resp. backward-directed entry". |
| 591 |
%%# |
| 592 |
%%# c) If there are three main entries like {graulty of bazola}, then the |
| 593 |
%%# format becomes { 1!~23 3!12~}, i.e. the output becomes |
| 594 |
%%# |
| 595 |
%%# graulty |
| 596 |
%%# ~ of bazola |
| 597 |
%%# |
| 598 |
%%# bazola |
| 599 |
%%# graulty of ~ |
| 600 |
%%# |
| 601 |
%%# The flags have an analogous effect to b). |
| 602 |
%%# In addition, if the flags ` resp. ' are used, the second word |
| 603 |
%%# (in our example: `of') is omitted from the output in the first resp. |
| 604 |
%%# in the second index entry. If the * flag and ` are used together, the |
| 605 |
%%# second entry is also omitted from the output into the running text. |
| 606 |
%%# |
| 607 |
%%# d) If there are four main entries like {graulty of OF bazola}, then the |
| 608 |
%%# format becomes { 1!~24 4!31~}, i.e. the output becomes |
| 609 |
%%# |
| 610 |
%%# graulty |
| 611 |
%%# ~ of bazola |
| 612 |
%%# |
| 613 |
%%# bazola |
| 614 |
%%# graulty OF ~ |
| 615 |
%%# |
| 616 |
%%# i.e. we have a similar effect as in c) except that for the first entry |
| 617 |
%%# the third word is skipped, and for the second entry the second word is |
| 618 |
%%# skipped. All flags as in c) can be used with an analogous meaning. |
| 619 |
%%# Also if the * flag is used, the output into the running text is |
| 620 |
%%# analogous to c) (the third word is skipped). |
| 621 |
%%# |
| 622 |
%%# e) If there are more than four main entries, then |
| 623 |
%%# (formatA) resp. (format*A) is used. |
| 624 |
%%# |
| 625 |
%%# If an explicit format argument is provided, then this is used except |
| 626 |
%%# when it contains the symbol +. In this case, this symbol is replaced by the |
| 627 |
%%# output which would be generated "normally". If additionally the `*'-flag |
| 628 |
%%# is used, there is a special rule: |
| 629 |
%%# If the explicit format contains a `*', then no additional `*'-output is |
| 630 |
%%# produced. Otherwise, the `*'-output from a)-e) is prepended to the given |
| 631 |
%%# format string (with a space at the end, unless the format string is empty). |
| 632 |
%%# This means that `normally' you have the output from a)-e), |
| 633 |
%%# unless you write an own `*'-part in the argument. |
| 634 |
%%# |
| 635 |
%%# If you do not like the tokens chosen for the default symbols, you can |
| 636 |
%%# easily choose your own tokens by just replacing \varindextwoScan with your |
| 637 |
%%# own macro (or defining your own ``magic'' tokens after \varindextwoScan, |
| 638 |
%%# see Example 9. above). |
| 639 |
|
| 640 |
%%# |
| 641 |
%%# |
| 642 |
%%# Primitive customization: |
| 643 |
%%# |
| 644 |
%%# |
| 645 |
%%# You may use the command |
| 646 |
%%# \varindexUsePlaceholderAfalse |
| 647 |
%%# \varindexUsePlaceholderBfalse |
| 648 |
%%# to ignore the sign ~ resp. = in the format entry. |
| 649 |
%%# You can easily restore the default by |
| 650 |
%%# \varindexUsePlaceholderAtrue |
| 651 |
%%# \varindexUsePlaceholderBtrue |
| 652 |
%%# |
| 653 |
%%# If you want to switch off the placeholder only at the beginning of |
| 654 |
%%# a new entry (resp. of a new subentry), you can use the commands |
| 655 |
%%# \varindexLeadingPlaceholderAfalse |
| 656 |
%%# \varindexLeadingPlaceholderBfalse |
| 657 |
%%# The default is restored with |
| 658 |
%%# \varindexLeadingPlaceholderAtrue |
| 659 |
%%# \varindexLeadingPlaceholderBtrue |
| 660 |
%%# |
| 661 |
%%# By default, the "," in the format string is in this connection |
| 662 |
%%# treated as a symbol generating a new "subentry". You can change this |
| 663 |
%%# default with the command |
| 664 |
%%# \varindexCommaLeadsfalse |
| 665 |
%%# You may switch back with |
| 666 |
%%# \varindexCommaLeadstrue |
| 667 |
%%# |
| 668 |
%%# |
| 669 |
%%# The content of the macro |
| 670 |
%%# \varindexPlaceholderAText |
| 671 |
%%# \varindexPlaceholderASort |
| 672 |
%%# \varindexPlaceholderBText |
| 673 |
%%# \varindexPlaceholderBSort |
| 674 |
%%# is used as the placeholder ~ resp. = in the index resp. sort entry. |
| 675 |
%%# Note that if one of these entries expands empty, different rules for |
| 676 |
%%# the automatic insertion of spaces apply (for the index and sort entry |
| 677 |
%%# separately). |
| 678 |
%%# |
| 679 |
%%# You may prefer that the placeholder text resp. sort content changes at |
| 680 |
%%# run time to the context of the previous ! entry. For example, you may |
| 681 |
%%# want that the command \varindex{Gibble Gobble}{2!~2} produces the index |
| 682 |
%%# entry |
| 683 |
%%# Gibble |
| 684 |
%%# Gibble Gobble |
| 685 |
%%# (or is at least SORTED as such an entry). |
| 686 |
%%# |
| 687 |
%%# You can achieve this with the commands |
| 688 |
%%# \varindexPreviousATexttrue |
| 689 |
%%# \varindexPreviousASorttrue |
| 690 |
%%# \varindexPreviousBTexttrue |
| 691 |
%%# \varindexPreviousBSorttrue |
| 692 |
%%# for the text and sort entry and the placeholders ~ and =, respectively. |
| 693 |
%%# With these commands, the content of \varindexPlaceholderAText etc |
| 694 |
%%# is only used as the default if no previous ! entry was given. |
| 695 |
%%# You can switch back to the default mode with the respective commands |
| 696 |
%%# \varindexPreviousATextfalse |
| 697 |
%%# \varindexPreviousASortfalse |
| 698 |
%%# \varindexPreviousBTextfalse |
| 699 |
%%# \varindexPreviousBSortfalse |
| 700 |
%%# |
| 701 |
%%# By default, the ',' in the format entry is considered in this connection |
| 702 |
%%# similar to '!'. If you want to change this, use the command |
| 703 |
%%# \varindexCommaExpandfalse |
| 704 |
%%# You may switch back with |
| 705 |
%%# \varindexCommaExpandtrue |
| 706 |
%%# |
| 707 |
%%# Since version 2.2, the dash "-" occurring at the beginning of entry |
| 708 |
%%# (or after "!" or even after "," if \varindexCommaExpandtrue is in effect) |
| 709 |
%%# is ignored for sorting. You can switch off this feature with the command |
| 710 |
%%# |
| 711 |
%%# \let\varindexOutSortDashBeg\varindexOutSortDash |
| 712 |
%%# |
| 713 |
%%# To restore the new default, use |
| 714 |
%%# |
| 715 |
%%# \let\varindexOutSortDashBeg\toolboxEmpty |
| 716 |
%%# |
| 717 |
%%# |
| 718 |
%%# The commands |
| 719 |
%%# |
| 720 |
%%# \varindexSetWordString{|} % Use | as separator for entries instead |
| 721 |
%%# % of spaces. |
| 722 |
%%# \varindexSetSortString{>} % default: @ |
| 723 |
%%# \varindexSetPlainString{<} % default: ! |
| 724 |
%%# |
| 725 |
%%# set the default "magic" strings used for the main argument. |
| 726 |
%%# The argument of the above macros is intentionally NOT expanded (so that |
| 727 |
%%# you do not have troubles with active characters like ~). |
| 728 |
%%# To force expansion, use e.g. |
| 729 |
%%# \expandafter\varindexSetWordString\expandafter{\MacroToExpand} |
| 730 |
%%# or some similar construct. |
| 731 |
%%# |
| 732 |
%%# If you use a different separator than `space' for the entries, you may want |
| 733 |
%%# to change the rule how braces are eliminated. With the commands |
| 734 |
%%# \varindexEliminateOuterBracetrue |
| 735 |
%%# \varindexEliminateInnerBracetrue |
| 736 |
%%# \varindexEliminateOuterBracefalse |
| 737 |
%%# \varindexEliminateInnerBracefalse |
| 738 |
%%# you may allow resp. forbid the elimination of braces around the entries |
| 739 |
%%# resp. around {indextext} {sorttext} and {outputtext} |
| 740 |
%%# With the flag `1', {main entries} is considered as one single entry, |
| 741 |
%%# but if \varindexEliminateOuterBracetrue is set (which is the default) |
| 742 |
%%# also in this case an additional pair of braces around main entry is |
| 743 |
%%# eliminated. |
| 744 |
%%# |
| 745 |
%%# Similarly as above, |
| 746 |
%%# |
| 747 |
%%# \varindexSetIndexString{|} % default: space |
| 748 |
%%# \varindexSetOutputString{<} % default: * |
| 749 |
%%# \varindexSetTildeAString{~} % (is default) |
| 750 |
%%# \varindexSetTildeBString{=} % (is default) |
| 751 |
%%# \varindexSetSpaceString{_} % (is default) |
| 752 |
%%# \varindexSetSpaceTokString{s} % (is default) |
| 753 |
%%# \varindexSetOmitString{.} % (is default) |
| 754 |
%%# \varindexSetCommaString{,} % (is default) |
| 755 |
%%# \varindexSetDashString{-} % (is default) |
| 756 |
%%# \varindexSetExclamString{!} % (is default) |
| 757 |
%%# \varindexSetStringForNr 1{a} % default: 1 |
| 758 |
%%# \varindexSetStringForNr{11}{b}% No default! |
| 759 |
%%# |
| 760 |
%%# sets the default "magic" strings used for the format argument. |
| 761 |
%%# In contrast to before, the arguments are fully expanded (with |
| 762 |
%%# \varindexedef, see below). |
| 763 |
%%# Note that the last command provides a way to access more than 10 entries! |
| 764 |
%%# |
| 765 |
%%# If you use \varindexSetIndexString{|} (with some non-space token), |
| 766 |
%%# you may still use spaces in the format which then are just ignored. |
| 767 |
%%# |
| 768 |
%%# |
| 769 |
%%# Avoid that one string is a prefix of another string: In this case, |
| 770 |
%%# strange effects may happen, and this behavior may even change in |
| 771 |
%%# future releases of this package. |
| 772 |
%%# Note that the above effect may arise unintentionally if you use active |
| 773 |
%%# chars. For this reason, `~' is defined to expand to the letter `~', |
| 774 |
%%# before the expansion is executed. Maybe in later releases of this package |
| 775 |
%%# there will be further such redefinitions. |
| 776 |
%%# You can explicitly use this feature in your own macros by using |
| 777 |
%%# \varindexedef instead of the usual \edef, see below. |
| 778 |
%%# |
| 779 |
%%# |
| 780 |
%%# You can change the output for the text resp sort entry of the various |
| 781 |
%%# symbols used in the format string. More precisely, you can redefine |
| 782 |
%%# |
| 783 |
%%# \varindexOutExclam % Text output for ! |
| 784 |
%%# \varindexFollowsExclam % Decide whether magic space after ! is inserted |
| 785 |
%%# \varindexOutTextComma % Text output for , |
| 786 |
%%# \varindexOutSortComma % Sort output for , |
| 787 |
%%# \varindexFollowsComma % Decide whether magic space after , is inserted |
| 788 |
%%# \varindexPreceedsComma % Decide whether magic space before , is erased |
| 789 |
%%# \varindexOutTextSpace % Text output for _ |
| 790 |
%%# \varindexOutSortSpace % Sort output for _ |
| 791 |
%%# \varindexFollowsSpace % Decide whether magic space after _ is inserted |
| 792 |
%%# \varindexPreceedsSpace % Decide whether magic space before _ is erase |
| 793 |
%%# \varindexOutTextSpTok % Text output for s |
| 794 |
%%# \varindexOutSortSpTok % Sort output for s |
| 795 |
%%# \varindexFollowsSpTok % Decide whether magic space after s is inserted |
| 796 |
%%# \varindexPreceedsSpTok % Decide whether magic space before s is erased |
| 797 |
%%# \varindexOutTextDash % Text output for - |
| 798 |
%%# \varindexOutSortDash % Sort output for - |
| 799 |
%%# \varindexOutSortDashBeg% Sort output for - if nothing preceeds |
| 800 |
%%# \varindexFollowsDash % Decide whether magic space after - is inserted |
| 801 |
%%# \varindexPreceedsDash % Decide whether magic space before - is erased |
| 802 |
%%# \varindexOutTextOmit % Text output for . |
| 803 |
%%# \varindexOutSortOmit % Sort output for . |
| 804 |
%%# \varindexFollowsOmit % Decide whether magic space after . is inserted |
| 805 |
%%# \varindexPreceedsOmit % Decide whether magic space before . is erased |
| 806 |
%%# |
| 807 |
%%# The meaning is as follows: \varindexOut... should just expand to the |
| 808 |
%%# tokens which should be written into the text resp. sort output. |
| 809 |
%%# The corresponding macro \varindexFollows... is typically defined with |
| 810 |
%%# one of the following commands: |
| 811 |
%%# \let\varindexFollows...\varindexNextSpace |
| 812 |
%%# \let\varindexFollows...\varindexNoNextSpace |
| 813 |
%%# In the first case, a space is `magically' inserted in front of a |
| 814 |
%%# subsequent token (unless this token erases the magic space). |
| 815 |
%%# In the second case, no space follows, of course. |
| 816 |
%%# There is an alternative call: |
| 817 |
%%# \def\varindexFollows...{\varindexSpaceTexttrue\varindexSpaceSortfalse} |
| 818 |
%%# This definition achieves that for the text output a space should follow, |
| 819 |
%%# but not for the sort output. Of course, you can also use similarly the |
| 820 |
%%# commands \varindexSpaceTextfalse and/or \varindexSpaceSorttrue |
| 821 |
%%# in the above definition (the effect should be obvious). |
| 822 |
%%# In particular, \varindexNextSpace is equivalent to |
| 823 |
%%# \varindexSpaceTexttrue\varindexSorttrue. |
| 824 |
%%# |
| 825 |
%%# The macro \varindexPreceeds... is similarly as \varindexFollows... with |
| 826 |
%%# the difference that it is executed BEFORE the token in question is |
| 827 |
%%# output. In particular, you can ignore a previous `magic space'. |
| 828 |
%%# All of the `magic space' commands are defined by default with |
| 829 |
%%# \let\varindexFollows...\toolboxEmpty |
| 830 |
%%# \let\varindexPreceeds...\varindexNoNextSpace |
| 831 |
%%# with the following two exceptions: |
| 832 |
%%# \let\varindexFollowsExclam\varindexNoNextSpace |
| 833 |
%%# \let\varindexFollowsComma\varindexNextSpace |
| 834 |
%%# |
| 835 |
%%# Documented Features (in later versions, these will still be available, |
| 836 |
%%# and if they contain a bug now, they will be repaired to work this way): |
| 837 |
%%# |
| 838 |
%%# (In a future release, varindex will cook your coffee, too) |
| 839 |
%%# |
| 840 |
%%# |
| 841 |
%%# |
| 842 |
%%# The main argument is NOT expanded, so you can actually write macros |
| 843 |
%%# into the *.idx file. The command actually used to write the index is |
| 844 |
%%# |
| 845 |
%%# \varindexIndex |
| 846 |
%%# |
| 847 |
%%# (which by default is of course defined as \index). |
| 848 |
%%# Since some implementations of the \index command still (partially) expand |
| 849 |
%%# their argument (which might be considered as a bug), the argument of |
| 850 |
%%# \varindexIndex is translated before the actual call with the aid of |
| 851 |
%%# \toolboxMakeHarmless. |
| 852 |
%%# If you want to redefine \varindexIndex to a personal \index-output |
| 853 |
%%# function, you might want to skip the \toolboxMakeHarmless step. |
| 854 |
%%# This is arranged with the command |
| 855 |
%%# |
| 856 |
%%# \varindexNoConvert |
| 857 |
%%# |
| 858 |
%%# You can cancel the effect of this command with |
| 859 |
%%# |
| 860 |
%%# \varindexDoConvert |
| 861 |
%%# |
| 862 |
%%# Even if \varindexNoConvert is not in effect, the main argument is not |
| 863 |
%%# expanded (and in particular, the argument of \varindexIndex consists of |
| 864 |
%%# the corresponding entries in an unexpanded form). |
| 865 |
%%# |
| 866 |
%%# The whole \varindex... procedure takes place in a group, so all your |
| 867 |
%%# variables are local to a single call (unless you use \gdef... |
| 868 |
%%# (and friends) of course). |
| 869 |
%%# |
| 870 |
%%# There are no \global directives in any macro related with this package. |
| 871 |
%%# In particular, if you call the above macros in a group (or redefine |
| 872 |
%%# \varindexIndex), the effect holds only until the end of the group. |
| 873 |
%%# |
| 874 |
%%# In contrast to the main argument, the format argument is expanded |
| 875 |
%%# (with \varindexedef, see below) |
| 876 |
%%# (and also formatA resp. format*A is expanded before), |
| 877 |
%%# so you can define abbreviations (even simple conditional abbreviations) |
| 878 |
%%# for the format. Note, however, that the expansion is essentially only |
| 879 |
%%# evaluated with \edef. So, you will probably not want to use e.g. \relax, |
| 880 |
%%# since this command expands to itself (and not into nothing - use |
| 881 |
%%# \toolboxEmpty if you want the latter). |
| 882 |
%%# If you want more complex abbreviations, use {mainprogram} instead. |
| 883 |
%%# |
| 884 |
%%# In order to help you write conditional abbreviations, the |
| 885 |
%%# following variables are defined when your macro is expanded (and in |
| 886 |
%%# particular also in {mainprogram}). You may of course redefine them |
| 887 |
%%# appropriately: |
| 888 |
%%# |
| 889 |
%%# \varindexAppend The argument pagestyleA resp. pagestyleB. |
| 890 |
%%# \varindexCount a TeX counter containing the number of entries in |
| 891 |
%%# the main argument. |
| 892 |
%%# \varindexLastEntry This is a macro (NOT a counter) which is usually |
| 893 |
%%# the value of \the\varindexCount. See below. |
| 894 |
%%# \varindexEntry1-... The (index) text occuring in entry 1-... |
| 895 |
%%# \varindexSort1-... The corresponding sort entry. If no sort entry was |
| 896 |
%%# given, this is the same as the corresponding |
| 897 |
%%# \varindexEntry1-... |
| 898 |
%%# \varindexPlain1-... The text which should be output in the text. If no |
| 899 |
%%# such entry was given, this is the same as the |
| 900 |
%%# corresponding \varindexEntry1-... |
| 901 |
%%# |
| 902 |
%%# \varindexCount may be larger than 10, and correspondingly there may be |
| 903 |
%%# also more than 10 different \varindexEntry/Sort/Plain macros. |
| 904 |
%%# If you ADD entries, you have to increase \varindexCount correspondingly, |
| 905 |
%%# otherwise an error is produced if the format string contains an entry |
| 906 |
%%# larger then \varindexCount. However, your additional entries are NOT |
| 907 |
%%# output for EMPTY formats: For empty formats the number used is |
| 908 |
%%# \varindexLastEntry. So if you want to output also your additional entries |
| 909 |
%%# in empty formats, you have to set \varindexLastEntry to your modified |
| 910 |
%%# value of \varindexCount in mainprogram. You may e.g. achieve this with |
| 911 |
%%# the following lines: |
| 912 |
%%# \expandafter |
| 913 |
%%# \def\expandafter\varindexLastEntry\expandafter{\the\varindexCount}% |
| 914 |
%%# It is admissible that \varindexLastEntry is larger than \varindexCount: |
| 915 |
%%# In this case all entries until \varindexLastEntry are |
| 916 |
%%# output in empty formats without producing an error (provided, of course, |
| 917 |
%%# that the corresponding variables \varindexEntry.../Sort.../Plain... are |
| 918 |
%%# defined). |
| 919 |
%%# |
| 920 |
%%# Note that numbers in TeX command names require special handling, |
| 921 |
%%# i.e., you have to use something like |
| 922 |
%%# |
| 923 |
%%# \csname varindexPlain2\endcsname |
| 924 |
%%# |
| 925 |
%%# to access variables. To avoid this, you may want to use the macros |
| 926 |
%%# \toolboxLet and \toolboxWithNr of the toolbox package. Examples are |
| 927 |
%%# \toolboxWithNr 1\let{varindexEntry}\toolboxEmpty |
| 928 |
%%# \toolboxWithNr {10}\def{varindexSort}{Foo} |
| 929 |
%%# \toolboxLet \mymacro{varindexPlain\the\mycount} |
| 930 |
%%# These commands set \varindexEntry1 to \toolboxEmpty, \varindexSort10 to |
| 931 |
%%# Foo, and \mymacro to the content of \varindexPlain5 (if \mycount=5). |
| 932 |
%%# |
| 933 |
%%# All these variables are also available when {mainprogram} is expanded. |
| 934 |
%%# In {mainprogram} also the following functions are useful: |
| 935 |
%%# |
| 936 |
%%# \varindexFormat |
| 937 |
%%# This macro expands to the actual format string which is used. |
| 938 |
%%# The main purpose of {mainprogram} will usually be to (re)define |
| 939 |
%%# this macro. After {mainprogram} has been called, this macro is |
| 940 |
%%# modified in several ways: |
| 941 |
%%# 1. \varindexFormat is expanded (with \varindexedef, see below). |
| 942 |
%%# (thus, \varindexFormat is expanded BEFORE AND AFTER the call |
| 943 |
%%# of {mainprogram}). |
| 944 |
%%# 2. \ifvarindexStar is true (see below) a `*' resp. `* ' is prepended. |
| 945 |
%%# 3. If it is only "*", it is replaced by "* ". |
| 946 |
%%# Note that before execution of {mainprogram}, no tests on the |
| 947 |
%%# validity of the format are done: You may use your own symbols to |
| 948 |
%%# `communicate' with {mainprogram} (if {mainprogram} eliminates these |
| 949 |
%%# symbols afterwards). |
| 950 |
%%# |
| 951 |
%%# \varindexFormatDefault |
| 952 |
%%# This macro expands to formatA resp format*A (in the expanded form) |
| 953 |
%%# depending whether the * flag has been used in the call. |
| 954 |
%%# Note that this expansion was executed BEFORE the optional format |
| 955 |
%%# argument is expanded for the first time. |
| 956 |
%%# |
| 957 |
%%# \ifvarindexStar ifpart [ \else elsepart] \fi |
| 958 |
%%# If the optional * was given, the ifpart is executed, otherwise the |
| 959 |
%%# else-part. This is a TeX-if-command. In particular, by |
| 960 |
%%# \varindexStarfalse resp. \varindexStartrue |
| 961 |
%%# you may change the behavior for future if's. This can be used |
| 962 |
%%# to prevent/force that a `*' resp. `* ' is prepended to the format |
| 963 |
%%# after the execution of {mainprogram}. |
| 964 |
%%# Setting of this variable has no effect in {scanprogram} |
| 965 |
%%# |
| 966 |
%%# \ifvarindexExplicitFormat |
| 967 |
%%# This is a TeX-if-command (see above) which is true if the optional |
| 968 |
%%# format argument [formatB] was given. |
| 969 |
%%# |
| 970 |
%%# |
| 971 |
%%# To "compose" the format, you may want to use the macros |
| 972 |
%%# |
| 973 |
%%# \toolboxDef\macrotodefine{argumentlist} |
| 974 |
%%# \toolboxAppend\macrotoappend{argumentlist} |
| 975 |
%%# \varindexedef\macrotodefine{argumentlist} |
| 976 |
%%# |
| 977 |
%%# All commands work similar to \def resp. \edef with two differences: |
| 978 |
%%# |
| 979 |
%%# For \toolboxDef\macro the argumentlist is expanded precisely by one level |
| 980 |
%%# (for details, see the documentation of the toolbox package). |
| 981 |
%%# Of course, for \toolboxAppend, the new definition is appended to the old |
| 982 |
%%# definition of \macro. |
| 983 |
%%# |
| 984 |
%%# \varindexedef fully expands argumentlist. However, some active symbols |
| 985 |
%%# (currently only ~, but additional symbols might follow in a future release) |
| 986 |
%%# are deactivated before expansion, so that ~ actually expands to ~ and not |
| 987 |
%%# to a strange command sequence. |
| 988 |
%%# |
| 989 |
%%# |
| 990 |
%%# To "decompose" the format, you may want to use one of the macros |
| 991 |
%%# |
| 992 |
%%# \toolboxSplitAt{arg}{critical}{\before}{\after} |
| 993 |
%%# \toolboxMakeSplit{critical}{command} resp. |
| 994 |
%%# \varindexMakeSplitExpand{\MacrosWhichExpandToCritical}{command} |
| 995 |
%%# \varindexMakeVarSplit\variable{\MacrosWhichExpandToCritical}{command} |
| 996 |
%%# |
| 997 |
%%# The first two macros are described in the toolbox package. |
| 998 |
%%# The remaining two macros are similar to \varindexMakeSplit with the |
| 999 |
%%# difference that the argument {critical} is obtained by expanding |
| 1000 |
%%# \MacrosWhichExpandToCritical with the aid of \varindexedef. |
| 1001 |
%%# In the last form, additionally \variable is (re)defined to expand to |
| 1002 |
%%# the value of critical. |
| 1003 |
%%# |
| 1004 |
%%# The following instances of a command created by \toolboxMakeSplit |
| 1005 |
%%# exist (the content of "critical" should be obvious): |
| 1006 |
%%# |
| 1007 |
%%# \varindexSplitAtIndex (generated by \varindexSetIndexString) |
| 1008 |
%%# \varindexSplitAtOutput |
| 1009 |
%%# \varindexSplitAtTildeA |
| 1010 |
%%# \varindexSplitAtTildeB |
| 1011 |
%%# \varindexSplitAtSpace <- Here the default content of "critical" is "_" |
| 1012 |
%%# \varindexSplitAtSpaceTok<- Here the default content of "critical" is "s" |
| 1013 |
%%# \varindexSplitAtOmit |
| 1014 |
%%# \varindexSplitAtComma |
| 1015 |
%%# \varindexSplitAtDash |
| 1016 |
%%# \varindexSplitAtExclam |
| 1017 |
%%# \varindexSplitAtNr?? (here, ?? is the number as a string; use |
| 1018 |
%%# \csname ....\endcsname to call this macro. Only those numbers are |
| 1019 |
%%# admissible which have been introduced with \varindexSetStringForNr |
| 1020 |
%%# (this is the case for 1-10)). |
| 1021 |
%%# |
| 1022 |
%%# There is also the instance |
| 1023 |
%%# \varindexSplitSpace (to be distinguished from \varindexSplitAtSpace) |
| 1024 |
%%# where "critical" is the space symbol. |
| 1025 |
%%# |
| 1026 |
%%# |
| 1027 |
%%# In addition, you may use the variables |
| 1028 |
%%# \varindexIndexString |
| 1029 |
%%# \varindexOutputString |
| 1030 |
%%# \varindexTildeAString |
| 1031 |
%%# .... |
| 1032 |
%%# \varindexNr??String |
| 1033 |
%%# which expand to the corresponding strings. |
| 1034 |
%%# |
| 1035 |
%%# All the previous macros should not be redefined `by hand'. |
| 1036 |
%%# They are implicitly redefined by the \varindexSet... commands. |
| 1037 |
%%# |
| 1038 |
%%# |
| 1039 |
%%# |
| 1040 |
%%# |
| 1041 |
%%# To drop possible braces, use the command |
| 1042 |
%%# |
| 1043 |
%%# \toolboxDropBrace\variable |
| 1044 |
%%# |
| 1045 |
%%# of the toolbox package. |
| 1046 |
%%# |
| 1047 |
%%# |
| 1048 |
%%# In {scanprogram} you may already want to call \toolboxMakeSplit: |
| 1049 |
%%# In this way many choices for the tokens are put into {scanprogram}, |
| 1050 |
%%# and in this sense, you can consider {mainprogram} as `customizable'. |
| 1051 |
%%# Anyway, the main task of {scanprogram} is to introduce new flags with |
| 1052 |
%%# |
| 1053 |
%%# \varindexNewFlag\token\position[program\varindexEndOfFlag] |
| 1054 |
%%# or |
| 1055 |
%%# \varindexNewFlag\token\position[\programmacro] |
| 1056 |
%%# |
| 1057 |
%%# Here, \position is an (undefined) macro, and \token an arbitrary token. |
| 1058 |
%%# The [program(macro)] part is optional and is explained later. |
| 1059 |
%%# If token is entered in the current call of \varindex instead (or in |
| 1060 |
%%# addition to) the star, then \position is defined to expand to a |
| 1061 |
%%# (literally) number, namely the (last) position where token was given |
| 1062 |
%%# inside the "*-argument-list" (counting from 0). For example, if |
| 1063 |
%%# \varindexNewFlag ,\commapos |
| 1064 |
%%# \varindexNewFlag -\minuspos |
| 1065 |
%%# \varindexNewFlag .\pointpos |
| 1066 |
%%# are used in \programA, then in the call |
| 1067 |
%%# \varindex(){\programA}{\programB},-**-{} |
| 1068 |
%%# the variable \commapos will expand in \programB to `0', while |
| 1069 |
%%# \minuspos will expand to `4' (the last position is taken). Finally, |
| 1070 |
%%# \pointpos is \undefined (unless you defined \pointpos differently AFTER |
| 1071 |
%%# the call of \varindexNewFlag; in this case, this is the default). |
| 1072 |
%%# If \varindexNewFlag is called multiple times with the same token, |
| 1073 |
%%# only the LAST call with this token takes effect. |
| 1074 |
%%# |
| 1075 |
%%# The flags `*' and `1' are introduced in this way with |
| 1076 |
%%# |
| 1077 |
%%# \varindexNewFlag *\varindexStarPos |
| 1078 |
%%# \varindexNewFlag 1\varindexOneEntry |
| 1079 |
%%# |
| 1080 |
%%# BEFORE {scanprogram} is executed. This means: |
| 1081 |
%%# 1. Usually, \varindexStarPos contains the (last) position of `*' |
| 1082 |
%%# (resp. is undefined). Moreover, if you define \varindexStarPos in |
| 1083 |
%%# {scanprogram} or in some flag, you get the same effect as if `*' |
| 1084 |
%%# had been used. |
| 1085 |
%%# An analogous remark holds for \varindexOneEntry. |
| 1086 |
%%# 2. If you introduce `*' with \varindexNewFlag, the `*' looses its |
| 1087 |
%%# original meaning. The same holds for `1'. |
| 1088 |
%%# |
| 1089 |
%%# If you have added a [program(macro)] part, this part is expanded |
| 1090 |
%%# whenever the flag introduced by \token is used in the call of \varindex |
| 1091 |
%%# (note that it is not excluded that this happens several times within one |
| 1092 |
%%# call). More precisely, program is expanded AFTER the variable \position has |
| 1093 |
%%# been set to the corresponding value, so you may already use \position in |
| 1094 |
%%# the program part. |
| 1095 |
%%# |
| 1096 |
%%# IMPORTANT: The last token expanded in program MUST be \varindexEndOfFlag. |
| 1097 |
%%# This is not nice but has to do with the way TeX parses its arguments. |
| 1098 |
%%# Also if you use the form \programmacro, the VERY LAST token expanded |
| 1099 |
%%# must be \varindexEndOfFlag. Even a construction like |
| 1100 |
%%# \def\myprogrammacro{\ifx.... |
| 1101 |
%%# \CallSomeMacroWithvarindexEndOfFlagAtTheEnd |
| 1102 |
%%# \fi |
| 1103 |
%%# \varindexEndOfFlag} |
| 1104 |
%%# is forbidden: In \CallSomeMacroWithvarindexEndOfFlagAtTheEnd an error |
| 1105 |
%%# would occur at the end, since still the tokens \fi\varindexEndOfFlag |
| 1106 |
%%# are in the tokenlist when EndOfFlag is reached there. |
| 1107 |
%%# As a workaround, you may e.g. use |
| 1108 |
%%# \def\myprogrammacro{\ifx... |
| 1109 |
%%# \def\execute{....\varindexEndOfFlag}% |
| 1110 |
%%# \else |
| 1111 |
%%# \def\execute{\varindexEndOfFlag}% |
| 1112 |
%%# \execute} |
| 1113 |
%%# |
| 1114 |
%%# If you use the form [\programmacro], your macro may even read additional |
| 1115 |
%%# parameters. These parameters are expected in the call of \varindex BEHIND |
| 1116 |
%%# the flag you have introduced. So you may actually use flags with |
| 1117 |
%%# parameters. For example, if \scanprogram contains a macro like |
| 1118 |
%%# \varindexNewFlag -\minuspos[\readpara] |
| 1119 |
%%# and you have defined |
| 1120 |
%%# \def\readpara#1{\def\merk{#1}\varindexEndOfFlag} |
| 1121 |
%%# then the call \varindex(){\scanprogram}{\mainprg}*-{Foo}-{Foo 2}*{Entries} |
| 1122 |
%%# is admissible, and in mainprogram, \merk will have the value Foo 2. |
| 1123 |
%%# |
| 1124 |
%%# If you are more familiar with TeX, you can even allow OPTIONAL arguments |
| 1125 |
%%# following your flag: The value of the next (non-space) token is at the |
| 1126 |
%%# call of \programmacro already saved into the variable |
| 1127 |
%%# \varindexNextToken, |
| 1128 |
%%# so you can just use it to test for e.g. [. In this connection, you may |
| 1129 |
%%# also want to use the commands |
| 1130 |
%%# \varindexTestAndExec |
| 1131 |
%%# \varindexSkipAndExec |
| 1132 |
%%# Please, see the program text how these commands are applied. |
| 1133 |
|
| 1134 |
%%# Since version 2.1 you can also hack in personal extensions of the format |
| 1135 |
%%# string. To do this, use the command |
| 1136 |
%%# |
| 1137 |
%%# \varindexNewFormat\splitcommand{action} |
| 1138 |
%%# |
| 1139 |
%%# Here, \splitcommand is a command generated by \toolboxMakeSplit or |
| 1140 |
%%# friends (preferably by \varindexMakeSplitExpand, because the command should |
| 1141 |
%%# act on the format string which is expand with \varindexedef). |
| 1142 |
%%# The string where it splits is the new string you can use |
| 1143 |
%%# in the format argument after this call. For each |
| 1144 |
%%# occurrence of the corresponding string in the format argument, |
| 1145 |
%%# action will be executed. If \splitcommand splits at a string which already |
| 1146 |
%%# had a previous meaning in the format string (or which is a prefix to |
| 1147 |
%%# such a string), the old meaning of these tokens in the format string is |
| 1148 |
%%# overridden. |
| 1149 |
%%# |
| 1150 |
%%# Typically, action will contain the following commands: |
| 1151 |
%%# One action will probably be to output a desired token (sequence) via |
| 1152 |
%%# |
| 1153 |
%%# \varindexTokensOut{TextToken}{SortToken} |
| 1154 |
%%# or |
| 1155 |
%%# \varindexTokensOutExpand\MacroForTextToken\MacroForSortToken |
| 1156 |
%%# |
| 1157 |
%%# In the first form, TextToken resp. SortToken is the token sequence put |
| 1158 |
%%# into the index or running text respectively into the sort entry of the |
| 1159 |
%%# index for the corresponding format entry. The second form is similar with |
| 1160 |
%%# the only difference that the arguments must be single macros which expand |
| 1161 |
%%# to TextToken and SortToken, respectively. |
| 1162 |
%%# |
| 1163 |
%%# The variable \ifvarindexIndexMode can be used to test whether the |
| 1164 |
%%# output goes into the running text or into the index (i.e. whether a `*' |
| 1165 |
%%# preceeded the current entry). For output into the text, SortToken is |
| 1166 |
%%# ignored, of course). |
| 1167 |
%%# |
| 1168 |
%%# Another action in \varindexNewFormat will probably be to take care of the |
| 1169 |
%%# magic space flags. This is achieved by a call to \varindexNextSpace or |
| 1170 |
%%# \varindexNoNextSpace (or separately via \varindexSpaceTexttrue/false resp. |
| 1171 |
%%# \varindexSpaceTexttrue/false); see the earlier description. |
| 1172 |
%%# The magic space flags are taken into account in "\varindexTokensOut". |
| 1173 |
%%# Thus, if you want to ignore the previous flag for some reason you should |
| 1174 |
%%# set them correspondingly before this call. |
| 1175 |
%%# However, after the call you should also set them correspondingly for |
| 1176 |
%%# further processing. |
| 1177 |
%%# |
| 1178 |
%%# Example: |
| 1179 |
%%# \varindexMakeSplitExpand{:}{splitAtColon} |
| 1180 |
%%# \varindexNewFormat\splitAtColon{% |
| 1181 |
%%# \varindexNoNextSpace |
| 1182 |
%%# \ifvarindexIndexMode |
| 1183 |
%%# \varindexTokensOut{:}{}\varindexSpaceTexttrue |
| 1184 |
%%# \else |
| 1185 |
%%# \varindexTokensOut{---}{}\varindexNoNextSpace |
| 1186 |
%%# \fi} |
| 1187 |
%%# |
| 1188 |
%%# defines a new format entry `:' which has the meaning that a colon |
| 1189 |
%%# (automagically followed by a space) is put into the index but not into |
| 1190 |
%%# the sort entry. Moreover, in the running text, the colon appears as a |
| 1191 |
%%# long dash with no space followed. In any case, there is no magic space |
| 1192 |
%%# output in front of the colon. |
| 1193 |
%%# |
| 1194 |
|
| 1195 |
%%# As an alternative action in \varindexNewFormat, you can also call the |
| 1196 |
%%# default commands for the format entries. The corresponding macros are |
| 1197 |
%%# |
| 1198 |
%%# \varindexAddSpace _ |
| 1199 |
%%# \varindexAddSpTok s |
| 1200 |
%%# \varindexAddOmit . |
| 1201 |
%%# \varindexAddDash - |
| 1202 |
%%# \varindexAddComma , |
| 1203 |
%%# \varindexAddExclam ! |
| 1204 |
%%# \varindexAddTildeA ~ |
| 1205 |
%%# \varindexAddTildeB = |
| 1206 |
%%# \varindexAddNumber{number} 0-9 (the argument is 1-...) |
| 1207 |
%%# |
| 1208 |
%%# The precise meaning of these macros is intentionally NOT documented, |
| 1209 |
%%# because some details or side effects might change in a future release of |
| 1210 |
%%# "varindex". But just for this reason, it might be advantageous to use the |
| 1211 |
%%# above macros instead of writing personal substitutes which may fail to |
| 1212 |
%%# have such side effects. |
| 1213 |
%%# |
| 1214 |
%%# Example: |
| 1215 |
%%# \varindexMakeSplitExpand{~-}{splitPhrase}% It is important to expand |
| 1216 |
%%# % (to have correct ~ catcode) |
| 1217 |
%%# \varindexNewFormat\splitPhrase{% |
| 1218 |
%%# \varindexAddTildeA |
| 1219 |
%%# \let\remember\varindexPreceedsDash |
| 1220 |
%%# \let\varindexPreceedsDash\toolboxEmpty |
| 1221 |
%%# \varindexAddDash |
| 1222 |
%%# \let\varindexPreceedsDash\remember} |
| 1223 |
%%# |
| 1224 |
%%# After the above command, "~" and "-" have their usual meaning in |
| 1225 |
%%# the format string except when they follow immediately in the form "~-". |
| 1226 |
%%# In this case, the behavior of "-" changes as if \varindexPreceedsDash |
| 1227 |
%%# were empty (which has the effect that the output looks like "~ -" instead |
| 1228 |
%%# of "~-". |
| 1229 |
%%# Note that although "~" is a prefix to "~-", the converse is not true: |
| 1230 |
%%# Thus, the above command does not change the previous meaning of "~" |
| 1231 |
%%# (and of course also not of "-"). |
| 1232 |
|
| 1233 |
%%# |
| 1234 |
%%# Some hack: |
| 1235 |
%%# Tex ignores leading spaces in the argument list of a `normal' macro. |
| 1236 |
%%# This has the effect that you should be able to insert spaces BETWEEN any |
| 1237 |
%%# of your arguments without any trouble. |
| 1238 |
%%# If this does not work the expected way, you can use the command |
| 1239 |
%%# |
| 1240 |
%%# \let\varindexArgumentSpace\varindexSkipTricky |
| 1241 |
%%# |
| 1242 |
%%# which implements an own macro which does this task. Sadly, this can only |
| 1243 |
%%# be done with some catcode trickery which in turn might bring you in trouble |
| 1244 |
%%# with some (VERY) exotic packages. You can restore the default with |
| 1245 |
%%# |
| 1246 |
%%# \let\varindexArgumentSpace\varindexSkipDefault |
| 1247 |
%%# |
| 1248 |
%%# |
| 1249 |
%%# All above custamization commands/variables may be used anytime between |
| 1250 |
%%# two \varindex calls. They take effect with the next \varindex call. |
| 1251 |
|
| 1252 |
%%# The macros \varindextwoScan and \varindextwo are considered as a |
| 1253 |
%%# (very useful) EXAMPLE for the customization of the \varindex command. |
| 1254 |
%%# If you need further customization, have a look at their definition first. |
| 1255 |
|
| 1256 |
\endinput |
| 1257 |
%% |
| 1258 |
%% End of file `varindex.txt'. |