summaryrefslogtreecommitdiff
path: root/support/intex/latex/intex.dtx
blob: 564c81d82078d5703ee569d9026a92fcbb03b8cd (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
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
% \iffalse meta-comment
% $Id$
% Copyright (C) 2005--2008 by Martin Thorsen Ranang <mtr@ranang.org>
% -------------------------------------------------------
% 
% This file may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.2
% of this license or (at your option) any later version.
% The latest version of this license is in:
%
%    http://www.latex-project.org/lppl.txt
%
% and version 1.2 or later is part of all distributions of LaTeX 
% version 1999/12/01 or later.
%
% \fi
%
% \iffalse
%<*driver>
\ProvidesFile{intex.dtx}
%</driver>
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{intex}
%<*package>
   [2008/10/13 v1.1 A concept indexing and typesetting package]
%</package>
%<*batchfile>
\begingroup
%%
%% Copyright (C) 2005--2008 by Martin Thorsen Ranang <mtr@ranang.org>
%%
%% This file may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License, either version 1.2 of this license
%% or (at your option) any later version.  The latest version of this
%% license is in:
%% 
%%    http://www.latex-project.org/lppl.txt
%% 
%% and version 1.2 or later is part of all distributions of LaTeX version
%% 1999/12/01 or later.
%%
\input docstrip.tex
\keepsilent

\usedir{tex/latex/intex}

\preamble

This is a generated file.

Copyright (C) 2005--2008 by Martin Thorsen Ranang <mtr@ranang.org>

This file may be distributed and/or modified under the conditions of
the LaTeX Project Public License, either version 1.2 of this license
or (at your option) any later version.  The latest version of this
license is in:

   http://www.latex-project.org/lppl.txt

and version 1.2 or later is part of all distributions of LaTeX version
1999/12/01 or later.

\endpreamble

\askforoverwritefalse
\generate{\file{intex.sty}{\from{intex.dtx}{intex}}}

\obeyspaces
\Msg{*************************************************************}
\Msg{*                                                           *}
\Msg{* To finish the installation you have to move the following *}
\Msg{* file into a directory searched by TeX:                    *}
\Msg{*                                                           *}
\Msg{*     intex.sty                                             *}
\Msg{*                                                           *}
\Msg{* To produce the documentation run the file intex.dtx       *}
\Msg{* through LaTeX.                                            *}
\Msg{*                                                           *}
\Msg{* Happy TeXing!                                             *}
\Msg{*                                                           *}
\Msg{*************************************************************}

\endgroup
%</batchfile>
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{intex}[2008/10/13]
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[norsk,english]{babel}
\usepackage{fancyvrb}
\usepackage{url}
\usepackage[colorlinks=true]{hyperref}
\usepackage{svn}
\usepackage{booktabs}
\SVN $Rev$
\SVN $Date$
\EnableCrossrefs
%\CodelineIndex
\RecordChanges
\begin{document}
  \DocInput{intex.dtx}
  %\PrintChanges
  %\PrintIndex
\end{document}
%</driver>
% \fi
%
% \CheckSum{0} ^^A Should be 0 during development.
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
%
% \changes{v1.0}{2005/08/05}{Initial version}
%
% \GetFileInfo{intex.dtx}
%
% \DoNotIndex{\newcommand,\newenvironment}
%
% ^^A From ltugboat.cls
%
% ^^A Typeset the name of an environment
% \providecommand\env[1]{\textsf{#1}}
% \providecommand\clsname[1]{\textsf{#1}}
% \providecommand\pkgname[1]{\textsf{#1}}
% \providecommand\optname[1]{\textsf{#1}}
% \providecommand\progname[1]{\textsf{#1}}
%
% ^^A A list of options for a package/class
% \newenvironment{optlist}{\begin{description}%
%   \renewcommand\makelabel[1]{%
%     \descriptionlabel{\mdseries\optname{##1}}}%
%   \itemsep0.25\itemsep}%
%  {\end{description}}
%
% ^^A Utility macros
%
% ^^A Special dashes
% \def\thinskip{\hskip 0.16667em\relax}
% \def\endash{--}
% \def\emdash{\endash-}
% \def\d@sh#1#2{\unskip#1\thinskip#2\thinskip\ignorespaces}
% \def\dash{\d@sh\nobreak\endash}
% \def\Dash{\d@sh\nobreak\emdash}
%
% ^^A Example macros - adapted from the `fvrb-ex' package
% ^^A ---------------------------------------------------
%
% ^^A Take care that we use here the "Z" character as comment character,
% ^^A to avoid to use an 8 bit one which can cause portability problems.
% ^^A But we can't use any more the "Z" into the example environments
% ^^A of this documentation.
%
% \makeatletter
% \newcommand{\BeginExample}[1][0]{%
% \parindent=0pt
% \multiply\topsep by 2
% \VerbatimEnvironment
% \begin{VerbatimOut}[gobble=#1]{\jobname.tmp}}
%
% \newcommand{\BelowExample}[1]{%
% \VerbatimInput[gobble=4,commentchar=Z,numbersep=3pt,frame=single,
%                numbers=left]{\jobname.tmp}
% \catcode`\Z=9\relax%
% #1\par}
%
% \newcommand{\SideBySide@Example}[1]{%
% \@tempdimb=\FV@XRightMargin
% \advance\@tempdimb -5mm
% \vspace{2mm}
% \begin{minipage}[c]{\@tempdimb}
%   \fvset{xrightmargin=0pt}%
%   \catcode`\Z=9\relax%
%   #1
% \end{minipage}%
% \@tempdimb=\textwidth
% \advance\@tempdimb -\FV@XRightMargin
% \advance\@tempdimb 5mm
% \begin{minipage}[c]{\@tempdimb}
%   \VerbatimInput[commentchar=Z,numbersep=3pt,frame=single,
%                  numbers=left,xleftmargin=5mm,xrightmargin=0pt]{\jobname.tmp}
% \end{minipage}
% \vspace{2mm}}
%
% \def\Example{%
% \catcode`\^^M=\active
% \@ifnextchar[{\catcode`\^^M=5\Example@}{\catcode`\^^M=5\Example@@}}
% \def\Example@[#1]{\fvset{#1}\Example@@}
% \def\Example@@{\BeginExample}
% \def\endExample{%
% \end{VerbatimOut}%
% \BelowExample{\input{\jobname.tmp}}}
%
% \def\CenterExample{%
% \catcode`\^^M=\active
% \@ifnextchar[{\catcode`\^^M=5\CenterExample@}
%              {\catcode`\^^M=5\CenterExample@@}}
% \def\CenterExample@[#1]{\fvset{#1}\CenterExample@@}
% \def\CenterExample@@{\BeginExample}
% \def\endCenterExample{%
% \end{VerbatimOut}%
% \center
% \BelowExample{\input{\jobname.tmp}}
% \endcenter}
% 
% \def\SideBySideExample{%
% \catcode`\^^M=\active
% \@ifnextchar[{\catcode`\^^M=5\SideBySideExample@}%
%              {\catcode`\^^M=5\SideBySideExample@@}}
% \def\SideBySideExample@[#1]{\fvset{#1}\SideBySideExample@@}
% \def\SideBySideExample@@{\BeginExample[4]}
% \def\endSideBySideExample{%
% \end{VerbatimOut}%
% \SideBySide@Example{\input{\jobname.tmp}}}
% \makeatother
%
% ^^A End of example macros from `fvrb-ex'
%
% \makeatletter
% \date{\the\year/\two@digits{\the\month}/\two@digits{\the\day}}
% \makeatother
%
% ^^A The beginning of the documentation itself.
%
% \title{The \textsf{\InTeX} Package\thanks{This document corresponds
%     to \textsf{intex}, revision~\SVNRev, dated \today.}}
% \author{Martin Thorsen Ranang \\ \texttt{mtr@ranang.org}}
%
% \maketitle
%
% \section{Introduction}
% This package adds functionality to \LaTeX\ that eases typesetting
% and indexing of phrases, acronyms and names in a consistent manner.
%
% \DescribeMacro{intex} \DescribeMacro{\co}
% The really short usage description is that in order to use the
% package, insert |\usepackage{intex}| at the beginning of your
% \LaTeX\ source file.  After that, you can wrap the macro
% |\co{|\meta{concept}|}| around any concept you want to typeset
% and/or typeset in some special way.
%
% \section{Background}
% I have been using \LaTeX\ since the spring of 1997.  Since then I
% have written several technical documents.  Like many others, I try
% to present my work in an accessible way to the reader, and I believe
% that \LaTeX\ can help with the technicalities of presenting
% technical writing in a clear and precise way.  For example, I have
% always tried to explain every non-trivial acronym used in my
% documents; include a meaningful index; and to also leave some clues
% to the reader through the typesetting, so that it will be easier to
% find the key phrases in the document.
%
% Already, packages exist that provide functionality that eases the
% \DescribeMacro{acronym}acronym\footnote{The |acronym| package,
%   written by Tobias Oetiker, available from
%   \url{CTAN:/macros/latex/contrib/acronym}.} and
% \DescribeMacro{index}indexing\footnote{The |index| package, written
%   by David M.\,Jones, available from
%   \url{CTAN:/macros/latex/contrib/index}.} operations mentioned
% above.  However, problems quickly arise when writing about an
% acronym in both singular and plural.  For example, let's say you
% want to use the concept \emph{informed search} (abbreviated IS).
% Then, if you want to write about that concept in plural, the logical
% acronym would be ISes (informed searches).  At the same time, you
% probably want those two occurences---perhaps typeset several
% chapters apart---to be indexed as being the same concept.
%
% The \InTeX\ package was written to reduce the work needed to handle
% such a task.  This has been done by combining the functionality of
% the |acronym| and the |index| packages with an external
% \co{Python}\footnote{\co{Python} is available from
% \url{http://www.python.org/}.} script.
%
% \section{Usage}
% How you can use \InTeX\ should be clearer after examining some
% examples.  The central idea in \InTeX\ is that a phrase or a word
% worth indexing constitutes some kind of a \co{concept}---in a broad
% sense of the word.  A \co{concept} can be of several kinds.  It can
% be either an \co{acronym} (or abbreviation), the name of an entity
% (a \co{person concept}, or an organization), or of the ``plain''
% kind (simply a phrase).  Hence, we will refer to the three kinds of
% \co{concepts} as \emph{\co{acronym concepts}}, \emph{\co{person
%     concepts}}, and \emph{\co{plain concepts}}.
%
% In the above paragraph, the word ``concepts'' was defined as a
% \co{concept} of the \co{plain} kind, and it was defined to be
% indexed as the word ``concept''.  Furthermore, the words
% ``acronym'', ``person'', and ``plain'' where also defined as
% \co{plain}.  However, these concepts are defined as
% \co{sub-concepts} of ``concept'' and should be indexed accordingly.
%
% \subsection{Package Options}
% \begin{optlist}
%   \item[noindex]: Whether \InTeX\ should generate an index or not.
% (\emph{Default: true}).
% \item[nowarnundef]: Whether \InTeX\ should generate in-document
%  warnings where unknown/undeclared concepts are encountered.
% (\emph{Default: true}).
% \item[nomargin\meta{type}]: Tell \InTeX\ not to add margin notes
%  whenever \emph{new} concepts of kind \meta{type} are typeset, where
%  \meta{type} is one of \optname{plain}, \optname{acronym}, or
%  \optname{person}.
% \end{optlist}
%
% \subsection{Examples}
% \begin{SideBySideExample}[xrightmargin=5cm]
%   \makeatletter
%   \@itx@margin@acronymfalse%
%   \makeatother
%   It is easy to refer to (and thus index)
%   acronyms, like \co{H2O}.  And 
%   sub-concepts, like \co{H2O reserve}
% \end{SideBySideExample}
%
% \begin{SideBySideExample}[xrightmargin=5cm]
%   \makeatletter
%   \@itx@margin@acronymfalse%
%   \makeatother
%   We could talk about multiple \co{IDs}, 
%   or a single \co{ID}.  The following 
%   table shows explicitly defined 
%   formatting:\\
%
%   \begin{tabular}{@{}ll@{}}
%     \toprule
%     Format & Expansion \\
%     \midrule 
%     forced long & ``\coL{ID}''\\
%     short & ``\coS{ID}''\\
%     full & ``\coF{ID}'' \\
%     \bottomrule
%   \end{tabular}
% \end{SideBySideExample}
%
% \begin{SideBySideExample}[xrightmargin=5cm]
%   \makeatletter
%   \@itx@margin@acronymfalse%
%   \makeatother
%   The \InTeX\ package also supports 
%   indexing sub-terms of acronyms,
%   like the \co{Swedish SIMPLE}, which
%   is part of the \co{SIMPLE} project.
% \end{SideBySideExample}
%
% The package supports typesetting words differently in the text and
% in the index.  For example, take a look at the definition of the
% term ``\co{compound-word analyzer}'' in the \InTeX-file.  Example
% that provokes hyphenation: a new, experimental \co{compound-word
%   analyzer}, used for \co{Norwegian compound-word analysis} of
% \co{non-deverbal verb compounds}, perhaps found in
% \co{Bokmålsordboka}.  Generally, analyzing \co{compounds}.
%
% \makeatletter
% \@itx@margin@plainfalse%
% \makeatother
% \begin{SideBySideExample}[xrightmargin=5cm]
%   The word \co{carnivore} means
%   \co{meat eater}.  There are both
%   \co{feline} and \co{canine}
%   \co{meat eaters} in the animal
%   kingdom.
% \end{SideBySideExample}
% \makeatletter
% \@itx@margin@plaintrue%
% \makeatother
%
% It is also possible to refer to acronyms from non-acronym entries,
% like \co{water}.
%
% It is also possible to refer to a concept using capitalized words,
% as in
%
% \makeatletter
% \@itx@margin@plainfalse%
% \makeatother
% \begin{SideBySideExample}[xrightmargin=5cm]
%   \co{Carnivore} eat meat.
% \end{SideBySideExample}
% \makeatletter
% \@itx@margin@plaintrue%
% \makeatother
%
% The package also supports ``special'' typesetting of acronyms, like
%
% \makeatletter
% \@itx@margin@plainfalse%
% \makeatother
% \begin{SideBySideExample}[xrightmargin=5cm]
%   \verb|mkintex| automatically inflects 
%   words following common patterns.  For
%   example, \co{index} and \co{indices} 
%   both refer to the same concept, even
%   though only \verb|index| is entered 
%   in the \InTeX-file.  The same goes for
%   \co{vertex} and \co{vertices}, and
%   \co{dog} and \co{dogs}.
% \end{SideBySideExample}
% \makeatletter
% \@itx@margin@plaintrue%
% \makeatother
%
% The \InTeX\ package handles the notion of multiple names for the
% same concept too.  For example, a lot of people believes that
% \co{EAPK} is referring to one person only, and that is the late
% \co{EAP}.
%
% \subsubsection{Index Definitions}
% The concept index definition file used for the above paragraph looks
% like:
% \VerbatimInput[showtabs=true,tabsize=4,numbers=left,fontsize=\small,lastline=1]{intex.itx}
% The file can be divided into different sections, according to the
% kind of concepts to be declared.  To set the
% current section, use a single line that must contain exactly 
% |"% *|\meta{type}|*"|, where \meta{type} is either |ACRONYMS|,
% |CONCEPTS|, or |PERSONS|.
%
% \VerbatimInput[showtabs=true,tabsize=4,numbers=left,fontsize=\small,firstline=2,lastline=10]{intex.itx}
% the above line should mean that |\co{synsets}| in the text should be
% indexed as if it read |\co{synset}|.  However, if the plural of the
% concept occurs first (in the [part of] document), its full-form
% should be \emph{typeset} ``synonym set'' + ``s'' (indicated by the |#y|) in
% the index file.  In other words, it only a short-hand notation.  On the
% other hand, in the next definition, another short-hand notation |#y|
% is used that will transform ``y'' into ``ies'' as the end of the last
% word:
%
% \VerbatimInput[showtabs=true,tabsize=4,numbers=left,fontsize=\small,firstline=11]{intex.itx}
%
% \subsection{Compilation}
% \label{sec:compilation}
% \DescribeMacro{mkintex} As mentioned earlier, the package includes
% an external program named |mkintex|.  The typical usage of
% |mkintex|, given that your document is named \meta{name}, would
% be \co{concept}:
% 
% \begin{enumerate}
% \item |latex |\meta{name}|.tex|
% \item |mkintex |\meta{name} \meta{name}|.itx -o |\meta{name}|.rix [-a acronyms.tex -p persons.tex]|
% \item |makeindex |\meta{name}
% \item |makeindex -o |\meta{name}|.rid |\meta{name}|.rix|
% \item |latex |\meta{name}|.tex|
% \end{enumerate}
%
% \section{Macros}
%
% \DescribeMacro{\InTeX}
% This is simply a macro for typesetting the \co{InTeX logo}. 
%
% \StopEventually{}
%
% \section{Implementation}
%
% After the customary identification,
%    \begin{macrocode}
\def\filename{intex}%
\ProvidesPackage{intex}[2008/10/13 v1.1
Support for concept, acronym, and proper-name typesetting and indexing]%
%    \end{macrocode}
% we continue by defining the package options.
%
% \subsection{Package Options}
%
% \begin{macro}{noindex}
% \begin{macro}{\if@itx@index}
% Let the conditional |\if@itx@index| control whether
% \InTeX\ should generate an index or not.  The default is to perform
% indexing.  The option |noindex| turns this feature off.
%    \begin{macrocode}
\newif\if@itx@index%
\@itx@indextrue%
\DeclareOption{noindex}{\@itx@indexfalse}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{nowarnundef}
% \begin{macro}{\if@itx@nowarnundef}
% The conditional |\if@itx@nowarnundef| controls whether
% \InTeX\ should include in-document warnings about undefined concepts
% or not.  The default is to warn about undefined concepts inside the
% document.  The |nowarnundef| option turns this feature off.
%    \begin{macrocode}
\newif\if@itx@warn@undef%
\@itx@warn@undeftrue%
\DeclareOption{nowarnundef}{\@itx@warn@undeffalse}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{nomarginplain}
% \begin{macro}{nomarginacronym}
% \begin{macro}{nomarginperson}
% \begin{macro}{\if@itx@margin@plain}
% \begin{macro}{\if@itx@margin@acronym}
% \begin{macro}{\if@itx@margin@person}
%
% The conditionals |\if@itx@margin@|\meta{kind}---where \meta{kind} is
% one of |plain|, |acronym|, and |person|---control whether the short
% version of each first-occurrence of a concept (of kind \meta{kind},
% per significant document part) should also be typeset as a
% margin-label.
%
%    \begin{macrocode}
\newif\if@itx@margin@plain%
\newif\if@itx@margin@acronym%
\newif\if@itx@margin@person%
\@itx@margin@plaintrue%
\@itx@margin@acronymtrue%
\@itx@margin@persontrue%
\DeclareOption{nomarginplain}{\@itx@margin@plainfalse}%
\DeclareOption{nomarginacronym}{\@itx@margin@acronymfalse}%
\DeclareOption{nomarginperson}{\@itx@margin@personfalse}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% Next, process the options.
%    \begin{macrocode}
\ProcessOptions%
%    \end{macrocode}
%
% \subsection{External Packages}
%
% \begin{macro}{index}
% Now, if |\if@itx@index| is \emph{true}, then require the package
% |index| to be loaded.  If not, we define a handy macro usually
% defined in that package.
%    \begin{macrocode}
\if@itx@index%
  \RequirePackage{index}%
  \makeindex%
  \newindex{raw}{rix}{rid}{Index}%
\else%
  \def\@nearverbatim{\expandafter\strip@prefix\meaning}%
\fi%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{marginnote}
%   Only require the marginnote package if it is really required.
%   This is done in an attempt to avoid wasting counters.
%    \begin{macrocode}
\if@itx@margin@plain%
  \RequirePackage{marginnote}[2006/10/26]%
\fi%
\if@itx@margin@acronym%
  \RequirePackage{marginnote}[2006/10/26]%
\fi%
\if@itx@margin@person%
  \RequirePackage{marginnote}[2006/10/26]%
\fi%
%    \end{macrocode}
% Please note that the |marginnote| package will only be loaded once,
% even if it gets required multiple times.
% \end{macro}
%
% \begin{macro}{acronym}
% \begin{macro}{ifthen}
%   Anyhow, require the |acronym| and the |ifthen| packages to be
%   loaded.
%    \begin{macrocode}
\RequirePackage{acronym}[2008/05/28]%
\RequirePackage{ifthen}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% 
% \subsection{The \InTeX\ Logo}
% \begin{macro}{\InTeX}
% Define a \TeX-ish logo for this package.
%    \begin{macrocode}
\newcommand*{\InTeX}{\textsl{In}\kern-.07em\TeX}%
%    \end{macrocode}
% \end{macro}
%
% \subsection{Font Definitions}
%
% The following commands define the font-selection commands used to
% typeset the different kinds of concepts in different situations.
%
% \begin{macro}{\itxplaindeffont}
% \begin{macro}{\itxplainfollowfont}
% \begin{macro}{\itxplainmarginfont}
% These commands are used to typeset plain concepts.
%    \begin{macrocode}
\newcommand\itxplaindeffont[1]{\emph{#1}}%
\newcommand\itxplainfollowfont[1]{#1}%
\newcounter{itxpl}%
\newcommand\@itxbasemarginfont[1]{%
  \stepcounter{itxpl}%
  \ifthenelse{\isodd{\pageref{itxpl-\theitxpl}}}{%
    \raggedright\hspace{0pt}\footnotesize\textsf{#1}% odd
  }{%
    \raggedleft\hspace{0pt}\footnotesize\textsf{#1}% even
  }%
  \label{itxpl-\theitxpl}%
}%
\newcommand\itxplainmarginfont[1]{%
  \@itxbasemarginfont{#1}%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\itxacronymdeffont}
% \begin{macro}{\itxacronymdefshortfont}
% \begin{macro}{\itxacronymshortfont}
% \begin{macro}{\itxacronymmarginfont}
%
% For acronyms:
%    \begin{macrocode}
\newcommand{\itxacronymdeffont}[1]{#1}%
\newcommand{\itxacronymdefshortfont}[1]{\emph{#1}}%
\newcommand{\itxacronymshortfont}[1]{#1}%
\newcommand{\itxacronymmarginfont}[1]{%
  \@itxbasemarginfont{#1}%
  %\raggedleft\hspace{0pt}\footnotesize\textsf{#1}%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\itxpersondeffont}
% \begin{macro}{\itxpersonfirstfont}
% \begin{macro}{\itxpersonlastfont}
% \begin{macro}{\itxpersonmarginfont}
%
% For persons:
%    \begin{macrocode}
\newcommand{\itxpersondeffont}[1]{\emph{#1}}%
\newcommand{\itxpersonfirstfont}[1]{#1}%
\newcommand{\itxpersonlastfont}[1]{#1}%
\newcommand{\itxpersonmarginfont}[1]{%
  \@itxbasemarginfont{#1}%
  %\raggedleft\hspace{0pt}\footnotesize\textsf{#1}%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsection{The (Low-Level) Clockwork of the Package}
%
% \begin{macro}{co@serial}
%   First, define a counter that is used to enumerate new concept
%   definitions.
%    \begin{macrocode}
\newcounter{co@serial}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{co@equiv@serial}
%   First, define a counter that is used to enumerate new concept
%   definitions.
%    \begin{macrocode}
%\newcounter{co@equiv@serial}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{co@type}
%   First, define a counter that is used to enumerate new concept
%   definitions.
%    \begin{macrocode}
\newcounter{co@type}%
%    \end{macrocode}
% The |co@type| counter is used only inside the |\@itx| command.
% \end{macro}
%
% \begin{macro}{\itxundefcomment}
% Then, define the comment to display where use of undefined concepts
% are detected.
%    \begin{macrocode}
\newcommand*\itxundefcomment[1]{\emph{(undefined concept ``#1'')}}%
%    \end{macrocode}
% \end{macro}
%
% Define a couple of convenience macros.
%    \begin{macrocode}
\long\def\@firstofthree#1#2#3{#1}%
\long\def\@secondofthree#1#2#3{#2}%
%\newcommand*\@secondofthree[3]{#2}%
%    \end{macrocode}
%
% Make it possible to reset the ``defined'' flag for each concept.
% After a reset, the next time that concept occurs, it is typeset as
% if it's the first occurrence of that concept.
%    \begin{macrocode}
\def\ITX@reset#1{%
  \global\expandafter\let\csname itx@#1\endcsname\relax}%
%    \end{macrocode}
%
% \subsubsection{Typesetting of Margin Labels}
% \begin{macro}{\@itxmarginlabel}
%
% Define a macro to typeset the concepts at first-occurrence points in
% the margin.
%
%    \begin{macrocode}
\newcommand*\@itxmarginlabel[2]{%
  \hspace{0pt}%
%    \end{macrocode}
% 
% The second argument is the \meta{identity} of the entity we're
% typesetting, while the first argument signals its \meta{type}; that
% is, whether we're typesetting a\ldots
% 
%    \begin{macrocode}
  \ifcase#1%
%    \end{macrocode}
  % \ldots plain concept, \ldots
%    \begin{macrocode}
    \if@itx@margin@plain%
      \marginpar{\itxplainmarginfont{\ITX@itxs{#1}{#2}}}%
      %\marginnote{\itxplainmarginfont{\ITX@itxs{#1}{#2}}}%
    \fi%
  \or%
%    \end{macrocode}
  % \ldots an acronym, \ldots
%    \begin{macrocode}
    \if@itx@margin@acronym%
      \marginpar{\itxacronymmarginfont{\ITX@itxs{#1}{#2}}}%
    \fi%
  \or%
%    \end{macrocode}
  % \ldots or a person's name.
%    \begin{macrocode}
    \if@itx@margin@person%
      \marginpar{\itxpersonmarginfont{\ITX@itxl{#1}{#2}}}%
    \fi%
  \fi%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\ITX@used}
% Value to flag a concept as used.
%    \begin{macrocode}
\newcommand*\ITX@used{@<>@<>@}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ITX@get}
%    \begin{macrocode}
\newcommand*\ITX@get[2]{%
  \ifx#1\relax%
  \else%
    \expandafter#2#1%
  \fi%
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\itxplainarea}
% \begin{macro}{\itxacronymarea}
% \begin{macro}{\itxpersonarea}
% \begin{macro}{\@itxarea}
% Significant-area definitions.  When these counters change, the
% concepts concerned will be typeset as first occurrences.
%    \begin{macrocode}
\newcommand*\itxplainarea{\thesubparagraph:\thepage}%
\newcommand*\itxacronymarea{\thechapter}%
\newcommand*\itxpersonarea{\thesubsubsection}%
\newcommand*\@itxarea[1]{%
  \ifcase#1%
    {\itxplainarea}%
  \or%
    {\itxacronymarea}%
  \or%
    {\itxpersonarea}%
  \fi%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\itx@last@pos0}
% \begin{macro}{\itx@last@pos1}
% \begin{macro}{\itx@last@pos2}
%   The default (empty) area definitions.
%    \begin{macrocode}
\def\itx@last@pos0{}%
\def\itx@last@pos1{}%
\def\itx@last@pos2{}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\ITX@itxs}
%    \begin{macrocode}
\newcommand*\ITX@itxs[2]{%
  \csname fnss@\number#2\endcsname%
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ITX@itxl}
%    \begin{macrocode}
\newcommand*\ITX@itxl[2]{%
  \csname fnsl@\number#2\endcsname%
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\itxs}
%   The syntax is |\itxs{|\meta{type}|}{|\meta{identity}|}|.  A
%   wrapper for |\@itxs|.
%    \begin{macrocode}
\newcommand*{\itxs}[2]{%
  \texorpdfstring{\protect\@itxs{#1}{#2}}{#1}}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@itxs}
%   The syntax is |\@itxs{|\meta{type}|}{|\meta{identity}|}|.
%   Typesets the concept referred to by \meta{identity} in its
%   \emph{short form} according to its \meta{type}.
%    \begin{macrocode}
\newcommand*{\@itxs}[2]{%
  \ifcase\number#1%
%    \end{macrocode}
% \begin{description}
% \item[Plain Concept]
%    \begin{macrocode}
    \itxplainfollowfont{\ITX@itxs{#1}{#2}}%
  \or%
%    \end{macrocode}
% \item[Acronym]
%    \begin{macrocode}
    \itxacronymshortfont{\ITX@itxs{#1}{#2}}%
  \or%
%    \end{macrocode}
% \item[Person]
%    \begin{macrocode}
    \itxpersonlastfont{\ITX@itxl{#1}{#2}}%
  \fi%
}%
%    \end{macrocode}
% \end{description}
% \end{macro}
%
% \begin{macro}{\itxl}
%   The syntax is |\itxl{|\meta{type}|}{|\meta{identity}|}|.  A
%   wrapper for |\@itxl|.
%    \begin{macrocode}
\newcommand*{\itxl}{\protect\@itxl}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@itxl}
%   The syntax is |\@itxl{|\meta{type}|}{|\meta{identity}|}|.
%   Typesets the concept referred to by \meta{identity} in its
%   \emph{long form} according to its \meta{type}.
%    \begin{macrocode}
\newcommand*{\@itxl}[2]{%
  %\ITX@itxl{#1}{#2}%
  \ifcase\number#1%
%    \end{macrocode}
% \begin{description}
% \item[Plain Concept] Typeset the concept, \ldots
%    \begin{macrocode}
    \itxplainfollowfont{\ITX@itxs{#1}{#2}}\nolinebreak %
  \or%
%    \end{macrocode}
% \item[Acronym] Typeset the concept (note in-between margin
%   label), \ldots
%    \begin{macrocode}
    \itxacronymdeffont{\ITX@itxl{#1}{#2}}%
  \or%
%    \end{macrocode}
% \item[Person] Typeset the concept (note the in-between margin
%   label), \ldots
%    \begin{macrocode}
    \itxpersondeffont{%
      \itxpersonfirstfont{\ITX@itxs{#1}{#2}} %
      %\nolinebreak[3] %
      \itxpersonlastfont{\ITX@itxl{#1}{#2}}%
    }%
  \fi%
}%
%    \end{macrocode}
% \end{description}
% \end{macro}
%
% \begin{macro}{\itxf}
%   The syntax is |\itxf{|\meta{type}|}{|\meta{identity}|}|.  A wrapper
%   for |\@itxf|.
%    \begin{macrocode}
\newcommand*{\itxf}[2]{%
  \texorpdfstring{\protect\@itxf{#1}{#2}}{\ITX@itxl{#1}{#2} (#1)}%
}%
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\@itxf}
%   The syntax is |\@itxf{|\meta{type}|}{|\meta{identity}|}|.
%   Typesets the concept referred to by \meta{identity} in its
%   \emph{full form} according to its \meta{type}.
%    \begin{macrocode}
\newcommand*{\@itxf}[2]{%
  \ifcase\number#1%
%    \end{macrocode}
% \begin{description}
% \item[Plain Concept] Typeset margin-notes if applicable, \ldots
%    \begin{macrocode}
    \@itxmarginlabel{#1}{#2}%
%    \end{macrocode}
% \ldots typeset the concept, \ldots
%    \begin{macrocode}
    \itxplaindeffont{\ITX@itxs{#1}{#2}}\nolinebreak %
  \or%
%    \end{macrocode}
% \item[Acronym] Typeset the concept (note in-between margin
%   label), \ldots
%    \begin{macrocode}
    \itxacronymdeffont{%
      \ITX@itxl{#1}{#2} %
      %\nolinebreak[3] %
%    \end{macrocode}
% \ldots typeset margin-notes if applicable, \ldots
%    \begin{macrocode}
      \@itxmarginlabel{#1}{#2}%
%    \end{macrocode}
% \ldots continue typesetting the concept.
%    \begin{macrocode}
      \itxacronymdefshortfont{%
        \itxacronymshortfont{(\ITX@itxs{#1}{#2})}}%
    }%
  \or%
%    \end{macrocode}
% \item[Person] Typeset the concept (note the in-between margin
%   label), \ldots
%    \begin{macrocode}
    \itxpersondeffont{%
      \itxpersonfirstfont{%
        \ITX@itxs{#1}{#2}} %
      %\nolinebreak[3] %
%    \end{macrocode}
% \ldots typeset margin-notes if applicable, \ldots
%    \begin{macrocode}
      \@itxmarginlabel{#1}{#2}%
%    \end{macrocode}
% \ldots continue typesetting the concept.
%    \begin{macrocode}
      \itxpersonlastfont{%
        \ITX@itxl{#1}{#2}%
      }%
    }%
  \fi%
%    \end{macrocode}
% \end{description}
% Now, do the used/unused accounting.
%    \begin{macrocode}
  \expandafter\ifx\csname itx@#2\endcsname\ITX@used%
    %\relax%
  \else%
    \global\expandafter\let\csname itx@#2\endcsname\ITX@used%
    %\ITX@addtoclearlist{#2}% MTR
  \fi%
  %\ITX@logged{#2} MTR
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@itxrecordarea}
%   The syntax is |\@itxrecordarea{|\meta{type}|}{|\meta{identity}|}|.
%   A macro used to update the current used/non-used status of each
%   concept.  This macro only use the \emph{type} and \emph{numeric
%     id} of the concept.
%    \begin{macrocode}
\newcommand*{\@itxrecordarea}[2]{%
%    \end{macrocode}
  % Record this area:
%    \begin{macrocode}
  \edef\curr@pos{\@itxarea{#1}}%
  %\PackageWarning{InTeX}{Current position for type "#1" is "\curr@pos"}%
%    \end{macrocode}
  % Remember the last area where this concept (second argument) was used.
%    \begin{macrocode}
  \edef\last@pos{\csname itx@last@pos#1@#2\endcsname}%
  \ifx\curr@pos\last@pos%
%    \end{macrocode}
    % We're still in the same area.  Hence, we do nothing.
%    \begin{macrocode}
  \else%
%    \end{macrocode}
    % The area has changed.
%    \begin{macrocode}
    \ITX@reset{#2}%
  \fi%
  \expandafter\xdef\csname itx@last@pos#1@#2\endcsname{\curr@pos}%
}%
%    \end{macrocode}
%  \end{macro}
%
% \begin{macro}{\@itx@init@nonbookmode}
%   The syntax is |\@itx@init@nonbookmode|.  This command is responsible
%   for setting up miscellaneous aspects of the package when used in
%   nonbook environments.
%    \begin{macrocode}
\newcommand\@itx@init@nonbookmode{%
  \newcommand*{\@itxtypeset}[3]{% Article-mode.
    \ifx##3A%
      %\PackageWarning{InTeX}{Typesetting format is automatic}%
      \expandafter\ifx\csname itx@##2\endcsname\ITX@used%
%    \end{macrocode}
% The concept was last used in this area.  Hence, it is typeset in its
% short form.
%    \begin{macrocode}
        \itxs{##1}{##2}%
      \else%
%    \end{macrocode}
% The concept has not yet been used, or it was last used in another
% area.  Hence, it is typeset in its full form.
%    \begin{macrocode}
        \itxf{##1}{##2}%
      \fi%
    \else%
%    \end{macrocode}
% Explicit selected typesetting format.
%    \begin{macrocode}
      %\PackageWarning{InTeX}{Typesetting format = "##3"}%
      \ifx##3S\itxs{##1}{##2}\fi%
      \ifx##3L\itxl{##1}{##2}\fi%
      \ifx##3F\itxf{##1}{##2}\fi%
    \fi%
  }%
}%
%    \end{macrocode}
%  \end{macro}
%
% \begin{macro}{\@itx@init@bookmode}
%   The syntax is |\@itx@init@bookmode|.  This command is responsible
%   for setting up miscellaneous aspects of the package when used in
%   book environments.
%    \begin{macrocode}
\newcommand\@itx@init@bookmode{%
  \PackageInfo{InTeX}{Adjusting behavior to suite book/report document
    classes\@gobble}%
  \newcommand*{\@itxtypeset}[3]{% Book/report-mode.
    \ifx##3A%
      %\PackageWarning{InTeX}{Typesetting format is automatic}%
%    \end{macrocode}
% \emph{Automatic} typesetting.
%    \begin{macrocode}
      \if@mainmatter%
        \expandafter\ifx\csname itx@##2\endcsname\ITX@used%
%    \end{macrocode}
% The concept was last used in this area.  Hence, it is typeset in its
% short form.
%    \begin{macrocode}
          \itxs{##1}{##2}%
        \else%
%    \end{macrocode}
% The concept has not yet been used, or it was last used in another
% area.  Hence, it is typeset in its full form.
%    \begin{macrocode}
          \itxf{##1}{##2}%
        \fi%
      \else%
%    \end{macrocode}
% Either in frontmatter or in backmatter.
%    \begin{macrocode}
        \itxl{##1}{##2}%
      \fi%
    \else%
%    \end{macrocode}
% Explicit selected typesetting format.
%    \begin{macrocode}
      %\PackageWarning{InTeX}{Typesetting format = "##3"}%
      \ifx##3S\itxs{##1}{##2}\fi%
      \ifx##3L\itxl{##1}{##2}\fi%
      \ifx##3F\itxf{##1}{##2}\fi%
    \fi%
  }%
}
%    \end{macrocode}
%  \end{macro}
%
% \begin{macro}{\@itxtypeset}
%   The syntax is
%   |\@itxtypeset{|\meta{type}|}{|\meta{identity}|}{|\meta{format
%       code}|}|.  This command is responsible for typesetting the
%   $\left(\meta{type}, \meta{identity}\right)$ tuple.
%
%   If the \meta{identity} was referred to in the frontmatter (part of
%   books and reports), then a different set of rules should dictate
%   the typesetting of the according concept.  Therefore, first find
%   out if the package is used in an article, which does not have any
%   |\if@mainmatter| macro.
%    \begin{macrocode}
\newif\if@itx@bookmode%
\@itx@bookmodetrue%
%    \end{macrocode}
% Adjust the defaults so they make sense when used with the article
% document class.
%    \begin{macrocode}
\@ifclassloaded{article}{%
  \PackageInfo{InTeX}{Adjusting behavior to suite the article document
    class\@gobble}%
  \@itx@init@nonbookmode%
  \@itx@bookmodefalse%
}{}%
%    \end{macrocode}
% Adjust the defaults so they make sense when used with the beamer
% document class.
%    \begin{macrocode}
\@ifclassloaded{beamer}{%
  \PackageInfo{InTeX}{Adjusting behavior to suite the beamer document
    class\@gobble}%
  \@itx@init@nonbookmode%
  \@itx@bookmodefalse%
  \renewcommand*\itxacronymarea{0}%
  \@itx@margin@plainfalse%
  \@itx@margin@acronymfalse%
  \@itx@margin@personfalse%
}{}%
%    \end{macrocode}
% Assume that the current document class is one of the book or report
% classes, or another class with a definition of |\thechapter|.
%    \begin{macrocode}
\if@itx@bookmode%
  \@itx@init@bookmode%
\fi%
%    \end{macrocode}
%  \end{macro}
%
% \begin{macro}{\@itxplain}
%   The syntax is
%   |\@itxplain{|\meta{type}|}{|\meta{identity}|}{|\meta{format
%       code}|}|.  This command is responsible for keeping track of
%   where the $\left(\meta{type}, \meta{identity}\right)$ tuple was
%   last used and for typesetting it accordingly.
%
%   The \meta{format code} can be one of
%   \begin{description}
%   \item[|A|] for \emph{automatic} selection of any of the following,
%     explicit, format codes.
%   \item[|S|] for typesetting the entry in its \emph{short} form.
%   \item[|L|] for typesetting the entry in its \emph{long} form.
%   \item[|F|] for \emph{full-form} typesetting.
%   \end{description}
%    \begin{macrocode}
\newcommand*{\@itxplain}[3]{%
%    \end{macrocode}
%
% First, update the ``last used'' status of the current concept so
% that it refers to the current area.
%    \begin{macrocode}
  \@itxrecordarea{#1}{#2}%
%    \end{macrocode}
% Then, typeset the concept.
%    \begin{macrocode}
  \@itxtypeset{#1}{#2}{#3}%
}%
% \end{macro}
%
% \begin{macro}{\@itxalias}
%   Define the identity of the equivalent entry.  Get the identity of the main
%   index entry for which this is an alias.  Keep the original
%   definition as |\@orig|.  Redefine the main entry (as in
%   |\expandafter\gdef\csname fn@#1\endcsname{{#2}{#2}}|.)  Now,
%   typeset the alias by using the main index entry identity.  Finally,
%   reset the definition of the main entry.  \textbf{|FIXME:|} This
%   command is (probably) not used at the moment (2007-07-14) and is
%   not doing what this paragraph states.
%    \begin{macrocode}
\newcommand*{\@itxalias}[2]{%
  \edef\@mainserial{\expandafter\@firstoftwo#2}%
  \edef\@equivserial{\expandafter\@secondoftwo#2}%
%    \end{macrocode}
% Record usage of the main concept entry.
%    \begin{macrocode}
  %\@itxrecordarea{#1}{\@mainserial}%
  \@itxplain{#1}{\@equivserial}%
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@itx@fakeindex}
%   If no index is to be generated, we still need some output for
%   |mkintex| to work with.  Hence, this command substitutes the
%   |\index| command in the |index| package, and makes sure that an
%   index entry with \emph{page} equal to |\thepage| is written to the
%   auxiliary file instead.  However, the \emph{page} value will then
%   be used only for providing more detailed warnings about references
%   to undefined concepts.
%    \begin{macrocode}
\newcommand{\@itx@fakeindex}[1]{%
  \begingroup%
    \edef\@tempa{%
      \write\@auxout{%
        \string\@writefile{raw}{%
          \string\indexentry{#1}{\thepage}%
        }%
      }%
    }%
  \expandafter\endgroup\@tempa%
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\co}
%
%   The |\co| command is the only command the user should \emph{need}
%   to use.  The syntax is |\co{|\meta{identity}|}[|\meta{format
%     code}|]|, where \meta{identity} refers to a concept and
%   \meta{format code} is an optional argument that can be used to
%   force a particular kind of typesetting.  The idea is that the
%   |\co{}| command should be wrapped around every concept the user
%   want to either typeset or index in a special and consistent way
%   (or both).  Note that |\co| is a wrapper for the |\@itx| command.
%   Please see the definition of |\@itxplain| for a description of the
%   available format codes.  The default \meta{format code} is |A|.
%    \begin{macrocode}
%\newcommand*{\co}{\protect\@itx}%
\newcommand{\co}{\@itx}%
\newcommand{\coS}[1]{\@itx[S]{#1}}%
\newcommand{\coL}[1]{\@itx[L]{#1}}%
\newcommand{\coF}[1]{\@itx[F]{#1}}%
%\DeclareRobustCommand*{\co}{\protect\@itx}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@itx}
%   The |\@itx| command works just as described for |\co| above.
%   Hence, |#1| is the \meta{format code}, and |#2| is the
%   \meta{identity}.
%    \begin{macrocode}
%\newcommand*{\@itx}[2][A]{%
\DeclareRobustCommand*{\@itx}[2][A]{%
  \def\@tempa{#2}%
%    \end{macrocode}
% Handle, e.g., backslashes.
%    \begin{macrocode}
  \edef\@tempb{\@nearverbatim\@tempa}%
%    \end{macrocode}
%
% If \InTeX\ should generate an index, simply use the |index| package
% to write the identifying index entry.  The intricacies of how this
% concept should be indexed is handled externally by the |mkintex|
% program that is part of the \InTeX\ package.
%
%    \begin{macrocode}
  \if@itx@index%
    \index[raw]{#2}%
  \else%
    \@itx@fakeindex{\@tempb}%
  \fi%
%    \end{macrocode}
%
% Define a new conditional, |found|, to signal whether the
% \meta{identity} is found.
%    \begin{macrocode}
  \newif\iffound%
%    \end{macrocode}
%
% Now, let the |co@type| counter loop through the values $\left[0, 1,
%   2\right]$.
%    \begin{macrocode}
  \setcounter{co@type}{0}%
  \loop\ifnum\theco@type<3%
%    \end{macrocode}
% Check to see if the \meta{identity} is an (acronym or person)
% \emph{alias} or a \emph{main} entry.  If it is an \emph{alias},
% there exists a variable named |fn|$n$|e@|\meta{identity} (note the
% extra `|e|').  However, if \meta{identity} refers to a \emph{main}
% entry, a variable named |fn|$n$|@|\meta{identity} exists; that is,
% without the `|e|' before the `|@|'.  Also, it should be noted that
% \emph{no alias can exists without a main entry with the same
%   \meta{identity}}.
% 
% If an expansion of \meta{identity} is found, typeset it accordingly
% and flag the finding by setting |\iffound|.
%    \begin{macrocode}
    \expandafter\ifx\csname fn\number\theco@type e@\@tempb\endcsname\relax%
      \expandafter\ifx\csname fn\number\theco@type @\@tempb\endcsname\relax%
%    \end{macrocode}
% The \meta{identity} may refer to both a main entry \emph{and} an
% alias entry (because of the requirement mentioned above).  Do
% nothing.  The reason the code is written in this way is to implement
% a preference to main entries over alias entries (see the order
% below).
%    \begin{macrocode}
        % \PackageWarning{InTeX}{Main AND alias reference `#2' occurred}%
        % The reference refers to both main _and_ alias entries.  Do
        % nothing, this will be resolved through the |else|-cases
        % immediately below.
      \else%
%    \end{macrocode}
% The \meta{identity} refers to a main-entry.
%    \begin{macrocode}
        %\PackageInfo{InTeX}{Main reference `#2' occurred}%
        \edef\co@id{\csname fn\number\theco@type @\@tempb\endcsname}%
        \@itxplain{\number\theco@type}{\co@id}{#1}%
        \foundtrue%
      \fi%
%   \else%
%    \end{macrocode}
% The \meta{identity} refers to an alias-entry.
%    \begin{macrocode}
%      \PackageWarning{InTeX}{Alias reference `#2' occurred}%
%      %  XXX: It seems that this case never occurrs.
%      \edef\co@id{\csname fn\number\theco@type e@\@tempb\endcsname}%
%      \@itxalias{\number\theco@type}{\co@id}%
%      \foundtrue%
    \fi%
%    \end{macrocode}
% Increase |co@type| by $1$ and perform a new iteration of the loop.
% In other words, check if the reference (\meta{identity}) is referring to
% another kind of entry.
%    \begin{macrocode}
    \stepcounter{co@type}%
  \repeat%
%    \end{macrocode}
% If no expansion of \meta{identity} could be found, warn the user.
% Furthermore, an in-document warning will be typeset if
% |@itx@warn@undef| is \emph{true}.
%    \begin{macrocode}
  \iffound%
% Do nothing.
  \else%
    \PackageWarning{InTeX}{Reference `#2' to undefined concept}%
    \if@itx@warn@undef%
      \textbf{\itxundefcomment{#2}}%
    \else%
      #2%
    \fi%
  \fi%
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\personused}
%    \begin{macrocode}
\newcommand*{\personused}[1]{%
  \expandafter\ifx\csname pnused@#1\endcsname\PN@used%
    \relax%
  \else%
    \global\expandafter\let\csname pnused@#1\endcsname\PN@used%
    \global\let\PN@populated\PN@used%
  \fi%
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@itxdefineforms}
%    \begin{macrocode}
\newcommand\@itxdefineforms[3]{%
  \expandafter\gdef\csname fnss@\number#1\endcsname{#2}%
  \expandafter\gdef\csname fnsl@\number#1\endcsname{#3}%
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@newentry}
% The macros |\new|\meta{type}, where
% \meta{type} $\in \{|acronym|, |concept|, |person|\}$ (as described
% below), all call |\@newentry| with an additional first argument,
% namely the numeric \meta{type} identifier of the new entry.  The
% syntax is
% \begin{displaymath}
%   |\@newentry{|\meta{type}|}{|\meta{reference}|}{|\meta{typeset 1}|}{|\meta{typeset 2}|}|,
% \end{displaymath}
% where \meta{reference} is the string later refered to as
% |\co{|\meta{string}|}|, and \meta{typeset 1} and \meta{typeset 2}
% define how the concept will be typeset where it was refered to in
% the text.  The exact meaning of \meta{typeset 1} and \meta{typeset
%   2} depends on what \meta{type} this entry has.
%    \begin{macrocode}
\newcommand\@newentry[4]{%
  \def\@tempa{#2}%
  \edef\@tempb{\@nearverbatim\@tempa}%
  %
  \stepcounter{co@serial}%
  %\PackageWarning{init}{serial counter = \expandafter\theco@serial}%
  \expandafter\xdef\csname fn\number#1@\@tempb\endcsname{%
    \number\theco@serial}%
  %\PackageWarning{init}{Def: \meaning\csname fn\number#1@\@tempb\endcsname}%
  \@itxdefineforms{\theco@serial}{#3}{#4}%
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\newconcept}
%    \begin{macrocode}
\newcommand*\newconcept[3]{%
  \@newentry{0}{#1}{#2}{#3}%
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\newacronym}
%    \begin{macrocode}
\newcommand*\newacronym[3]{%
  \@newentry{1}{#1}{#2}{#3}%
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\newperson}
%   The syntax is
% \begin{displaymath}
%   |\newperson{|\meta{reference}|}{|\meta{short-form typeset}|}{|\meta{full-form typeset}|}|.
% \end{displaymath}
%    \begin{macrocode}
\newcommand*\newperson[3]{%
  \@newentry{2}{#1}{#2}{#3}%
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@newentryequiv}
%   The syntax for this command is
%   \begin{displaymath}
%     |\@newentryequiv{|\meta{type}|}{|\meta{parent}|}{|\meta{typeset}|}{|\meta{reference}|}{|\meta{full-form typeset}|}|,
%   \end{displaymath}
%   where \meta{type} $\in \{|acronym|, |concept|, |person|\}$,
%   \meta{parent} is the (reference) identity of the concept for which
%   this is an equivalent, \meta{typeset} defines how this equivalent
%   should be typeset in text (short-form if it is an acronym),
%   \meta{reference} is the identity of this entry (referred to as
%   |\co{|\meta{reference}|}|), and \meta{full-form typeset} defines
%   how this concept should be typeset in the text in its full-form.
%
%   Note that the macros |\new|\meta{type}|equiv|, where \meta{type}
%   $\in \{|acronym|, |concept|, |person|\}$, all are wrappers for
%   this command.
%    \begin{macrocode}
\newcommand*\@newentryequiv[5]{%
  \newif\iffound%
  \def\@tempa{#2}%
  \edef\@tempb{\@nearverbatim\@tempa}%
  \expandafter\ifx\csname fn\number#1 @\@tempb\endcsname\relax%
%    \end{macrocode}
% Nothing is done if |\csname fn\number#1 @\@tempb\endcsname| is not
% defined here, but notice that the default value of |found| is
% \emph{false}.
%    \begin{macrocode}
  \else%
    \foundtrue%
    \edef\co@id{\csname fn\number#1@\@tempb\endcsname}%
    %\PackageWarning{init}{Found `\@tempb' (type=\number#1, serial=\co@id)}%
%    \end{macrocode}
% Store the \emph{short} and the \emph{long}
% versions of the alias, in that order.
%    \begin{macrocode}
    \stepcounter{co@serial}%
    \@itxdefineforms{\theco@serial}{#3}{#5}%
%    \end{macrocode}
% Store the numeric identity of the concept alias.
%    \begin{macrocode}
    \def\@tempa{#4}%
    \edef\@tempb{\@nearverbatim\@tempa}%
    \expandafter\xdef\csname fn\number#1 e@\@tempb\endcsname{%
      {\co@id}{\theco@serial}}%
  \fi%
  \iffound%
  \else%
    %\PackageWarning{InTeX}{Can't find `#2' for sub-concept `#3'}%
  \fi%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\newconceptequiv}
% \begin{macro}{\newacronymequiv}
% \begin{macro}{\newpersonequiv}
%   Wrappers for the |\@newentryequiv| command, where each wrapper
%   specifies the entry's \meta{type} through the first argument to
%   |\@newentryequiv|.
%    \begin{macrocode}
\newcommand*\newconceptequiv[4]{%
  \@newentryequiv{0}{#1}{#2}{#3}{#4}%
}%
\newcommand*\newacronymequiv[4]{%
  \@newentryequiv{1}{#1}{#2}{#3}{#4}%
}%
\newcommand*\newpersonequiv[4]{%
  \@newentryequiv{2}{#1}{#2}{#3}{#4}%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsection{The Internal \InTeX\ File}
% \begin{macro}{\InTeX}
%   After the first run of {Make\InTeX}, the file |\jobname.ito| will
%   contain the different concept definitions.  The |.ito| file is
%   loaded at the beginning of the document.
%    \begin{macrocode}
\AtBeginDocument{\@input{\jobname.ito}}%
%    \end{macrocode}
% \end{macro}
%
% \printindex[raw]
% \Finale
\endinput%