summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/cstex/opmac-u-en.tex
blob: 9381cf07751683f7f3874ba9d2ded4cb408cd99e (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

\input opmac

\def\toasciidata{}\def\r{}

\typosize[11/13]

%\def\thefnote{$^{\locfnum}$}
\addto\footstrut{\hang}

\catcode`<=13
\def<#1>{\hbox{$\langle$\it#1\/$\rangle$}}

\activettchar"

\hyperlinks{\Blue}{\Green}
\insertoutline{CONTENTS} \outlines{0} 


\tit OPmac -- macros for plain\TeX\fnotemark1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
\centerline{\it Petr Ol\v s\'ak, 2012 -- 2019}

\bigskip
\centerline{\url{http://petr.olsak.net/opmac-e.html}}


\fnotetext {This text is second revised version. The first version was
 published in TUGboat 34:1, 2013, pp.~88--96}

\notoc\nonum \sec Contents
\maketoc

\nonum \sec Introduction
%%%%%%%%%%%%

The OPmac package is a set of simple additional macros to plain\TeX{}. It
enables users to take advantage of basic \LaTeX{} functionality: font size
selection, the automatic creation of a table of contents and an index, working
with bibliography databases, tables, references with optional hyperlinks, margin
settings, etc. 

I had been using these macros personally for a long time, but now, after
cleaning up the code a bit and providing both user and technical documentation,
I'm releasing them to the general public along with the new version of
\csplain{}.

My main motivation in publishing OPmac is to provide a set of macros with
solutions to common tasks for plain\TeX{} users. Additionally, I wanted to
demonstrate that it is possible to write \TeX{} code in a simple and effective
style, something that most \LaTeX{} macro packages lack. All of OPmac's macros
are contained within the single file "opmac.tex" in only 1,700
lines. By comparison, the \LaTeX{} code which solves comparable tasks is placed
inside its ``kernel'' along with many \LaTeX{} packages all of which contain
tens of thousands of lines.

The main principles which I followed when creating this macro package, are:

\begitems
  * Simplicity is power.
  * Macros are not universal, but are readable and understandable.
  * User can easily redefine these macros as he/she wishes. 
\enditems

Each part of the macro code is written in order to maximize readability for
human who will want to read it, understand it and change it. 

OPmac package offers a markup language for authors of texts (like \LaTeX),
i.e. the fixed set of tags to define the structure of the document. This
markup is different from the \LaTeX{} markup. It may offer to write the
source text of the document somewhat clearer and more attractive. The OPmac
package, however, does not care for the typography of the document. The simple
sober document is created if no additional macros are used. We assume that
the author of additional macros is able to create a look of the document to
suit specific requirement.

OPmac has a small number of additional packages: "fontfam", "pdfuni",
"opmac-xetex" and "opmac-bib" (see the end of
\url{http://petr.olsak.net/opmac-e.html} page). Moreover, there exist many
tens of little OPmac tricks comparable with \LaTeX{} packages mentioned on
\url{http://petr.olsak.net/opmac-tricks-e.html} page.

\secnum=-1

\sec Using OPmac
%%%%%%%%%%%%%%%%

OPmac is not compiled as a format. For using it in plain\TeX{}, you can simply
"\input opmac" at the beginning of your document. The example of the simple
document follows:

\begtt
\input opmac
\typosize[11/13]   % setting the basic font size and the baselineskip
\margins/1 a4 (1,1,1,1)in   % setting 1in margins for A4 paper

Here is a text.
\bye
\endtt

You can use \TeX, pdf\TeX, Xe\TeX{} or lua\TeX{} with plain \TeX{} format 
(classical "plain.tex", "etex.src" or \csplain{}).
The \csplain{} is recommended but it is not explicitly requested if you
don't need to use Czech/Slovak specific features\fnote
{Warnings: ``falling back to ASCII sorting''
or ``CZ/SK outline-conversion is off'' may occur without \csplain{}.}.


\sec Selection of font family
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

OPmac doesn't select a special default font family. The default is the same as in
plain \TeX{} (CM fonts) or \CS{}plain (CS fonts). It is possible to "\input"
so called ``font-files'' for loading a font family, i.\,e.\ typically four
variants of fonts "\rm", "\bf", "\it" and "\bi". The font-files use
primitive command "\font" for loading individual fonts.

You need not to remember names: use
"\fontfam[<FamilyName>]" macro which loads the appropriate font-file. The
argument "<FamilyName>" is case insensitive and spaces are ignored. So,
"\fontfam[Times Roman]" is equal to "\fontfam[TimesRoman]" and it is equal
to "\fontfam[timesroman]". Several aliases are prepared, thus
"\fontfam[times]" can be used for loading Times Roman family too.

If you write "\fontfam[?]" then all available font families are listed on
the terminal and in the log file. The listing looks like:

\begtt
[LM Fonts]  {\caps \sans \ttset ...} {\rm \bf \it \bi } +AMS (8z 8t u)
[TG Heros]  {\caps \cond} {\rm \bf \it \bi } +TX (8z 8t)
 ...
\endtt

The "<FamilyName>" is followed by the list of {\em modifiers} of basic
variant selectors, then available basic variant selectors are listed. After
plus character, the default set of math fonts used together with given
family is named. The available font encodings are written in round brackets.
More information about "\fontfam" macro can be found in the "fontfam.tex"
file.

The varinats are selected by basic selectors ("\rm", "\bf", "\it", "\bi").
The modifiers of basic variants ("\caps", "\cond" for example) can
be used immediately before a basic variant selector and they
can be (independently) combined: "\caps\it" or "\cond\caps\bf". The
modifiers can be followed by "\fam" command (instead of basic variant
selector). Then current variant is kept (but modified) and all consecutive
basic variant selectors (in a group) are modified too. 
If modifiers are followed by "\one" sequence (instead variant selector) 
then only current variant is modified. More about font modifers are
mentioned in the "cs-heros.tex" file and in the article "kpfonts-plain.pdf".

The "\fontfam[Catalog]" prints a font catalogue of all configured font
families.


\sec Font sizes
%%%%%%%%%%%%%%%

The commands for font size setting described below, for variant selectors and
modifiers desribed above have local validity. If you put them into a group, 
the font features are selected locally.

The command "\typosize[<fontsize>/<baselineskip>]" sets the font size of text and
math fonts and baselineskip. If one of these two parameters is empty, the
corresponding feature stays unchanged. The metric unit is supposed "pt" and
this unit isn't written in parameters. You can change the unit by the
command "\ptunit=<something-else>", for instance "\ptunit=1mm".
Examples:

\begtt
\typosize[10/12]   % default of plainTeX
\typosize[11/12.5] % font 11pt, baseline 12.5pt
\typosize[8/]      % font 8pt, baseline unchanged
\endtt

The command
"\typoscale[<font-factor>/<baselineskip-factor>]"
sets the text and math fonts
size and baselineskip as a multiple of the current fonts size and
baselineskip. The factor is written in "scaled"-like way, it means that 1000
means factor one. The empty parameter is equal to the parameter 1000,
i.e. the value stays unchanged. Examples:

\begtt
\typoscale[800/800]    % fonts and baselineskip re-size to 80 %
\typoscale[\magstep2/] % fonts bigger 1,44times
\endtt

The sizes declared by these macros (for example in titles) are relative to the
basic size selected for the current font (this may be arbitrary size, not only
10pt).

There are times however, when one would like to make a font change relative to
the documents ``base'' font size instead of the current font (e.g. when
typesetting footnotes). The macro "\typobase" provides an easy way to perform
such changes. The ``base'' font size is set with the first use of either
"\typosize" or "\typoscale" and this size is restored by "\typobase". Example:

\begtt
\typosize[12/14]    % if first use of \typosize, then this sets the "base"
...
{\typoscale[16/18]  % bigger size (for example title font)
 ...
 \typobase\typoscale[750/750] % reduced to 75% of [12/14] (i.e. [9/10.5])
 ...           % this is caculated from "base", no from actual title font
}
\endtt

The size of the current font can be changed by the command
"\thefontsize[<font-size>]" or can be rescaled by
"\thefontscale[<factor>]". These macros don't change math fonts sizes nor
baselineskip.

The "\resizefont", "\regfont" and "\resizeall" commands (documented in
\csplain) can be used even if
the used format is not \csplain. The best
design size of the font for desired size is selected. 
For example "\typosize[18/]" selects the font "cmr17 at 18pt".

The "\em" macro acts as "\it" if the current font is "\rm", acts as "\rm" if
the current font is "\it", acts as "\bi" if the current font is "\bf" and
acts as "\bf" if the current font is "\bi". The "\/" spaces are inserted
automatically. Example:

\begtt
This is {\em important} text.     % = This is {\it important\/} text.
\it This is {\em important} text. % = This is\/ {\rm important} text.
\bf This is {\em important} text. % = This is {\bi important\/} text.
\bi This is {\em important} text. % = This is\/ {\bf important} text.
\endtt


\sec Parts of the document
%%%%%%%%%%%%%%%%%%%%%%%%%%

The document can be divided into chapters, sections and subsections and titled
by "\tit" command. The parameters are separed by the end of current line (no
braces are used):

\begtt
\tit Document title <end of line>
\chap Chapter title <end of line>
\sec Section title <end of line>
\secc Subsection title <end of line>
\endtt

The chapters are numbered by one number, sections by two numbers
(chapter.section) and subsections by three numbers. If there are no chapters
then section have only one number and subsection two.

The implicit design of the titles of chapter etc.\ are implemented in the
macros "\printchap", "\printsec" and "\printsecc". User can simply change
these macros if he/she needs another behavior.

The first paragraph after the title of chapter, section and subsection is
not indented but you can type "\let\firstnoindent=\relax" if you need all
paragraphs indented.

If a title is so long then it breaks to more lines. It is better to hint the
breakpoints because \TeX{} does not interpret the meaning of the title.
User can put the "\nl" (it means newline) macro to the breakpoints.

The chapter, section or subsection isn't numbered if the "\nonum" precedes.
And the chapter, section or subsection isn't delivered to the table of
contents if "\notoc" precedes.


\sec Another numbered objects
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Apart from chapters, sections and subsections, there are another
automatically numbered objects: equations and captions for tables and
figures.

If user write the "\eqmark" as the last element of the display mode then
this equation is numbered. The format is one number in brackets. This number
is reset in each section. 

If the "\eqalignno" is used, then user can put "\eqmark" to the last column
before "\cr". For example:

\begtt
\eqalignno{
    a^2+b^2 &= c^2 \cr
          c &= \sqrt{a^2+b^2} & \eqmark \cr}
\endtt

The next numbered object is caption which is tagged by "\caption/t" for
tables and "\caption/f" for figures. Example:

\begtt
\hfil\table{rl}{
    age   & value \crl\noalign{\smallskip}
    0--1  & unmeasured \cr 
    1--6  & observable \cr
    6--12 & significant \cr
   12--20 & extremal \cr
   20--40 & normal \cr
   40--60 & various \cr
   60--$\infty$ & moderate}
\par\nobreak\medskip
\caption/t The dependency of the computer-dependency on the age.
\endtt

This example produces:

\bigskip
{\def\addto#1#2{\expandafter\def\expandafter#1\expandafter{#1#2}}
\hfil\table{rl}{age   & value \crl\noalign{\smallskip}
                0--1  & unmeasured \cr 
                1--6  & observable \cr
                6--12 & significant \cr
               12--20 & extremal \cr
               20--40 & normal \cr
               40--60 & various \cr
               60--$\infty$ & moderate}
\par\nobreak\medskip
{      \leftskip=\parindent plus1fil
      \rightskip=\parindent plus-1fil
      \parfillskip=0pt plus2fil \noindent
{\bf Table 2.3} The dependency of the com\-puter-dependency on the age.\par}
}
\bigskip

The word ``Table'' followed by a number is added by the macro 
"\caption/t". The macro "\caption/f" creates the word figure.
The caption text is centered. If it occupies more lines then the 
last line is centered.

The added word (table, figure) depends on the actual number of the
"\language" register. OPmac implements the mapping from "\language"
numbers to the languages and the mapping from languages to the generated
words.

If you wish to make the table or figure as floating object, you need to use
plain\TeX{} macros "\midinsert", "\topinsert" and "\endinsert".

Each automatically numbered object can be referenced, if the 
"\label[<label>]" command precedes. The reference commands are 
"\ref[<label>]" and "\pgref[<label>]". Example:

\begtt
\label[beatle] \sec About Beatles

\label[comp-dependence]
\hfil\table{rl}{...} % the table
\caption/t The dependency of the computer-dependency on the age.

\label[pythagoras]
$$ a^2 + b^2 = c^2 \eqmark $$

Now we can point to the section~\ref[beatle] on the page~\pgref[beatle] 
or write about the equation~\ref[pythagoras]. Finally there 
is an interesting Table~\ref[comp-dependence].
\endtt

If there are forward referenced objects then user have to run \TeX{} twice.
During each pass, the working "*.ref" file (with refereces data) is created
and this file is used (if it exists) at the begin of the document.

You can create a reference to whatever else by commands
"\label[<label>]\wlabel{<text>}". The connection between "<label>" and
"<text>" is established. The "\ref[<label>]" will print "<text>".


\sec Lists 
%%%%%%%%%%

The list of items is surrounded by "\begitems" and "\enditems" commands.
The asterisk ("*") is active within this environment and it starts one item.
The item style can be chosen by "\style" parameter written after "\begitems":

\begtt
\style o % small bullet
\style O % big bullet (default)
\style - % hyphen char
\style n % numbered items 1., 2., 3., ...
\style N % numbered items 1), 2), 3), ...
\style i % numbered items (i), (ii), (iii), ...
\style I % numbered items I, II, III, IV, ...
\style a % items of type a), b), c), ...
\style A % items of type A), B), C), ...
\style x % small rectangle
\style X % big rectangle
\endtt

Another style can be defined by the command "\sdef{item:<style>}{<text>}".
Default item can be redefined by "\def\normalitem{<text>}".
The list environments can be nested. Each new level of item is indented by
next multiple of "\iindent" which is set to "\parindent" by default.
The vertical space at begin and end of the environment is inserted by the
macro "\iiskip".


\sec Table of contents
%%%%%%%%%%%%%%%%%%%%%%

The "\maketoc" command prints the table of contents of all "\chap", "\sec"
and "\secc" used in the document. These data are read from external "*.ref" file, so
you have to run \TeX{} more than once (typically three times if the table of
contents is at the beginning of the document). 

The name of the section with table of contents is not printed. The direct usage
of "\chap" or "\sec" isn't recommended here because the table of contents 
is typically not referenced to itself. You can print the unnumbered and unreferenced
title of the section by the code:

\begtt
\nonum\notoc\sec Table of Contents
\endtt

The title of chapters etc.\ are written into the external file and they are
read from this file in a next run of \TeX. This technique can induce some
problems when a somewhat complicated macro is used in the title. OPmac
solves this problem by different way than \LaTeX. User can set the
problematic macro as ``robust'' by "\addprotect\macro" declaration. The
"\macro" itself cannot be redefined. The common macros used in OPmac which
can be occur in the titles are declared by this way. For example:

\begtt
\addprotect~ \addprotect\TeX \addprotect\thefontsize \addprotect\em
\endtt


\sec Making the index 
%%%%%%%%%%%%%%%%%%%%%

The index can be included into document by "\makeindex" macro. No external
program is needed, the alphabetical sorting are done inside \TeX{} at macro
level.

The "\ii" command (insert to index) declares the word separated by the space
as the index item. This declaration is represented as invisible atom on the
page connected to the next visible word. The page number of the page where
this atom occurs is listed in the index entry. So you can type:

\begtt
The \ii resistor resistor is a passive electrical component ...
\endtt

You cannot double the word if you use the "\iid" instead "\ii":

\begtt
The \iid resistor is a passive electrical component ...
or:
Now we'll deal with the \iid resistor .
\endtt

Note that the dot or comma have to be separated by space when "\iid" is
used. This space (before dot or comma) is removed by the macro in 
the current text.

The multiple-words entries are commonly organized in the index by the format
(for example): 

\medskip

linear~dependency  11, 40--50

--- independency 12, 42--53

--- space 57, 76

--- subspace 58

\medskip

To do this you have to declare the parts of the words by the "/" separator.
Example:

\begtt
{\bf Definition.}
\ii linear/space,vector/space
{\em Linear space} (or {\em vector space}) is a nonempty set of...
\endtt

The number of the parts of one index entry is unlimited. Note, that you can
spare your typing by the comma in the "\ii" parameter. The previous example
is equivalent to "\ii linear/space" "\ii vector/space".

Maybe you need to propagate to the index the similar entry to the
linear/space in the form space/linear. You can do this by the shorthand ",@"
at the end of the "\ii" parameter. Example:

\begtt
\ii linear/space,vector/space,@
is equivalent to:
\ii linear/space,vector/space \ii space/linear,space/vector
\endtt

If you really need to insert the space into the index entry, write ``"~"''.

The "\makeindex" creates the list of alphabetically sorted index entries
without the title of the section and without creating more columns. OPmac
provides another macros for more columns: 

\begtt
\begmulti <number of columns>
<text>
\endmulti
\endtt

The columns will be balanced. The Index can be printed by the following
code:

\begtt
\sec Index\par
\begmulti 3 \makeindex \endmulti
\endtt

Only ``pure words'' can be propagated to the index by the "\ii" command. It
means that there cannot be any macro, \TeX{} primitive, math selector etc.
But there is another possibility to create such complex index entry. Use
``pure equivalent'' in the "\ii" parameter and map this equivalent to the
real word which is printed in the index by "\iis" command. Example:

\begtt
The \ii chiquadrat $\chi$-quadrat method is 
...
If the \ii relax "\relax" command is used then \TeX\ is relaxing.
...
\iis chiquadrat {$\chi$-quadrat}
\iis relax {{\tt \char`\\relax}}
...
\endtt

