summaryrefslogtreecommitdiff
path: root/obsolete/indexing/corridx/doc/corridx.tex
blob: 8a825ebe841d442fdf77c12ff117ee0455b572bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
\documentclass{article}
\usepackage{makeidx}
\makeindex
\begin{document}
 \title{The CorrIdx Package}
 \author{ J. K. Fink\\ Uni Leoben}
 \maketitle

\begin{abstract}

The CorrIdx package can be used to sort an index with chemical
names containing leading numbers, etc. into a proper alphabetical
order. It is intended as a preprocessor to the MakeIndex program.

\end{abstract}

\tableofcontents

\begin{center}
  {\em The author is not liable for whatever will happen by the use of the material presented
  here.}\vskip2ex

  NOTE: In the examples below, the INDEX comes always on a new page
\end{center}

\section{Introduction}

In a text containing chemical names like N,N'-diallyl p-phenyl
diamine , 1,2-ethanediol, o-chlorobisphenol~A,
endo-methylenetetrahydrophthalic acid anhydride, tert-butanol, you
may want to include these compounds into the index. If you use the
index command \verb"\index{...}", \LaTeX\space will produce from
the entries
\begin{verbatim}
    \index{1,2-ethanediol}
    \index{o-chlorobisphenol~A}
    \index{endo-methylenetetrahydrophthalic acid anhydride}
    \index{tert-butanol}
    \index{N,N'-diallyl p-phenyl diamine}
\end{verbatim}
with the \LaTeX\space command \verb"\MakeIndex" a \verb"*.idx"
file looking like
\begin{verbatim}
    \indexentry{1,2-ethanediol}{1} \indexentry{o-chlorobisphenol~A}{1}
    \indexentry{endo-methylenetetrahydrophthalic acid anhydride}{1}
    \indexentry{tert-butanol}{1} \indexentry{N,N'-diallyl p-phenyl
    diamine}{1}
\end{verbatim}
and the program MakeIndex produces
\begin{theindex}
  \item 1,2-ethanediol, 1

  \indexspace

  \item endo-methylenetetrahydrophthalic acid anhydride, 1

  \indexspace

  \item N,N'-diallyl p-phenyl diamine, 1

  \indexspace

  \item o-chlorobisphenol~A, 1

  \indexspace

  \item tert-butanol, 1
\end{theindex}
Note that we differentiate in between the \LaTeX\space command
\verb"\MakeIndex"  and the MakeIndex program. We are using
\verb"\usepackage{makeidx}".

Now, you may find that the sort order in the example above is not
satisfactory. Therefore you must use the \verb"@" in the index
command to force a certain sort order. Try now the following index
entries
\begin{verbatim}
    \index{ethanediol@1,2-ethanediol}
    \index{chlorobisphenol@o-chlorobisphenol~A}
    \index{methylenetetrahydrophthalic@endo-methylenetetrahydrophthalic acid anhydride}
    \index{butanol@tert-butanol}
    \index{diallyl@N,N'-diallyl-p-phenyl diamine}
\end{verbatim}
and the MakeIndex program will produce now a more satisfactory
result. This is shown now:
\begin{theindex}

  \item tert-butanol, 3

  \indexspace

  \item o-chlorobisphenol~A, 3

  \indexspace

  \item N,N'-diallyl-p-phenyl diamine, 3

  \indexspace

  \item 1,2-ethanediol, 3

  \indexspace

  \item endo-methylenetetrahydrophthalic acid anhydride, 3

\end{theindex}
The MakeIndex program uses the \verb"*.idx" file and produces a
*.ind file. We try now another type of index entries like this
\begin{verbatim}
 \index{chem @1,2-ethanediol}
 \index{chem @o-chlorobisphenol~A}
 \index{chem @endo-methylenetetrahydrophthalic acid anhydride}
 \index{chem @tert-butanol}
 \index{chem @N,N'-diallyl p-phenyl diamine}
 \index{chem @curing}
 \index{chem @synthesis}
\end{verbatim}
A single run with the \LaTeX\space command \verb"\MakeIndex" in
the text produces
\begin{verbatim}
  \indexentry{chem @1,2-ethanediol}{5}
  \indexentry{chem @o-chlorobisphenol~A}{5}
  \indexentry{chem @endo-methylenetetrahydrophthalic acid anhydride}{5}
  \indexentry{chem @tert-butanol}{5}
  \indexentry{chem @N,N'-diallyl p-phenyl diamine}{5}
  \indexentry{chem @curing}{5}
  \indexentry{chem @synthesis}{5}
\end{verbatim}
Now we run the corridx program as preprocessor and get a modified
preprocessed file \verb"*.idx" looking like
\begin{verbatim}
 \indexentry{chem ethanediol@1,2-Ethanediol}{5}
 \indexentry{chem chlorobisphenol~a@o-Chlorobisphenol~A}{5}
 \indexentry{chem methylenetetrahydrophthalicacidanhydride@endo-Methylenetetrahydrophthalic acid anhydride}{5}
 \indexentry{chem butanol@tert-Butanol}{5}
 \indexentry{chem diallylphenyldiamine@N,N'-Diallyl p-phenyl diamine}{5}
 \indexentry{chem curing@Curing}{5}
 \indexentry{chem synthesis@Synthesis}{5}
\end{verbatim}
Further, the MakeIndex program produces from this file an *.ind
file that is printed out as
\begin{theindex}
  \item tert-Butanol, 5
  \item o-Chlorobisphenol~A, 5
  \item Curing, 5
  \item N,N'-Diallyl p-phenyl diamine, 5
  \item 1,2-Ethanediol, 5
  \item endo-Methylenetetrahydrophthalic acid anhydride, 5
  \item Synthesis, 5
\end{theindex}
This is probably what you want.
\section{The Corridx Program}

The source code of the program is in Pascal compiled with Free
Pascal \newline (\verb"http://www.freepascal.org/")

\subsection{Using the Program}

Corridx stands for correct the \verb"*.idx" file. The simplest
call is to run \verb"corridx.exe". Then a file \verb"in.txt" must
be in the same directory as \verb"corridx.exe" and the output
comes in a file \verb"out.txt". Therefore you may copy your
\verb"*.idx" file into the \verb"in.txt", run \verb"corridx.exe"
and collect the output from \verb"out.txt". This output copy back
in your \verb"*.idx" file and run immediately the \verb"MakeIndex"
program.

If a command line parameter just one meaning a valid file name is
there, then the \verb"corridx.exe" takes this as input file and
copies the output back to this file. If more than one command line
is there, or if the filename is not correct, I did not check what
will happen.

I am running from Winedt both programs, as I have changed the
index menu into
\begin{verbatim}
  Run("c:\fullpathtocorridx\corridx.exe %P\%N.idx","%P",0,0,"CorrIdx",1,1);
  Prompt('Finished CorrIdx');
  Exe('%B\Exec\MiKTeX\MakeIndex.edt');
\end{verbatim}
The prompt is necessary to retard the program execution. Or else
you may use instead of the \verb"Run" command the \verb"WinExe"
command with the synchronize option. I did not check out this.

\subsection{Program Description}

Note that every index entry you create must contain a \verb"@",
otherwise an error will be created. For example create the entry
\verb"\index{chem @1,4-butanediol}". The program scans each line
in the \verb"*.idx" file. When it finds \verb"chem" just behind
the opening bracket \verb"{", it ignores what is after \verb"chem"
until it finds the \verb"@". Then it reads the name string until
the closing bracket comes. There should be no \verb"\}" in
between. Finally it reads the string with the page number. The
name string is copied to a sort string which is now processed:

\begin{enumerate}
    \item Every text in between dollar signs is replaced by a
    blank.
    \item Every non letter besides the tilde \verb"~" is replaced by a blank.
    So you may protect \verb"bisphenol~A".
    \item Every single letter in between blanks is replaced by a blank.
    \item Special sequences like exo, endo, tert, sec, cis,
    trans, syn, anti, cyclo, spiro are replaced by blanks.
    \item what is left over is made lower case.
\end{enumerate}

The program is looking now in the sort string for the first
appearance of a letter and makes in the name string this position
as uppercase. Then in the sort string all spaces are eliminated.
Finally, the index entry is rebuilt to result in
\verb"\indexentry{chem butanediol@1,4-Butanediol}{8}"%

\subsection{Further Options}

Four types of index are allowed:
\begin{enumerate}
    \item Index of chemicals \verb"\index{chem @1,3-Butadiene}"
    \item General Index \verb"\index{gen @Synthesis}"
    \item Index of acronyms \verb"\index{acr LCD@LCD!Liquid crystal display}"
    \item Index of other items \verb"\index{whatever you want@abc}"
\end{enumerate}
In an index entry of acronyms, a \verb"!" is compulsory. The
example above produces the index:

\begin{theindex}

  \item LCD
    \subitem Liquid crystal display, 8

  \indexspace

  \item 1,3-Butadiene, 8

  \indexspace

  \item Synthesis, 8

  \indexspace

  \item abc, 8

\end{theindex}

\section{User Defined Commands}

To get a better performance, it is a good idea to define the
following commands:

\begin{verbatim}
\newcommand{\ia}[2]{#1 {\nobreak(#2)}\index{acr #2@#2!#1}}
% is is an acronym index. Example: \ia{Polyalkylene oxide}{PAO} %
\newcommand{\ic}[1]{#1\index{chem #1@#1}}
% ic is a chemical index
\newcommand{\ib}[2]{#1 {\nobreak(#2)}\index{acr #2@#2!#1}\index{chem #1@#1}}
% ib is both acronym and chemical index
\newcommand{\ig}[2][]{#2\index{gen #2@#2#1}}
% ig is a general index
\end{verbatim}

\newcommand{\ia}[2]{#1 {\nobreak(#2)}\index{acr #2@#2!#1}}
% Example: \ia{Polyalkylene oxide}{PAO} %
\newcommand{\ic}[1]{#1\index{chem #1@#1}}
\newcommand{\ib}[2]{#1 {\nobreak(#2)}\index{acr #2@#2!#1}\index{chem #1@#1}}
% ib is both acronym and chemical
\newcommand{\ig}[2][]{#2\index{gen #2@#2#1}}

We show now the use of these commands in the following sample
text. You should look in the original \LaTeX\space file.

Note that we have in the text also the commands
\begin{verbatim}
    \newcommand\swallow[1]{\relax}
    \index{acr   @\section*{Acronyms}\swallow|swallow}%
    \index{chem  @\section*{Chemicals}\swallow|swallow}%
    \index{gen  @\section*{General}\swallow|swallow}%
\end{verbatim}

\section{Sample Text}

There are various types of novolak resins with different \ig[
resins]{ortho} to para ratios of the methylene linkages, \ia{high
ortho novolak resins}{HON}, \ia{general-purpose novolak
resins}{GPN} and \ia{high para novolak resins}{HPN}.

The liquid-phase oxidation of cumene to \ib{cumene
hydroperoxide}{CHP} results in \ic{acetone} and \ic{phenol}. This
is used for \ic{bisphenol~A}, \ic{bisphenol~B}, \ic{resorcinol},
\ic{cresol}s, and \ic{xylenol}s. \ic{2-Cyclohexyl-5-methylphenol}
is used for \ig[!positive]{photoresist}s. \ic{m-Methoxyphenol},
\ic{2-naphthol}, \ic{cardanol}, and \ic{cardol}, are other
suitable \ig[!other]{phenols}.


\section{The Sample Text Verbatim}

\begin{verbatim}
There are various types of novolak resins with different \ig[
resins]{ortho} to para ratios of the methylene linkages, \ia{high
ortho novolak resins}{HON}, \ia{general-purpose novolak
resins}{GPN} and \ia{high para novolak resins}{HPN}.

The liquid-phase oxidation of cumene to \ib{cumene
hydroperoxide}{CHP} results in \ic{acetone} and \ic{phenol}. This
is used for \ic{bisphenol~A}, \ic{bisphenol~B}, \ic{resorcinol},
\ic{cresol}s, and \ic{xylenol}s. \ic{2-Cyclohexyl-5-methylphenol}
is used for \ig[!positive]{photoresist}s. \ic{m-Methoxyphenol},
\ic{2-naphthol}, \ic{cardanol}, and \ic{cardol}, are other
suitable \ig[!other]{phenols}.
\end{verbatim}


    \newcommand\swallow[1]{\relax}
    \index{acr   @\section*{Acronyms}\swallow|swallow}%
    \index{chem  @\section*{Chemicals}\swallow|swallow}%
    \index{gen  @\section*{General}\swallow|swallow}%

\printindex

\end{document}
%