The "\iis <equivalent> {<text>}" creates one entry in the ``dictionary 
of the exceptions''. The sorting is done by the "<equivalent>" but the
"<text>" is printed in the index entry list.

The special sorting by the Czech or Slovak standard of alphabetical sorting
is activated if \csplain{} is used and if "\language" register is set to the
Czech or Slovak hyphenation patterns when "\makeindex" is in progress. The
main difference from English sorting is that ``ch'' is treated as one
character between h and i.


\sec Colors
%%%%%%%%%%%

The colors selection macros are working only if pdf\TeX-like engine (or
Xe\TeX) is used.
OPmac provides a small number of color selectors: 
{\localcolor\Blue "\Blue"}, 
{\localcolor\Red "\Red"}, 
{\localcolor\Brown "\Brown"},
{\localcolor\Green "\Green"}, 
{\localcolor\Yellow "\Yellow"}, 
{\localcolor\Cyan "\Cyan"}, 
{\localcolor\Magenta "\Magenta"}, 
{"\White"}, 
{\localcolor\Grey "\Grey"}, 
{\localcolor\LightGrey "\LightGrey"} and
"\Black". User can define more
such selectors by setting the CMYK components. For example

\begtt
\def\Orange{\setcmykcolor{0 0.5 1 0}}
\endtt

The current color in CMYK format is saved in the "\currentcolor" macro, thus you
can save it to your macro "\let\yourmacro=\currentcolor" and you can return to
this color by "\setcmykcolor\yourmacro".

The color selectors work globally by default. It means that colors don't
respect the \TeX{} groups and you have to return back to the black
typesetting explicitly by the "\Black" selector. 

OPmac provides the macro "\localcolor". If it is used then the
colors return back to the original value after \TeX{} groups automatically.
The macro has local validity. You can use it at begin of your document 
(for all \TeX{} broups) or only in selected \TeX{} group (for this group 
and nested goups). Example:

\begtt
\Red The text is red
{\localcolor \Blue here is blue {\Green and green} 
             restored blue \Brown and brown}
now the text is red.
\endtt

\def\coloron#1#2#3{%
   \setbox0=\hbox{#3}\leavevmode
   {\localcolor\rlap{#1\strut \vrule width\wd0}#2\box0}%
}
The more usable example follows. It defines a macro which creates the
\coloron\Yellow\Brown{colored text on the} 
\coloron\Yellow\Brown{colored background}. Usage:
"\coloron<background><foreground>{<text>}"

The "\coloron" can be defined as follows:

\begtt
\def\coloron#1#2#3{%
   \setbox0=\hbox{#3}\leavevmode
   {\localcolor\rlap{#1\strut \vrule width\wd0}#2\box0}%
}
\coloron\Yellow\Brown{The brown text on the yellow backround}
\endtt

{\bf The watermark} is grey text on the backrounf of the page. OPmac offers
an example: the macro "\draft" which creates grey scaled and rotated text
DRAFT on the background of every page.


\sec Hyperlinks, outlines
%%%%%%%%%%%%%%%%%%%%%%%%%

If the command "\hyperlinks{<color-in>}{<color-out>}" is used at the beginning of
the file, then the following objects are hyperlinked when PDF output is used:

\begitems
* numbers generated by "\ref" or "\pgref",
* numbers of chapters, sections and subsections in the table of contents,
* numbers or marks generated by "\cite" command (bibliography references),
* texts printed by "\url" command.
\enditems

The last object is an external link and it is colored by
"<color-out>". Others links are internal and they are colored by
"<color-in>". Example:

\begtt
\hyperlinks \Blue \Green % internal links blue, URLs green.
\endtt

You can use another marking of active links: by frames which are visible in
the PDF viewer but invisible when the document is printed. The way to do it
is to define the macros "\pgborder", "\tocborder", "\citeborder",
"\refborder" and "\urlborder" as the triple of RGB components of the used
color. Example:

\begtt
\def\tocborder {1 0 0}  % links in table of contents: red frame
\def\pgborder {0 1 0}   % links to pages: green frame
\def\citeborder {0 0 1} % links to references: blue frame
\endtt

By default these macros are not defined. It means that no frames are created.

There are ``low level'' commands to create the links. You can specify the
destination of the internal link by "\dest[<type>:<label>]". The
active text linked to the "\dest" can be created by
"\link[<type>:<label>]{<color>}{<text>}". The "<type>" parameter is one of
the "toc", "pg", "cite", "ref" or another special for your purpose. 

The "\url" macro prints its parameter in "\tt" font and creates a potential
breakpoints in it (after slash or dot, for example). If "\hyperlinks"
declaration is used then the parameter of "\url" is treated as an external URL link.
An example: "\url{http://www.olsak.net}" creates \url{http://www.olsak.net}.
The charecters {\tt\%}, "\", "#", "$", "{" and "}" have to be protected by %$
backslash in the "\url" argument, the other special charecters "~", "_",
"^", "&" can be written as single character. You can insert the "\|" command 
in the "\url" argument as a potential breakpoint.

If the linked text have to be different than the URL, you can use
"\ulink[<url>]{text}" macro. For example:

\begtt
\ulink[http://petr.olsak.net/opmac-e.html]{OPmac page}
\endtt
creates
\ulink[http://petr.olsak.net/opmac-e.html]{OPmac page}.

The PDF format provides ``outlines'' which are notes placed in the special frame of
the PDF viewer. These notes can be managed as structured and hyperlinked
table of contents of the document. The command "\outlines{<level>}" creates
such outlines from data used for table of contents in the document. The
"<level>" parameter gives the level of opened sub-outlines
in the default view. The deeper levels can be open by mouse click on the
triangle symbol after that.\looseness=-1

The strings used in PDF outlines are converted if \csplain{} is used: the
accents are stripped off because they can make problems in outlines. But
user can use "\input pdfuni" in order to convert these strings to internal
UNICODE representation.

The command "\insertoutline{<text>}" inserts next entry into PDF outlines at
the main level~0. This entry can be placed before table of contents (created
by "\outlines") or after it.


\sec Verbatim
%%%%%%%%%%%%%

The display verbatim text have to be surrounded by the "\begtt" and
"\endtt" couple. 
The inline verbatim have to be tagged (before and after) 
by a character which is declared by
"\activettchar<char>". For example "\activettchar"{\tt\char`"} 
declares the
{\tt\char`"} for inline verbatim markup. 

If the numerical register "\ttline" is set to the non-negative value then
display verbatim will number the lines. The first line has the number
"\ttline+1" and when the verbatim ends then the "\ttline" value is equal to the
number of last line printed. Next "\begtt...\endtt" environment will follow
the line numbering. OPmac sets "\ttline=-1" by default.

The indentation of each line in display verbatim is controlled by
"\ttindent" register. This register is set to the "\parindent" when
"opmac.tex" is read. User have to change its value if the "\parindent" is
changed after reading of "opmac.tex".

The "\begtt" starts internal group in which the catcodes are changed. Then
the "\tthook" macro is run. This macro is empty by default and user can
control fine behavior by it. For example the cactodes can be reset here. If
you need to define active character in the "\tthook", use "\adef" as in the
following example:

{\def\tthook{\adef@{\string\endtt}}
\begtt
\def\tthook{\adef!{?}\adef?{!}}
\begtt
Each occurrence of the exclamation mark will be changed to 
the question mark and vice versa. Really? You can try it! 
@
\endtt
}

The "\adef" command sets its parameter as active {\it after\/}
the body of "\tthook" is read. So you can't worry about active
categories. 

There are tips for global "\tthook" definitions here:

\begtt
\def\tthook{\typosize[9/11]}     % setting font size for verbatim
\def\tthook{\ttline=0}           % each listing will be numbered from one
\def\tthook{\adef{ }{\char`\ }}  % visualisation of spaces
\endtt

You can print verbatim listing from external files by "\verbinput" command. 
Examples:

\begtt
\verbinput (12-42) program.c  % listing from program.c, only lines 12-42
\verbinput (-60) program.c    % print from begin to the line 60
\verbinput (61-) program.c    % from line 61 to the end
\verbinput (-) program.c      % whole file is printed
\verbinput (70+10) program.c  % from line 70, only 10 lines printed
\verbinput (+10) program.c    % from the last line read, print 10 lines 
\vebrinput (-5+7) program.c   % from the last line read, skip 5, print 7
\verbinput (+) program.c      % from the last line read to the end
\endtt


The "\ttline" influences the line numbering by the same way as in
"\begtt...\endtt" environment. If "\ttline=-1" then real line numbers are
printed (this is default). If "\ttline"{\tt\char`\<-1} then no line 
numbers are printed. 

The "\verbinput" can be controlled by "\tthook", "\ttindent" just like
in "\begtt...\endtt".


\sec Tables
%%%%%%%%%%%

The macro "\table{<declaration>}{<data>}" provides similar "<declaration>"
as in \LaTeX: you can use letters "l", "r", "c", each letter declares 
one column (aligned to left, right, center respectively). 
These letters can be combined by the ``{\tt\char`\|}'' character 
(vertical line). Example

\begtt
\table{||lc|r||}{                  \crl
   Month    & commodity & price    \crli \tskip.2em
   January  & notebook   & \$ 700  \cr
   February & skateboard & \$ 100  \cr
   July     & yacht      & k\$ 170 \crl}
\endtt
%
generates the following result:

\bigskip
\hfil\table{||lc|r||}{               \crl
   Month    & commodity & price \crli 
                                     \tskip.2em
   January  & notebook   &  \$ 700    \cr
   February & skateboard &  \$ 100    \cr
   July     & yacht      & k\$ 170   \crl}
\bigskip

Apart from "l", "r", "c" declarators, you can use the "p{<size>}" declarator
which declares the column of given width. More preciselly, a long text in
the table cell is printed as an paragraph with given width.
To avoid the problems with narrow left-right aligned paragraphs you can write
"p{<size>\raggedright}", then the paragraph will be only left aligned.

You can use "(<text>)" in the "<declaration>" then this text is applied in
each line of table. For example "r(\kern10pt)l" adds more 10 pt space
between "r" and "l" rows. 

An arbitrary part of the "<declaration>" can be repeated by a "<number>"
prefixed. For example ``"3c"'' means ``"ccc"'' or ``"c 3{|c}"'' means
``"c|c|c|c"''. Note that spaces in the <declaration> are ignored and you 
can use them in order to more legibility.
 
The command "\cr" used in the "<data>" part of the table (the end row
separator) is generally known. 
Moreover OPmac defines following similar commands:

\begitems
* "\crl" \dots\ the end of the row with a horizontal line after it.
* "\crli" \dots\ like "\crl" but the horizontal line doesn't intersect the
      vertical double lines.
* "\crlli" \dots\ like "\crli" but horizontal line is doubled.
* "\crlp{<list>}" \dots\ like "\crli" but the lines are drawn only in the
columns mentioned in comma separated "<list>" of their numbers.
The "<list>" can include "<from>-<to>" declarators, for example
"\crlp{1-3,5}" is equal to "\crlp{1,2,3,5}". 
\enditems

The "\tskip<dimen>" command works like the "\noalign{\vskip<dimen>}" 
after "\cr*" commands but it doesn't interrupt the vertical lines.

The configuration macros for "\table" are defined in the following listing
with their default values:

\begtt
\def\tabiteml{\enspace} % left material in each column
\def\tabitemr{\enspace} % right material in each column
\def\tabstrut{\strut}   % strut inserted in each line
\def\vvkern{1pt}        % space between double vertical line
\def\hhkern{1pt}        % space between double horizontal line
\endtt

If you do "\def\tabiteml{$\enspace}\def\tabitemr{\enspace$}" then
the "\table" acts like \LaTeX's array environment.

If there is an item which spans to more than one column in the table then you can use
"\multispan{<number>}" macro from plain \TeX{} or "\mspan<number>[<declaration>]{<text>}"
from OPmac, which spans <number> columns and formats the <text> by the
<declaration>. The <declaration> must include a declaration of right one column
with the same syntax as comon "\table" <declaration>.
If your table includes vertical rules and you want to
create continuous vertical rules by "\mspan", then use rules in
only after ``"c"'', ``"l"'' or ``"r"'' letter in "\mspan" <declaration>. The
exception is only in the case when "\mspan" includes first
column and the table have rules on the left side. The example of "\mspan" usage is below.

The "\frame{<text>}" makes a frame around "<text>". You can put the whole "\table"
into "\frame" if you need double-ruled border of the table. Example:

\begtt
\frame{\table{|c||l||r|}{ \crl
  \mspan3[|c|]{\bf Title} \crl   \noalign{\kern\hhkern}\crli
  first & second & third  \crlli
  seven & eight  & nine   \crli}}
\endtt
%
creates the following result:

%\bigskip
\hfil\frame{\table{|c||l||r|}{\crl
  \mspan3[|c|]{\bf Title} \crl   \noalign{\kern\hhkern}\crli
  first & second & third  \crlli
  seven & eight  & nine   \crli}}
\bigskip

The "c", "l", "r" and "p" are default <declaration> letters but you can define
more such letters by "\def\tabdeclare<letter>{<left>##<right>}". The
technical documentation "opmac-d.pdf" describes this feature more preciselly.

The rule width of tables (and implicit width of all "\vrule"s and "\hrule"s)
can be set by the command "\rulewidth=<dimen>". The default value given 
by \TeX{} is 0.4pt.

Many tips about tables can be seen on
\url{http://petr.olsak.net/opmac-tricks-e.html}.

\sec Images
%%%%%%%%%%%

The "\inspic <filename>.<extension><space>" inserts the picture stored in
the graphics file  with the name "<filename>.<extension>". 
You can set the picture width by "\picw=<dimen>" before first "\inspic" command
which declares the width of the picture. 
The files can be in the PNG, JPG, JBIG2 or PDF format. The "\inspic" command
works with pdf\TeX{}/Xe\TeX{} only.

The "\picwidth" is an equivalent register to "\picw". Moreover there is an
"\picheight" register which denotes the height of the picture. If both
registers are set then the picture will be (probably) deformed. 

The file is searched in "\picdir". This macro is empty by default, this
means that the file is searched in current directory.

\sec PDF transformations
%%%%%%%%%%%%%%%%%%%%%%%%

All typesetting elements are transformed in pdf\TeX{} by linear
transformation given by the current transformation matrix. The
"\pdfsetmatrix {<a> <b> <c> <d>}" command makes the internal multiplication
with the current matrix so linear transformations can be composed. The
stack-oriented commands "\pdfsave" and "\pdfrestore" gives a possibility of
storing and restoring the current transformation matrix and current point.
The possition of current point have to be the same from \TeX{}'s point of
view as from transformation point of view when "\pdfrestore" is processed.
Due to this fact the "\pdfsave\rlap{<transformed text>}\pdfrestore" 
or something similar is recomeded.

OPmac provides the macros 

\begtt
\pdfscale{<horizontal-factor>}{<vertical-factor>} 
\pdfrotate{<angle-in-degrees>}
\endtt 

These macros simply calls the
properly "\pdfsetmatrix" primitive command.

It is known that the comosition of transformations is not commutative. It
means that the order is important. You have to read the tranformation
matrices from right to left. Example:

\begtt
First: \pdfsave \pdfrotate{30}\pdfscale{-2}{2}\rlap{text1}\pdfrestore
      % text1 is scaled two times and it is reflected about vertical axis
      % and next it is rotated by 30 degrees left.
second: \pdfsave \pdfscale{-2}{2}\pdfrotate{30}\rlap{text2}\pdfrestore
      % text2 is rotated by 30 degrees left then it is scaled two times
      % and reflected about vertical axis.
third: \pdfsave \pdfrotate{-15.3}\pdfsetmatrix{2 0 1.5 2}\rlap{text3}%
       \pdfrestore % first slanted, then rotated by 15.3 degrees right
\endtt

\bigskip\smallskip
This gives the following result. 
First: \pdfsave \pdfrotate{30}\pdfscale{-2}{2}\rlap{text1}\pdfrestore
second: \pdfsave \pdfscale{-2}{2}\pdfrotate{30}\rlap{text2}\pdfrestore
third: \pdfsave \pdfrotate{-15.3}\pdfsetmatrix{2 0 1.5 2}\rlap{text3}\pdfrestore
\bigskip\bigskip

\sec Footnotes and marginal notes
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

The plain\TeX{}'s macro "\footnote" is not redefined. But a new macro 
"\fnote{<text>}" is defined. The footnote mark is added automatically and it
is numbered on each page from one\fnote
{This behavior is changed if {\tt\char`\\runningfnotes} is used: 
the footnotes are numbered from one in whole document in such case.
Alternatives are possible, see OPmac tricks or technical documentation.}. 
The "<text>" is scaled by
"\typoscale[800]". The implicit visual aspect of the footnote mark is defined by
"\def\thefnote{$^{\locfnum}$}".
%\fnote{%
%   Note the right parenthesis in the mark. This isn't bug, this is used in Czech
%   traditional typography. If you need to remove it, you can define
%   {\def\s{\string}\tt\s\def\s\thefnote\s{\$\s^\s{\s\locfnum\s}\$\s}}.
%   }.
User can redefine it, for example:

\begtt
\def\thefnote{\ifcase\locfnum\or *\or**\or***\or$^{\dag}$\or
   $^{\ddag}$\or$^{\dag\dag}$\fi}
\endtt

The "\fnote" macro is fully applicable only in ``normal outer'' paragraph.
It doesn't work inside boxes (tables for example). If you are solving such
case you can use "\fnotemark<number>" inside the box (only the footnote mark is
generated). When the box is finished you can use "\fnotetext{<text>}". This
macro puts the "<text>" to the footnote. The "<number>" after "\fnotemark"
have to be "1" if only one such command is in the box. Second "\fnotemark"
inside the same box have to have the parameter "2" etc. 
The same number of "\fnotetext"s have to be written 
after the box as the number of "\fnotemark"s inserted inside the box.

The marginal note can be printed by the "\mnote{<text>}" macro. The <text>
is placed to the right margin on the odd pages and it is placed to the left
margin on the even pages. This is done after second \TeX{} run because the
relevant information is stored in an external file. If you need to place the
notes only to the fixed margin write "\fixmnotes\right" or
"\fixmnotes\left".

The <text> is formatted as a little paragraph with the maximal width
"\mnotesize" ragged left on the left margins or ragged right on the right
margins. The first line of this little paragraph is at the same height as
the invisible mark created by "\mnote" in the current paragraph. The
exceptions are possible by "\mnoteskip" register. You can implement such
exceptions to each "\mnote" manually in final printing in order to margin
notes do not overlap. The positive value of "\mnoteskip" shifts the note up
and negative value shifts it down. For example
"\mnoteskip=2\baselineskip \mnote{<text>}" shifts this (and only this) note 
two lines up.


\sec Bib\TeX ing
%%%%%%%%%%%%%%%%

The command "\cite[<label>]" or its variations of the type
\hbox{"\cite[<label-1>,<label-2>,<label-3>]"}
create the citations in the form [42] or [15,~19,~26]. 
If "\shortcitations" is declared at the beginning of the document then continuous sequences of
numbers are re-printed like this: \hbox{[3--5,~7,~9--11]}. If
"\sortcitations" is declared then numbers generated by one "\cite" command
are sorted upward.

If "\nonumcitations" is used then the marks instead numbers are generated
depending on the used bib\TeX{} style. For example the citations look like
[Now08] when "alpha" style is used and like [Nowak, 2008] when "apalike"
style is used.

The "\rcite[<labels>]" creates the same list as "\cite[<labels>]" but without
the outer brackets. Example: "[\rcite[tbn], pg.~13]" creates [4,~pg.13].

The "\ecite[<label>]{<text>}" prints the "<text>" only, but the entry labeled
"<label>" is decided as to be cited. If "\hyperlinks" is used then "<text>"
is linked to the references list.

You can define alternative formating of "\cite" command. Example:

\begtt
\def\cite[#1]{(\rcite[#1])}    % \cite[<label>] creates (27)
\def\cite[#1]{$^{\rcite[#1]}$} % \cite[<label>] creates^{27}
\endtt

The numbers printed by "\cite" correspond to the same numbers generated in
the list of references. There are four possibilities to generate this
references list:

\begitems
* Manually using "\bib[<label>]" commands.
* Using bib\TeX{} and "\usebibtex{<bib-base>}{<bib-style>}" command.
* Using pregenerated "*.bbl" file and "\usebbl/<type> <bbl-base>" command.
* By "\usebib/<type> (<style>) <bbl-base>" command which reads "*.bib"
  databases directly. 
\enditems

These possibilities are documented here in detail:

\medskip\noindent
{\bf References created manually using "\bib[<label>]" command.}

{\def\tthook{\catcode`/=0 \catcode`+=9 }
\begtt
\bib [tbn] P. Ol/v+s/'ak. {\it\TeX{}book naruby.} 468~s. Brno: Konvoj, 1997.
\bib [tst] P. Ol/v+s/'ak. {\it Typografick/'y syst/'em \TeX.}  
           269~s. Praha: CSTUG, 1995.
\endtt
}

If you are using "\nonumcitations" then you need to declare the "<marks>"
used by "\cite" command. To do it you have to use long form of the "\bib"
command which is in the format "\bib[<label>] = {<mark>}". The spaces around
equal sign are mandatory. Example:

{\def\tthook{\catcode`/=0 \catcode`+=9 }
\begtt
\bib [tbn] = {Olšák, 2001} 
    P. Ol/v+s/'ak. {\it\TeX{}book naruby.} 468~s. Brno: Konvoj, 2001.
\endtt
}

{\bf References using bib\TeX.}
The command "\usebibtex{<bib-base>}{<bst-style>}"
 creates the list of cited entries and entries indicated by
"\nocite[<label>]". 
After first \TeX{} run the "*.aux" file is created, so user have to run
the bib\TeX{} by the command "bibtex <document>". After second \TeX{} run 
the bib\TeX's
output is read and after third \TeX{} run all references are properly
created.

The "<bib-base>" is one or more "*.bib" database source files (separated by
spaces and without extension) and the "<bst-style>" is the style used by
bib\TeX. The common styles are "plain", "alpha", "apalike", "ieeetr",
"unsrt". 

\medskip\noindent
{\bf Using pregenerated "*.bbl" file by bib\TeX.}
You can create the temporary file ("mybase.tex", for example) 
which looks like:

\begtt
\input opmac  
\genbbl{<bib-base>}{<bst-style>}  
\end
\endtt
%
After first \TeX{} run the "mybase.aux" is generated. Then you can run
"bibtex mybase" which generates the ".bbl" file with all entries from the
"<bib-base>" "*.bib" file(s). Second \TeX{} run on the file "mybase.tex" generates
the printed form of the list of all bib entries with labels. This is usable
printed matter, you can place it to your notice board when you create
your document. Finally you can insert to your real document one of the
following commands:

\begtt
\usebbl/a mybase  % print all entries from mybase.bbl (a=all) 
\usebbl/b mybase  % print only \cited and \nocided entries
                  % sorted by mybase.bbl  (b=bbl)
\usebbl/c mybase  % print only \cited and \nocited entries
                  % sorted by \cite-order (c=cite)
\endtt

Sometimes the pure \LaTeX{} command occurs (unfortunately) 
in the ".bib" database or bib\TeX{}
style. User can define such commands in the "\bibtexhook" macro which is a
hook started inside the group before ".bbl" file is read. Example:

\begtt
\def\bibtexhook{\def\emph##1{{\em##1}}\def\frac##1##2{{##1\over##2}}}
\endtt

\noindent
{\bf Direct reading of ".bib" files} is possible by "\usebib" macro.
This macro reads macro package "opmac-bib.tex" (on demand) which uses the external 
package "librarian.tex" by Paul Isambert. The usage is similar to previous case:

\begtt
                           % print only \cited and \nocited entries
\usebib/c (<style>) <bib-base> % sorted by \cite-order (c=cite),
\usebib/s (<style>) <bib-base> % sorted by style (s=style).
\endtt

The "<bib-base>" is one or more "*.bib" database source files (separated by
spaces and without extension) and the "<style>" is the part of the filename
"opmac-bib-<style>.tex" where the formatting of the references list is
defined. Possible styles are "simple" or "iso690". The behavior of
"opmac-bib.tex" and "opmac-bib-iso690.tex" is full documented in these files
(after "\endinput" command).

\medskip\noindent
{\bf Formatting of the references list} is controlled by the "\printb" macro.
It is called at the begin of each entry. The default "\printb" macro prints
the number of the entry in square brackets. If the "\nonumcitations" is set
then no numbers are printed, only all lines (but no first one) are indented.
The "\printb" macro can use the following values: "\the\bibnum" (the number
of the entry) and "\the\bibmark" (the mark of the entry used when
"\nonumcitations" is set). Examples:

\begtt
% The numbers are without square brackets:
\def\printbib{\hangindent=\parindent \indent \llap{\the\bibnum. }}
% Printing of <marks> when \nonumcitations is set:
\def\printbib{\hangindent=\parindent \noindent [\the\bibmark]\quad}
\endtt 

Next examples can be found on the 
\ulink[http://petr.olsak.net/opmac-tricks-e.html]{OPmac tricks WWW page}.


\sec Typesetting math
%%%%%%%%%%%%%%%%%%%%%

There are two files for math typesetting prepared in \csplain:

\begitems
* "ams-math.tex" loads the AMS math fonts visual compatible with Computer
  modern.
* "tx-math.tex" loads the TX fonts visual compatible with Times.
\enditems

OPmac reads the first file "ams-math.tex" by default. If you are using font
files from \csplain{} ("ctimes.tex", "cbookman.tex", "cs-termes.tex" etc.)
then the second math-file "tx-math.tex" is loaded.

This section describes the features of the macros from "ams-math.tex" or
"tx-math.tex". More documentation is written in these files themselves. 

Hundreds math symbols and operators like in AMS\TeX{} are accesible. 
For example  "\alpha" $\alpha$, "\geq" $\geq$, "\sum" $\sum$, 
"\sphericalangle" $\sphericalangle$, "\bumpeq", $\bumpeq$. See AMS\TeX{}
manual (or TX-fonts manual) for complete list of symbols.

The following math alphabets are available:

{\def\tthook{\catcode`\$=3 \catcode`/=0 \medmuskip=0mu \adef{ }{ }}%
\begtt
\mit     % mathematical variables    $abc-xyz,ABC-XYZ$
\it      % text italics              $/it abc-xyz,ABC-XYZ$
\rm      % text roman                $/rm abc-xyz,ABC-XYZ$
\cal     % normal calligraphics      $/cal ABC-XYZ$
\script  % script                    $/script ABC-XYZ$
\frak    % fracture                  $/frak abc-xyz,ABC-XYZ$
\bbchar  % double stroked letters    $/bbchar ABC-XYZ$
\bf      % sans serif bold           $/bf abc-xyz,ABC-XYZ$
\bi      % sans serif bold slanted   $/bi abc-xyz,ABC-XYZ$
\endtt
}

The last two selectors "\bf" and "\bi" select the sans serif fonts regardless
current text font family. The reason is that these shapes are used for
vectors and matrices in Czech math typesetting.

The math fonts are scaled by "\typosize" and "\typoscale" macros.
Two math fonts collections are prepared: "\normalmath" for normal weight
and "\boldmath" for bold. The first one is set by default.
There is an example for math typesetting in titles:

\begtt
\def\title#1\par{\centerline{\typosize[17/]\bf\boldmath #1}}
\title The title with math $\int_a^b f(x) {\rm d}x$ is here
\endtt

Variables are printed by special math italics when "ams-math.tex" is loaded
and by text italics of the current text font when "tx-math.tex" is loaded.
You can change this behavior by following commands:

\begtt
\itvariables  % variables typeset by text italics.
\mitvariables % variables typeset by math italics.
\endtt
%
{\bf Note:} Due to the features described in this section (AMS symbols, "\bbchar",
"\script", "\frak" characters and sans serif bold in math) more special fonts are loaded
(from AMS package and from EC fonts). If you dislike such dependency, you
can follow the \ulink[http://petr.olsak.net/opmac-tricks-e.html\#onlycm]{OPmac trick 0111}.


\sec Setting the margins
%%%%%%%%%%%%%%%%%%%%%%%%

OPmac declares paper formats a4, a4l (landscape~a4), a5, a5l, b5, letter and
user can declare another own format by "\sdef":

\begtt
\sdef{pgs:b5l}{(250,176)mm} 
\sdef{pgs:letterl}{(11,8.5)in}
\endtt

The "\margins" command declares margins of the document. This command have
the following parameters:

\begtt
\margins/<pg> <fmt> (<left>,<right>,<top>,<bot>)<unit>
  example:
\margins/1 a4 (2.5,2.5,2,2)cm
\endtt

Parameters are:

\begitems
* <pg> \dots\ "1" or "2" specifies one-page or two-pages design.
* <fmt> \dots\ paper format (a4, a4l, a5, letter, etc. or user defined).
* <left>, <right>, <top>, <bot> \dots\ gives the amount of left, right,
      top and bottom margins.
* <unit> \dots\ unit used for values <left>, <right>, <top>, <bot>.
\enditems

Each of the parameters <left>, <right>, <top>, <bot> can be empty.
If both <left> and <right> are nonempty then "\hsize" is set. Else "\hsize"
is unchanged. If both <left> and <right> are empty then typesetting area is
centered in the paper format. The analogical rule works when <top> or <bot>
parameter is empty ("\vsize" instead "\hsize" is used). Examples:

\begtt
\margins/1 a4 (,,,)mm   % \hsize, \vsize untouched, 
                        % typesetting area centered
\margins/1 a4 (,2,,)cm  % right margin set to 2cm
                        % \hsize, \vsize untouched, vertically centered
\endtt

If "<pg>=1" then all pages have the same margins. If "<pg>=2" then the
declared margins are true for odd pages. The margins at the even pages are
mirrored in such case, it means that <left> is replaced by <right> and vice
versa.

The "<fmt>" can be in the form "(<width>,<height>)<unit>" where "<unit>" is
optional. If it is missing then "<unit>" after margins specification is
used. For example:

\begtt
\margins/1 (100,200) (7,7,7,7)mm
\endtt
%
declares the paper 100$\times$200\,mm with all four margins 7\,mm. The spaces
before and after "<fmt>" parameter are necessery.

The command "\magscale[<factor>]" scales the whole typesetting area. The
fixed point of such scaling is the so called the ``Knuth's point'': 1in
below and 1in right of paper sides. Typesetting (breakpoints etc.) is
unchanged. All units are relative after such scaling. Only paper formats
dimensions stays unscaled. Example:

\begtt
\margins/2 a5 (22,17,19,21)mm
\magscale[1414] \margins/1 a4 (,,,)mm
\endtt
%
The first line sets the "\hsize" and "\vsize" and margins for final
printing at a5 format. The setting on the second line centers the scaled 
typesetting area to the true a4 paper while breaking points for paragraphs
and pages are unchanged. It may be usable for 
review printing. After review is done, the second line can be commented out.

\sec The last page
%%%%%%%%%%%%%%%%%%

The number of the last page (it may be different from number of pages) is
stored in the "\lastpage" register after first \TeX{} run if the working "*.ref" 
file is open. This file isn't open for every documents; only for those
where the forward references are printed or table of contents is created.
If the "*.ref" file isn't open for your document and you need to use the "\lastpage"
register then you have to write the command "\openref". This command opens
the "*.ref" file immediatelly.

There is an example for footlines in the format ``current page / last
page'': 

\begtt
\footline={\hss \rm \thefontsize[10]\the\pageno/\the\lastpage \hss}
\endtt

\sec Using other language
%%%%%%%%%%%%%%%%%%%%%%%%%

OPmac supports all languages but only English, Czech and Slovak languages
are immediately ready for use. When using another language, you have to do
little more work. First of all, use \TeX{} engine and \TeX{} format ready
for such language (with hyphenation patterns preloaded or prepared). 
\CS{}plain for pdf\TeX{} supports 16 languages (since March 2019) but better
choice is \CS{}plain for Lua\TeX{} which works in Unicode and supports all
languages from \TeX{} distribution (about 57 languages).

The next example shows usage of Spanish language. \CS{}plain for Lua\TeX{}
is assumed, so use the command
"luatex -fmt pdfcsplain example".

\mubyte \ntie ^^c3^^b1\endmubyte \def\ntie{\~n}
\mubyte \ccedilla ^^c3^^a7\endmubyte \def\ccedilla{\c c}
\mubyte \Ccedilla ^^c3^^87\endmubyte \def\Ccedilla{\c C}

\begtt
\input opmac
\input lmfonts   % Unicode fonts

\sdef{mt:chap:es}{Capítulo}   % Chapter in es
\sdef{mt:t:es}{Cuadro}        % Table in es
\sdef{mt:f:es}{Figura}        % Figure in es

\eslang % Spanish hyphenation + activation of declated "es" words

\sec Mañana

Mañana.

\caption/f Test % generates the text "Figura 1.1 Test"

\bye
\endtt

The declaration of the Spanish words ``Capítulo'', ``Cuadro'' and ``Figura''
is shown in this example. You can see that such declaration is based on the
short language name "es" (by ISO 639-1). The declared words are activated
after the hyphenation selector "\eslang" is used.

When you are using basic fromat from "etex.src", i.e.\ the commands
"luatex example" or "xetex example", then you have to use language selector
"\uselanguage{espanol}" instead "\eslang" and you  have to declare the
connection from long language name to short name by
"\isolangset{espanol}{es}".

When sorting the index by "\makeindex" in the non-\csplain{} format, OPmac
writes a warning: ``falling back to ASCII sorting''.
If you want to use sorting rules given for your language, 
you must define the macro "\sortingdata<iso-code>". And you can optionally
define the "\specsortingdata<iso-code>" macro. Example:
{\emergencystretch=2em\par}

\begtt
\def\sortingdataes {aAäÄáÁ,bB,cCçÇ,^^P^^Q^^R,dD,...,zZ,.}
\def\specsortingdataes {ch:^^P Ch:^^Q CH:^^R}
\endtt

There are groups of letters separated by comma and ended by comma-dot in
the macro "\sortingdata<iso-code>". (In the example above, three dots must
be replaced by real data by the user.) All letters in one group are not
distinguished during first step of sorting (primary sorting). If some items
are equal from this point of view then the secondary sorting is processed
for such items where all mentioned letters are distinguished in the order
given in the macro. 

Sorting algorithm can treat couple of letters (like Dz, Ch etc.) as one letter 
if the macro "\specsortingdata<iso-code>" is defined. There is
a space separated list of items in the form "<couple>:<one-token>". The
replacing from <couple> to <one-token> is done before sorting, so you can
use "<one-token>" in the "\sortingdata<iso-code>" macro. The "<one-token>"
must be something special not used as the letter of the alphabet. The usage of "^^A",
"^^B" etc. is recommended but you must avoid the "^^I" and "^^M" because
these characters have special catcode.

The macro "\sortingdata<iso-code>" (if it is defined and the hyphenation of
given language is selected) has precedence before an internal "\sortingdata"
defined in OPmac. The internal "\sortingdata" are optimized for Czech,
Slovak and English languages.

The list of ignored characters for sorting point of view is defined in the
"\setignoredchars" macro. OPmac defines this macro like:

{\catcode`\<=12
\begtt
\def\setignoredchars{\setlccodes ,.;.?.!.:.'.".|.(.).[.].<.>.=.+.{}{}}
\endtt
}%
It means that comma, semicolon, question mark, \dots, plus mark are treated
as dot and dot is ignored by sorting algorithm. You can redefine this macro,
but you must keep the format, keep "\setlccodes" in the front and "{}{}" in
the end.

\sec Pre-defined styles

OPmac defines two style-declaration macros "\report" and "\letter" since
Mar.~2019. You can use them at the beginning of your document if you are
preparing these types of document and you don't need to create your own
macros.

The "\report" declaration is intended to create reports. It 
sets default font size to 11\,pt and "\parindent" to 1.2\,em.
The "\tit" macro uses smaller font because we assume that ``chapter'' level
will be not used in reports. The first page has no page number, but next pages
are numbered (from number 2). The footnotes are numbered from one in whole
document. The macro "\author <authors><end-line>" can be used when 
"\report" is declared. It prints "<authors>" in italics at center of the
line. You can separate authors by "\nl" to more lines.

The "\letter" declaration is intended to create letters. It sets default
font size to 11\,pt and "\parindent" to 0\,pt. It sets half-line space
between paragraphs. The page numbers are not printed. The "\subject" macro
can be used, it prints the word ``Subject:'' or ``V\v{e}c'' in bold
depending on used language. Moreover, the "\address" macro
can be used when "\letter" is declared. The usage of the "\address" macro
looks like:

\begtt
\address
  <first line of address>
  <second line of address>
  <etc.>
  <empty line>
\endtt

It means that you need not to use any special mark at the end of lines: end
of lines in the source file are the same as in printed output. The
"\address" macro creates "\vtop" with address lines. The width of such
"\vtop" is equal to the most wide line used in it. So, you can use
"\hfill\address..." in order to put the address box to the right side of the
document. Or you can use "<prefixed text>\address..." to put 
"<prefixed text>" before first line of the address.

Analogical declaration macros "\book" or "\slides" are not prepared. Each
book needs an individual typographical care so you need to cerate specific
macros for design. And you can find an inspiration of slides in OPmac tricks
\ulink[http://petr.olsak.net/opmac-tricks-e.html\#slidy]{0017 and 0022}.


%\vfil\break

\sec Summary
%%%%%%%%%%%%

\def\tthook{\typosize[10/12]\adef!{\string\endtt}\adef&{\kern.25em}}
\begtt
\tit Title (terminated by end of line)
\chap Chapter Title (terminated by end of line)
\sec Section Title (terminated by end of line)
\secc Subsection Title (terminanted by end of line)

\maketoc         % table of contents generation
\ii item1,item2  % insertion the items to the index
\makeindex       % the index is generated

\label [labname]  % link target location
\ref [labname]    % link to the chapter, section, subsection, equation
\pgref [labname]  % link to the page of the chapter, section, ...

\caption/t  % a numbered table caption
\caption/f  % a numbered caption for the picture
\eqmark     % a numbered equation

\begitems       % start list of the items
\enditems       % end of list of the items
\begtt          % start verbatim text
!          % end verbatim text
\activettchar X % initialization character X for in-text verbatim
\verbinput      % verbatim extract from the external file
\begmulti num   % start multicolumn text (num columns)
\endmulti       % end multicolumn text

\cite [labnames]  % refers to the item in the lits of references
\rcite [labnames] % similar to \cite but [] are not printed.
\sortcitations \shortcitations \nonumcitations % cite format
\bib [labname]  % an item in the list of references
\usebibtex {bib-base}{bst-style}  % use BibTeX for bibliography
\genbbl {bib-base}{bst-style}     % prepare the bbl file generation
\usebbl/? bbl-base   % use pre-generated bbl file, ? in {a,b,c}
\usebib/? (style) bib-base % direct using of .bib file, ? in {s,c}

\fontfam [FamilyName] % selection of font family
\typosize [font-size/baselineskip] % size setting of typesetting
\typoscale [factor-font/factor-baselineskip] % size scaling
\thefontsize [size] \thefontscale [factor]   % current font size

\inspic file.ext    % insert a picture, extensions: jpg, png, pdf
\table {rule}{data} % simple macro for the tables like in LaTeX

\fnote    % footnote (local numbering on each page)
\mnote    % note in the margin (left or right by page number)

\hyperlinks {color-in}{color-out} % PDF links activate as clickable
\outlines {level}   % PDF will have a table of contents in the left tab

\magscale[factor]  % resize typesetting, line/page breaking unchanged
\margins/pg format (left, right, top, bottom)unit % margins setting

\report \letter    % style declaration macros
\endtt

\end