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
|
% \iffalse meta-comment
% A LaTeX Class for CNXML
% Copyright (c) 2006 Michael Kohlhase, all rights reserved
% this file is released under the
% Gnu Library Public Licences (LGPL)
%
% The development version of this file can be found at
% https://svn.kwarc.info/repos/kwarc/projects/stex/sty/cnx.dtx
% \fi
%
% \iffalse
%<class>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<class>\ProvidesClass{cnx}[2006/01/10 v0.1 LaTeX Bindings for CNXML]
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{url,array,float}
\usepackage[show]{ed}
\makeindex
\floatstyle{boxed}
\newfloat{exfig}{thp}{lop}
\floatname{exfig}{Example}
\begin{document}\DocInput{cnx.dtx}\end{document}
%</driver>
% \fi
%
%\CheckSum{443}
%
% \changes{v0.1}{2005/12/06}{Initial Version}
% \changes{v0.2}{2006/01/11}{Namespaces now work}
%
% \GetFileInfo{cnx.cls}
%
% \MakeShortVerb{\|}
%\def\scsys#1{{{\sc #1}}\index{#1@{\sc #1}}}
% \def\stex{{\raisebox{-.5ex}S\kern-.5ex\TeX}}
% \def\sTeX{\stex}
% \def\xml{\scshape{XML}}
% \def\cnxml{\scshape{CNXml}}
% \def\connexions{\scshape{Connexions}}
% \def\element#1{{\ttfamily{#1}}}
% \def\snippet#1{{\ttfamily{#1}}}
% \def\cnxlatex{CNX\LaTeX}
% \def\mathml{{\scshape{MathML}}}
% \def\latexml{\hbox{{\LaTeX}ML}}
% \title{{\cnxlatex}: A {\LaTeX}-based Syntax for Connexions Modules\thanks{Version {\fileversion}
% (last revised {\filedate})}}
% \author{Michael Kohlhase\\
% Jacobs University, Bremen\\
% \url{http://kwarc.info/kohlhase}}
% \maketitle
%
% \begin{abstract}
% We present {\cnxlatex}, a collection of {\LaTeX} macros that allow to write
% {\connexions} modules without leaving the {\LaTeX} workflow. Modules are authored in
% {\cnxlatex} using only a text editor, transformed to PDF and proofread as usual. In
% particular, the {\LaTeX} workflow is independent of havin access to the {\connexions}
% system, which makes {\cnxlatex} attractive for the initial version of single-author
% modules.
%
% For publication, {\cnxlatex} modules are transformed to {\cnxml} via the {\latexml}
% translator and can be uploaded to the {\connexions} system.
% \end{abstract}
%\newpage
%\section{Introduction}
%
% The Connexions project is a\ednote{continue; copy from somewhere...}
%
% The {\cnxml} format --- in particular the embeded content {\mathml} --- is hard to write
% by hand, so we provide a set of enviroments that allow to embed the {\cnxml} document
% model into {\LaTeX}.
%
%\section{The User Interface}
%
% This document is not a manual for the Connexions XML encoding, or a practical guide how
% to write Connexions modules. We only document the {\LaTeX} bindings for {\cnxml} and will
% presuppose experience with the format or familiarity with\ednote{cite the relevant stuff
% here}. Note that formatting {\cnxlatex} documents with the {\LaTeX} formatter does
% little to enforce the restrictions imposed by the {\cnxml} document model. You will need to
% run the {\latexml} converter for that (it includes DTD validation) and any CNX-specific
% quality assurance tools after that. \ednote{talk about Content {\mathml} and cmathml.sty
% somewhere}
%
% The {\cnxlatex} class makes heavy use of the |KeyVal| package, which is part of your
% {\LaTeX} distribution. This allows to add optional information to {\LaTeX} macros in the
% form of key-value pairs: A macro |\foo| that takes a KeyVal argument and a regular one,
% so a call might look like |\foo{bar}| (no KeyVal information given) or
% |\foo[key1=val1,...,keyn=valn]{bar}|, where |key1|,\dots,|keyn| are predefined keywords
% and values are {\LaTeX} token sequences that do not contain comma characters (though
% they may contain blank characters). If a value needs to contain commas, then it must be
% enclosed in curly braces, as in |\foo[args={a,comma,separated,list}]|. Note that the
% order the key/value pairs appear in a KeyVal Argument is immaterial.
%
% \subsection{Document Structure}
%
% \begin{exfig}
%\begin{verbatim}
% \documentclass{cnx}
% \begin{document}
% \begin{cnxmodule}[name=Hello World,id=m4711]
% \begin{ccontent}
% \begin{cpara}[id=p01] Hello World\end{cpara}
% \end{ccontent}
% \end{cnxmodule}
% \end{document}
% \end{verbatim}
% \caption{A Minimal {\cnxlatex} Document}\label{fig:minimal}
%\end{exfig}
%
% The first set of {\cnxlatex} environments concern the top-level structure of the
% modules. The minimal Connexions document in {\LaTeX} can be seen in
% Figure~\ref{fig:minimal}: we still need the {\LaTeX} document environment, then
% \DescribeEnv{cnxmodule}
% the |cnxmodule| environment contains the module-specific information as a KeyVal
% argument with the two keys: |id| for the module identifier supplied by the
% {\connexions} system) and |name| for the title of the module.
%
% \DescribeEnv{ccontent}
% The |content|envionrment delineates the module content from the metadata (see
% Section~\ref{sec:metadata}). It is needed to make the conversion to {\cnxml} simpler.
%
% \DescribeEnv{c*section}
% {\cnxml} knows three levels of sectioning, so the {\cnxlatex} class supplies three as
% well: |csection|, |csubsection| and |csubsubsection|. In contrast to regular
% {\LaTeX}, these are environments to keep the tight connection between the
% formats. These environments take an optional KeyVal argument with key |id| for the
% identifier and a regular argument for the title of the section (to be transformed into
% the {\cnxml} {\element{name}} element).
%
% \DescribeEnv{cpara, cnote}
% The lowest levels of the document structure are given by paragraphs and notes. The
% |cpara| and |cnote| environment take a KeyVal argument with the |id| key for
% identification, the latter also allows a |type| key for the note type (an unspecified
% string\ednote{what are good values?}).
%
%
% \subsection{Mathematics}
%
% Mathematical formulae are integrated into text via the {\LaTeX} math mode, i.e. wrapped
% in |$| characters or between |\(| and |\)| for inline mathematics and wrapped in |$$| or
% between |\[| and |\]| for display-style math. Note that {\cnxml} expects Content
% {\mathml} as the representation format for mathematical formulae, while run-of-the-mill
% {\LaTeX} only specifies the presentation (i.e. the two-dimensional layout of
% formulae). The {\latexml} converter can usually figure out some of the content {\mathml}
% from regular {\LaTeX}, in other cases, the author has to specify it e.g. using the
% infrastructure supplied by the |cmathml| package.
%
% \DescribeEnv{cequation}
% For numbered equations, {\cnxml} supplies the {\element{equation}} element, for which
% {\cnxlatex} provides the |cequation| environment. This environment takes a KeyVal
% argument with the |id| key for the (required) identifier.
%
%
% \subsection{Statements}
%
% {\cnxml} provides special elements that make represnet various types of claims; we
% collectively call them statements.
%
% \DescribeEnv{cexample}
% The |cexample| environment and |definition| elements take a KeyVal argument with key
% |id| for identification.
%
%
% \DescribeEnv{crule, statement, proof}
% In {\cnxml}, the {\element{rule}} element is used to represent a general assertion
% about the state of the world. The {\cnxlatex} |rule|\ednote{we have called this
% ``crule'', since ``rule'' is already used by {\TeX}.} environment is its {\cnxlatex}
% counterpart. It takes a KeyVal attribute with the keys |id| for identification, |type|
% to specify the type of the assertion (e.g. ``Theorem'', ``Lemma'' or ``Conjecture''),
% and |name|, if the assertion has a title. The body of the |crule| environment contains
% the statemnt of assertion in the |statement| environment and (optionally) a proof in
% the |proof| environment. Both take a KeyVal argument with an |id| key for
% identification.
%
%\begin{exfig}
%\begin{verbatim}
% \begin{crule}[id=prop1,type=Proposition]
% \begin{statement}[id=prop1s]
% Sample statement
% \end{statement}
% \begin{proof}[id=prop1p]
% Your favourite proof
% \end{proof}
% \end{crule}
% \end{verbatim}
% \caption{A Basic crule Example}\label{fig:crule}
%\end{exfig}
%
% \DescribeEnv{definition, cmeaning} A definition defines a new technical term or concept
% for later use. The |definition| environment takes a KeyVal argument with the keys |id|
% for identification and |term| for the concept (definiendum) defined in this form. The
% definion text is given in the |cmeaning| environment\footnote{we have called this
% |cmeaning|, sinc |menaning| is already taken by {\TeX}}, which takes a KeyVal argument
% with key |id| for identification. After the |cmeaning| environment, a |definition| can
% contain arbitrarily many |cexample|s.
%
%\begin{exfig}
%\begin{verbatim}
% \begin{definition}{term=term-to-be-defined, id=termi-def]
% \begin{cmeaning}[id=termi-meaning]
% {\term{Term-to-be-defined}} is defined as: Sample meaning
% \end{cmeaning}
% \end{definition}
%\end{verbatim}
% \caption{A Basic {\tt{definition}} and {\tt{cmeaning}} Example}\label{fig:def-cmean}
%\end{exfig}
%
% \subsection{Connexions: Links and Cross-References}
%
% As the name {\connexions} already suggests, links and cross-references are very
% important for {\connexions} modules. {\cnxml} provides three kinds of them. Module
% links, hyperlinks, and concept references.
%
% \DescribeMacro{cnxn}
% Module links are speficied by the |\cnxn| macro, which takes a keyval argument with
% the keys |document|, |target|, and |strength|. The |document| key allows to specify
% the module identifier of the desired module in the repository, if it is empty, then
% the current module is intended. The |target| key allows to specify the document
% fragment. Its value is the respective identifier (given by its |id| attribute in
% {\cnxml} or the |id| key of the corresponding environment in {\cnxlatex}). Finally,
% the |strength| key allows to specify the relevance of the link.
%
% The regular argument of the |\cnxn| macro is used to supply the link text.
%
%
% \DescribeMacro{link}
% Hyperlinks can be specified by the |\link| macro in {\cnxlatex}. It takes a KeyVal
% argument with the key |src| to specify the URL of the link. The regular argument of
% the |\link| macro is used to supply the link text.
%
%
% \DescribeMacro{term}
% The |\term| marcro can be used to specify the\ednote{continue, pending Chuck's
% investigation. }
%
%
% \subsection{Metadata}\label{sec:metadata}
%
% Metadata is mostly managed by the system in {\connexions}, so we often do not need to
% care about it. On the other hand, it influences the system, so if we have work on the
% module extensively before converting it to {\cnxml}, it may be worthwile specify some of
% the data in advance.
%
% \begin{exfig}
%\begin{verbatim}
% \begin{metadata}[version=2.19,
% created=2000/07/21,revised=2004/08/17 22:07:27.213 GMT-5]
% \begin{authorlist}
% \cnxauthor[id=miko,firstname=Michael,surname=Kohlhase,
% email=m.kohlhase@iu-bremen.de]
% \end{authorlist}
% \begin{keywordlist}\keyword{Hello}\end{keywordlist}
% \begin{cnxabstract}
% A Minimal CNXLaTeX Document
% \end{cnxabstract}
% \end{metadata}
% \end{verbatim}
% \caption{Typical {\cnxlatex} Metadata}\label{fig:metadata}
%\end{exfig}
%
% \DescribeEnv{metadata}
% The |metadata| environment takes a KeyVal argument with the keys |version|, |created|,
% and |revised| with the obvious meanings. The latter keys take ISO 8601 norm
% representations for dates and times. Concretely, the format is
% {\snippet{CCYY-MM-DDThh:mm:ss}} where ``{\snippet{CC}}'' represents the century,
% ``{\snippet{YY}}'' the year, ``{\snippet{MM}}'' the month, and ``{\snippet{DD}}'' the
% day, preceded by an optional leading ``{\snippet{-}}'' sign to indicate a negative
% number. If the sign is omitted, ``{\snippet{+}}'' is assumed. The letter
% ``{\snippet{T}}'' is the date/time separator and ``{\snippet{hh}}'',
% ``{\snippet{mm}}'', ``{\snippet{ss}}'' represent hour, minutes, and seconds
% respectively.
%
%
% \DescribeEnv{authorlist, maintainerlist}
% The lists of authors and maintainers can be specified in the |authorlist| and
% |maintainerlist| environments, which take no arguments.
%
% \DescribeMacro{cnxauthor,maintainer}
% The entries on this lists are specified by the |\cnxauthor| and |\maintainer|
% macros. Which take a KeyVal argument specifying the individual. The |id| key is the
% identifier for the person, the |honorific|, |firstname|, |other|, |surname|, and
% |lineage| keys are used to specify the various name parts, and the |email| key is used
% to speficy the e-mail address of the person.
%
%
% \DescribeEnv{keywordlist, keyword}
% The keywords are specified with a list of |keyword| macros, which take the respective
% keyword in their only argument, inside a |keyword| environment. Neither take any
% KeyVal arguments.
%
%
% \DescribeEnv{cnxabstract}
% The abstract of a {\connexions} module is considered to be part of the metadata. It is
% specified using the |cnxabstract| environment. It does not take any arguments.
%
%
% \subsection{Exercises}
%
% \DescribeEnv{cexercise, cproblem, csolution}
% An exercise or problem in {\connexions} is specified by the |cexercise| environment,
% which takes an optional keyval argument with the keys |id| and |name|. It must contain
% a |cproblem| environment for the problem statement and a (possibly) empty set of
% |csolution| environments. Both of these take an optional keyval argument with the key
% |id|.
%
% \subsection{Graphics, etc.}
%
% \DescribeMacro{cfigure} For graphics we will use the |cfigure|\ednote{probably better
% call it {\tt{cgraphics}}} macro, which provides a non-floating environment for
% including graphics into {\cnxml} files. |cfigure| takes three arguments first an
% optional {\cnxml} keys, then the keys of the |graphicx| package in a regular argument
% (leave that empty if you don't have any) and finally a path. So
% \begin{center}
% |\cfigure[id=foo,type=image/jpeg,caption=The first FOO]{width=7cm,height=2cm}{../images/foo}|
% \end{center}
% Would include a graphic from the file at the path |../images/foo|, equip this image with
% a caption, and tell {\latexml} that\ednote{err, exactly what does it tell latexml?} the
% original of the images has the MIME type |image/jpeg|.
%
% \StopEventually{\ednotemessage}
%
%\section{The Implementation}
%
% We first make sure that the |KeyVal| and |graphicx| packages are loaded.
% \begin{macrocode}
%<*cls>
\RequirePackage{keyval}
\RequirePackage{graphicx}
% \end{macrocode}
%
% The next step is to declare (a few) class options that handle the paper size; this is
% useful for printing.
% \begin{macrocode}
\DeclareOption{letterpaper}
{\setlength\paperheight {11in}%
\setlength\paperwidth {8.5in}}
\DeclareOption{a4paper}
{\setlength\paperheight {297mm}%
\setlength\paperwidth {210mm}}
\ExecuteOptions{letterpaper}
\ProcessOptions
% \end{macrocode}
% Finally, we input all the usual size settings. There is no sense to use something else,
% and we initialize the pagenumbering counter and tell it to output the numbers in arabic
% numerals (otherwise label and reference do not work).
% \begin{macrocode}
\input{size10.clo}
\pagenumbering{roman}
%</cls>
% \end{macrocode}
% Now comes the equivalent for {\latexml}: this is something that we will have throughout
% this document. Every part of the {\TeX/\LaTeX} implementation has a {\latexml}
% equivalent. We keep them together to ensure that they do not get out of sync.
% \begin{macrocode}
%<*ltxml>
# -*- CPERL -*-
package LaTeXML::Package::Pool;
use strict;
use LaTeXML::Package;
RequirePackage('keyval');
% \end{macrocode}
% We set up the necessary namespaces, the first one is the default one for {\cnxml}
% \begin{macrocode}
RegisterNamespace('cnx'=>"http://cnx.rice.edu/cnxml");
RegisterNamespace('md'=>"http://cnx.rice.edu/mdml/0.4");
RegisterNamespace('bib'=>"http://bibtexml.sf.net/");
RegisterNamespace('m'=>"http://www.w3.org/1998/Math/MathML");
% \end{macrocode}
% For {\latexml} we also have to set up the correct document type information. The first line
% gives the root element. The second gives the public identifier for the CNX DTD, then we
% have its URL, and finally the CNX namespace.
% \begin{macrocode}
DocType("cnx:document",
"-//CNX//DTD CNXML 0.5 plus LaTeXML//EN",
"../dtd/cnxml+ltxml.dtd",
'#default'=>"http://cnx.rice.edu/cnxml",
'md'=>"http://cnx.rice.edu/mdml/0.4",
'bib'=>"http://bibtexml.sf.net/",
'm'=>"http://www.w3.org/1998/Math/MathML",
'ltx'=>"http://dlmf.nist.gov/LaTeXML");
% \end{macrocode}
%
% And finally, we need to set up the counters for itemization, since we are defining a
% class file from scratch.\ednote{this will have to change, when Bruce updates to the next
% version (0.6?)}
%
% \begin{macrocode}
NewCounter('@itemizei', 'document', idprefix=>'I');
NewCounter('@itemizeii', '@itemizei', idprefix=>'I');
NewCounter('@itemizeiii', '@itemizeii', idprefix=>'I');
NewCounter('@itemizeiv', '@itemizeiii',idprefix=>'I');
NewCounter('@itemizev', '@itemizeiv', idprefix=>'I');
NewCounter('@itemizevi', '@itemizev', idprefix=>'I');
NewCounter('enumi', '@itemizei', idprefix=>'i');
NewCounter('enumii', '@itemizeii', idprefix=>'i');
NewCounter('enumiii','@itemizeiii', idprefix=>'i');
NewCounter('enumiv', '@itemizeiv', idprefix=>'i');
# A couple of more levels, since we use these for ID's!
NewCounter('enumv', '@itemizev', idprefix=>'i');
NewCounter('enumvi', '@itemizevi', idprefix=>'i');
DefMacro('\theenumi', '\arabic{enumi}');
DefMacro('\theenumii', '\alph{enumii}');
DefMacro('\theenumiii', '\roman{enumiii}');
DefMacro('\theenumiv', '\Alph{enumiv}');
NewCounter('equation', 'document', idprefix=>'E');
DefMacro('\theequation', '\arabic{equation}');
DefMacro('\textwidth','16cm');
% \end{macrocode}
%
% And another thing that is now needed:
%
% \begin{macrocode}
Let('\thedocument@ID','\@empty');
%</ltxml>
% \end{macrocode}
%
% \subsection{Document Structure}
%
% Now, we start with the document structure markup. The |cnxmodule| environment does not
% add anything to the {\LaTeX} output, it's attributes only show up in the {\xml}. There
% we have a slight complication: we have to put an |id| attribute on the |document|
% element in {\cnxml}, but we cannot redefine the |document| environment in
% {\LaTeX}. Therefore we specify the information in the |cnxmodule| environment. This
% means however that we have to put in on the |document| element when we are already past
% this. The solution here is that when we parse the |cnxmodule| environement, we store the
% value and put it on the |document| element when we leave the |document| environment
% (thanks for Ioan Sucan for the code).
%
% \begin{environment}{cnxmodule}
% \begin{macrocode}
%<*cls>
\define@key{cnxmodule}{name}{\def\cnx@title{#1}}
\define@key{cnxmodule}{id}{}
\newenvironment{cnxmodule}[1][]{\setkeys{cnxmodule}{#1}}{}
%</cls>
%<*ltxml>
DefKeyVal('cnxmodule','name','Semiverbatim');
DefKeyVal('cnxmodule','id','Semiverbatim');
DefEnvironment('{document}','<cnx:document>#body</cnx:document>',
beforeDigest=> sub { AssignValue(inPreamble=>0); },
afterDigest=> sub { $_[0]->getGullet->flush; return; });
DefEnvironment('{cnxmodule} OptionalKeyVals:cnxmodule',
"<cnx:name>&KeyVal('#1','name')</cnx:name>\n#body\n",
afterDigestBegin => sub {
AssignValue('cnxmodule_id',
KeyVal($_[1]->getArg(1), 'id')->toString,
'global');
});
Tag('cnx:document', afterClose => sub {
$_[1]->setAttribute('id', LookupValue('cnxmodule_id'));
});
%</ltxml>
% \end{macrocode}
% \end{environment}
%
% \begin{environment}{ccontent}
% The |ccontent| environment is only used for transformation. Its optional |id| attribute
% is not taken up in the {\LaTeX} bindings.
% \begin{macrocode}
%<*cls>
\newenvironment{ccontent}{}{}
%</cls>
%<*ltxml>
DefEnvironment('{ccontent}',"<cnx:content>#body</cnx:content>");
%</ltxml>
% \end{macrocode}
% \end{environment}
%
% \begin{environment}{c*section}
% The sectioning environments employ the obvious nested set of counters.
% \begin{macrocode}
%<*cls>
\newcounter{section}
\define@key{sectioning}{id}{}
\newenvironment{csection}[2][]%
{\stepcounter{section}\strut\\[1.5ex]\noindent%
{\Large\bfseries\arabic{section}.~{#2}}\\[1.5ex]
\setkeys{sectioning}{#1}}
{}
\newcounter{subsection}[section]
\newenvironment{csubsection}[2][]
{\refstepcounter{subsection}\strut\\[1ex]\noindent%
{\large\bfseries{\arabic{section}.\arabic{subsection}.~#2\\[1ex]}}%
\setkeys{sectioning}{#1}}%
{}
\newcounter{subsubsection}[subsection]
\newenvironment{csubsubsection}[2][]
{\refstepcounter{subsubsection}\strut\\[.5ex]\noindent
{\bfseries\arabic{section}.\arabic{subsection}.\arabic{subsubsecction}~#2\\[.5ex]}%
\setkeys{sectioning}{#1}}{}
%</cls>
%<*ltxml>
DefKeyVal('sectioning','id','Semiverbatim');
DefEnvironment('{csection}OptionalKeyVals:sectioning{}',
"<cnx:section %&KeyVals(#1)>\n"
. "?#2(<cnx:name>#2</cnx:name>\n)()"
. "#body\n</cnx:section>\n");
DefEnvironment('{csubsection}OptionalKeyVals:sectioning{}',
"<cnx:section %&KeyVals(#1)>\n"
. "?#2(<cnx:name>#2</cnx:name>\n)()"
. "#body\n</cnx:section>\n");
DefEnvironment('{csubsubsection}OptionalKeyVals:sectioning{}',
"<cnx:section %&KeyVals(#1)>\n"
. "?#2(<cnx:name>#2</cnx:name>\n)()"
. "#body\n</cnx:section>\n");
%</ltxml>
% \end{macrocode}
% \end{environment}
%
% \begin{environment}{cpara}
% For the |<cnx:para>| element we have to do some work, since we want them to be
% numbered. This handline is adapted from Bruce Miller's |LaTeX.ltxml|
% numberd.
% \begin{macrocode}
%<*cls>
\define@key{para}{id}{}
\newenvironment{cpara}[1][]{\setkeys{para}{#1}}{\par}
%</cls>
%<*ltxml>
DefKeyVal('para','id','Semiverbatim');
DefEnvironment('{cpara} OptionalKeyVals:para','<cnx:para %&KeyVals(#1)>#body</cnx:para>');
sub number_para {
my($document,$node,$whatsit)=@_;
# Get prefix from first parent with an id.
my(@parents)=$document->findnodes('ancestor::*[@id]',$node); # find 1st id'd parent.
my $prefix= (@parents ? $parents[$#parents]->getAttribute('id')."." : '');
# Get the previous number within parent; Worried about intervening elements around para's, but...
my(@siblings)=$document->findnodes("preceding-sibling::cnx:para",$node);
my $n=1;
$n = $1+1 if(@siblings && $siblings[$#siblings]->getAttribute('id')=~/(\d+)$/);
$node->setAttribute(id=>$prefix."p$n"); }
Tag('cnx:para',afterOpen=>\&number_para);
DefConstructor('\par',sub { $_[0]->maybeCloseElement('cnx:para'); },alias=>"\\par\n");
Tag('cnx:para', autoClose=>1, autoOpen=>1);
%</ltxml>
% \end{macrocode}
% \end{environment}
%
% \begin{environment}{cnote}
% \begin{macrocode}
%<*cls>
\define@key{note}{id}{}
\define@key{note}{type}{\def\note@type{#1}}
\newenvironment{cnote}[1][]%
{\setkeys{note}{#1}\par\noindent\strut\hfill\begin{minipage}{10cm}{\bfseries\note@type}:~}%
{\end{minipage}\hfill\strut\par}
%</cls>
%<*ltxml>
DefKeyVal('note','id','Semiverbatim');
DefKeyVal('note','type','Semiverbatim');
DefEnvironment('{cnote}OptionalKeyVals:note','<cnx:note %&KeyVals(#1)>#body</cnx:note>');
%</ltxml>
% \end{macrocode}
% \end{environment}
%
% \subsection{Mathematics}
%
% \begin{environment}{cequation}
% \begin{macrocode}
%<*cls>
\define@key{equation}{id}{}
\newenvironment{cequation}[1][]%
{\setkeys{equation}{#1}\begin{displaymath}}
{\end{displaymath}}
%</cls>
%<*ltxml>
DefKeyVal('equation','id','Semiverbatim');
DefEnvironment('{cequation} OptionalKeyVals:equation',
"<cnx:equation %&KeyVals(#1)>"
. "<ltx:Math mode='display'>"
. "<ltx:XMath>#body</ltx:XMath>"
. "</ltx:Math></cnx:equation>",
mode=>'display_math');
%</ltxml>
% \end{macrocode}
% \end{environment}
%
% \subsection{Rich Text}
%
% In this section, we redefine some of {\LaTeX} commands that have their counterparts in
% {\cnxml}.
%
% \begin{environment}{quote}
% \begin{macrocode}
%<*cls>
\define@key{cquote}{id}{}
\define@key{cquote}{type}{}
\define@key{cquote}{src}{}
\newenvironment{cquote}[1][]{%
\setkeys{cquote}{#1}\begin{center}\begin{minipage}{.8\textwidth}}{\end{minipage}\end{center}}
%</cls>
%<*ltxml>
DefKeyVal('cquote','id','Semiverbatim');
DefKeyVal('cquote','type','Semiverbatim');
DefKeyVal('cquote','src','Semiverbatim');
DefEnvironment('{cquote} OptionalKeyVals:cquote',
"<cnx:quote %&KeyVals(#1)>#body</cnx:quote>");
%</ltxml>
% \end{macrocode}
% \end{environment}
%
% \begin{environment}{footnote}
% \begin{macrocode}
%<*ltxml>
DefConstructor('\footnote[]{}',"<cnx:note type='foot'>#2</cnx:note>");
%</ltxml>
% \end{macrocode}
% \end{environment}
%
% \begin{environment}{emph}
% \begin{macrocode}
%<*ltxml>
DefConstructor('\emph{}',"<cnx:emphasis>#1</cnx:emphasis>");
%</ltxml>
% \end{macrocode}
% \end{environment}
%
% \begin{environment}{displaymath, eqnarray}
% We redefine the abbreviate display math envionment and the |eqnarray| and |eqnarray*|
% environments to use the {\cnxml} equation tags, everything else stays the same.
%
% \begin{macrocode}
%<*ltxml>
DefConstructor('\[',
"<cnx:equation id='#id'>"
. "<ltx:Math mode='display'>"
. "<ltx:XMath>"
. "#body"
. "</ltx:XMath>"
. "</ltx:Math>"
."</cnx:equation>",
beforeDigest=> sub{ $_[0]->beginMode('display_math'); },
captureBody=>1,
properties=> sub { RefStepID('equation') });
DefConstructor('\]' ,"",beforeDigest=> sub{ $_[0]->endMode('display_math'); });
%</ltxml>
% \end{macrocode}
% \end{environment}
%
% \begin{environment}{displaymath}
% We redefine the abbreviate display math envionment to use the {\cnxml} equation tags,
% everything else stays the same.\ednote{check {\tt{LaTeX.ltxml}} frequently and try to
% keep in sync, it would be good, if the code in LaTeXML.ltxml could be modularized,
% so that the {\tt{cnx}}/{\tt{ltx}} namespace differences could be relegated to
% config options}
%
% \begin{macrocode}
%<*ltxml>
DefConstructor('\[',
"<cnx:equation id='#id'>"
. "<ltx:Math mode='display'>"
. "<ltx:XMath>"
. "#body"
. "</ltx:XMath>"
. "</ltx:Math>"
."</cnx:equation>",
beforeDigest=> sub{ $_[0]->beginMode('display_math'); },
captureBody=>1,
properties=> sub { RefStepID('equation') });
DefConstructor('\]' ,"",beforeDigest=> sub{ $_[0]->endMode('display_math'); });
DefMacro('\eqnarray', '\@@eqnarray\@start@alignment');
DefMacro('\endeqnarray', '\@finish@alignment\end@eqnarray');
DefMacro('\csname eqnarray*\endcsname', '\@@eqnarray*\@start@alignment');
DefMacro('\csname endeqnarray*\endcsname', '\@finish@alignment\end@eqnarray');
DefConstructor('\@@eqnarray OptionalMatch:* AlignmentBody:\end@eqnarray',
sub {
my($document,$star,$body,%props)=@_;
$document->openElement('cnx:equation',refnum=>$props{refnum},id=>$props{id});
$document->openElement('ltx:Math',mode=>'display');
$document->openElement('ltx:XMath');
constructAlignment($document,$body,attributes=>{name=>'eqnarray'});
$document->closeElement('ltx:XMath');
$document->closeElement('ltx:Math');
$document->closeElement('cnx:equation'); },
mode=>'display_math',
beforeDigest=>sub { alignmentBindings('rcl'); },
properties=> sub { ($_[1] ? RefStepID('equation') : RefStepCounter('equation')); },
afterDigest=>sub {
$_[1]->setProperty(body=>$_[1]->getArg(2));}, # So we get TeX
reversion=>'\begin{eqnarray#1}#2\end{eqnarray#1}');
%</ltxml>
% \end{macrocode}
% \end{environment}
%
% \begin{environment}{displaymath}
% We redefine the abbreviate display math envionment to use the {\cnxml} equation tags,
% everything else stays the same.\ednote{check {\tt{LaTeX.ltxml}} frequently and try to
% keep in sync, it would be good, if the code in LaTeXML.ltxml could be modularized,
% so that the {\tt{cnx}}/{\tt{ltx}} namespace differences could be relegated to
% config options}
%
% \begin{macrocode}
%<*cls>
\newcommand{\litem}[2][]{\item[#1]\label{#2}}
%</cls>
%<*ltxml>
Tag('cnx:item', autoClose=>1);
DefConstructor('\item[]',"<cnx:item>?#1(<cnx:name>#1</cnx:name>)");
DefConstructor('\litem[]{}',"<cnx:item id='#2'>?#1(<cnx:name>#1</cnx:name>)");
DefConstructor('\itemize@item[]',
"<cnx:item id='#id'>?#1(<cnx:name>#1</cnx:name>)",
properties=>sub{ RefStepItemCounter(); });
DefConstructor('\enumerate@item[]',
"<cnx:item id='#id'>?#1(<cnx:name>#1</cnx:name>)",
properties=>sub{ RefStepItemCounter(); });
DefConstructor('\description@item[]',
"<cnx::item id='#id'>?#1(<cnx:name>#1</cnx:name>)",
properties=>sub{ RefStepItemCounter(); });
AssignValue(itemlevel=>0);
DefEnvironment('{itemize}',
"<cnx:list id='#id' type='itemize'>#body</cnx:list>",
properties=>sub { beginItemize('itemize'); });
DefEnvironment('{enumerate}',
"<cnx:list type='enumerate' id='#id'>#body</cnx:list>",
properties=>sub { beginItemize('enumerate'); });
DefEnvironment('{description}',
"<cnx:list type='description' id='#id'>#body</cnx:list>",
properties=>sub { beginItemize('description'); });
%</ltxml>
% \end{macrocode}
% \end{environment}
%
% The next set of commands and environemnts are largely presentational, so we just skip
% them.
%
% \begin{macrocode}
%<*ltxml>
DefEnvironment('{center}','#body');
DefEnvironment('{minipage}{}','#body');
DefEnvironment('{small}','#body');
DefEnvironment('{footnotesize}','#body');
DefEnvironment('{tiny}','#body');
DefEnvironment('{scriptsize}','#body');
%</ltxml>
% \end{macrocode}
%
% \begin{macrocode}
%<*ltxml>
DefConstructor('\ref Semiverbatim', "<cnx:cnxn target='#1'>&LookupValue('LABEL@#1')</cnx:cnxn>");
%</ltxml>
% \end{macrocode}
%
% \subsection{Statements}
%
% \begin{environment}{cexample}
% \begin{macrocode}
%<*cls>
\define@key{example}{id}{}
\define@key{example}{name}{\def\example@name{#1}}
\newenvironment{cexample}[1][]{\setkeys{example}{#1}
{\@ifundefined{example@name}{}{\noindent\bfseries{\example@name}}}}
{}
%</cls>
%<*ltxml>
DefKeyVal('example','id','Semiverbatim');
DefEnvironment('{cexample}OptionalKeyVals:example',
"<cnx:example %&KeyVals(#1)>#body</cnx:example>");
%</ltxml>
% \end{macrocode}
% \end{environment}
%
% \begin{environment}{cexercise}
% The |cexercise|, |cproblem| and |csolution| environments are very simple to set up for
% {\LaTeX}. For the {\latexml} side, we simplify matters considerably for the moment by
% restricting the possibilities we have on the {\cnxml} side: We assume that the content
% is just one |<cnx:para>| element for the |<cnx:problem>| and |<cnx:solution>|
% elements.\ednote{relax this when we have automated the generation of {\tt{cnx:para}}
% elements}
% \begin{macrocode}
%<*cls>
\newcounter{cexercise}
\define@key{cexercise}{id}{}
\define@key{cexercise}{name}{\def\cexercise@name{#1}}
\newenvironment{cexercise}[1][]{\setkeys{cexercise}{#1}
{\@ifundefined{cexercise@name}{}{\stepcounter{cexercise}\noindent\bfseries{\cexercise@name~\arabic{cexercise}}}}}
{}
\define@key{cproblem}{id}{}
\newenvironment{cproblem}[1][]{\setkeys{cproblem}{#1}}{}{}
\define@key{csolution}{id}{}
\newenvironment{csolution}[1][]{\setkeys{csolution}{#1}}{\par\noindent\bfseries{Solution}}{}
%</cls>
%<*ltxml>
DefKeyVal('cexercise','id','Semiverbatim');
DefKeyVal('cexercise','name','Semiverbatim');
DefEnvironment('{cexercise}OptionalKeyVals:exercise',
"<cnx:exercise ?&KeyVal(#1,'id')(id='&KeyVal(#1,'id')')()>"
. "#body"
. "</cnx:exercise>");
DefKeyVal('cproblem','id','Semiverbatim');
DefKeyVal('cproblem','name','Semiverbatim');
DefEnvironment('{cproblem}OptionalKeyVals:cproblem',
"<cnx:problem ?&KeyVal(#1,'id')(id='&KeyVal(#1,'id')')()>"
. "?&KeyVal(#1,'name')(<cnx:name>&KeyVal(#1,'name')</cnx:name>\n)()"
. "#body"
. "</cnx:problem>");
DefKeyVal('csolution','id','Semiverbatim');
DefKeyVal('csolution','name','Semiverbatim');
DefEnvironment('{csolution}OptionalKeyVals:cproblem',
"<cnx:solution ?&KeyVal(#1,'id')(id='&KeyVal(#1,'id')')()>"
. "?&KeyVal(#1,'name')(<cnx:name>&KeyVal(#1,'name')</cnx:name>\n)()"
. "#body"
. "</cnx:solution>");
%</ltxml>
% \end{macrocode}
% \end{environment}
%
% \begin{environment}{crule}
% \begin{macrocode}
%<*cls>
\define@key{rule}{id}{}
\define@key{rule}{name}{\def\rule@name{#1}}
\define@key{rule}{type}{\def\rule@type{#1}}
\newenvironment{crule}[1][]{\setkeys{rule}{#1}%
{\noindent\bfseries{\rule@type:}\@ifundefined{rule@name}{}{~(\rule@name)}}}%
{}
%</cls>
%<*ltxml>
DefKeyVal('rule','id','Semiverbatim');
DefKeyVal('rule','name','Semiverbatim');
DefKeyVal('rule','type','Semiverbatim');
DefEnvironment('{crule}OptionalKeyVals:rule',
"<cnx:rule ?&KeyVal(#1,'id')(id='&KeyVal(#1,'id')')() type='&KeyVal(#1,'type')'>\n"
. "?&KeyVal(#1,'name')(<cnx:name>&KeyVal(#1,'name')</cnx:name>\n)()"
. "\n#body\n"
. "</cnx:rule>\n");
%</ltxml>
% \end{macrocode}
% \end{environment}
%
% \begin{environment}{statement}
% \begin{macrocode}
%<*cls>
\define@key{statement}{id}{}
\newenvironment{statement}[1][]{\setkeys{statement}{#1}}{}
%</cls>
%<*ltxml>
DefKeyVal('statement','id','Semiverbatim');
DefEnvironment('{statement}OptionalKeyVals:statement','<cnx:statement %&KeyVals(#1)>#body</cnx:statement>');
%</ltxml>
% \end{macrocode}
% \end{environment}
%
% \begin{environment}{proof}
% \begin{macrocode}
%<*cls>
\define@key{proof}{id}{}
\newenvironment{proof}[1][]{\setkeys{proof}{#1}}{}
%</cls>
%<*ltxml>
DefKeyVal('proof','id','Semiverbatim');
DefEnvironment('{proof}OptionalKeyVals:proof','<cnx:proof %&KeyVals(#1)>#body</cnx:proof>');
%</ltxml>
% \end{macrocode}
% \end{environment}
%
% \begin{environment}{definition}
% \begin{macrocode}
%<*cls>
\define@key{definition}{term}{}
\define@key{definition}{id}{}
\define@key{definition}{seealso}{}
\newenvironment{definition}[1][]{\setkeys{definition}{#1}{\noindent\bfseries{Definition:}}}{}
%</cls>
%<*ltxml>
DefKeyVal('definition','id','Semiverbatim');
DefKeyVal('definition','term','Semiverbatim');
DefKeyVal('definition','seealso','Semiverbatim');
DefEnvironment('{definition}OptionalKeyVals:definition',
"<cnx:definition ?&KeyVal(#1,'id')(id='&KeyVal(#1,'id')')()>\n"
. "?&KeyVal(#1,'term')(<cnx:term>&KeyVal(#1,'term')</cnx:term>\n)()"
. "\n#body\n"
. "?&KeyVal(#1,'seealso')(<cnx:seealso><cnx:term>&KeyVal(#1,'term')</cnx:term></cnx:seealso>\n)()"
. "</cnx:definition>\n");
%</ltxml>
% \end{macrocode}
% \end{environment}
%
% \begin{environment}{cmeaning}
% \begin{macrocode}
%<*cls>
\define@key{meaning}{id}{}
\newenvironment{cmeaning}[1][]{\setkeys{meaning}{#1}}{}
%</cls>
%<*ltxml>
DefKeyVal('meaning','id','Semiverbatim');
DefEnvironment('{cmeaning}OptionalKeyVals:meaning','<cnx:meaning %&KeyVals(#1)>#body</cnx:meaning>');
%</ltxml>
% \end{macrocode}
% \end{environment}
%
% \subsection{Conexxions}
%
% \begin{macro}{cnxn}
% \begin{macrocode}
%<*cls>
\define@key{cnxn}{document}{\def\cnxn@doc{#1}}
\define@key{cnxn}{target}{\def\cnxn@target{#1}}
\define@key{cnxn}{strength}{}
\newcommand{\cnxn}[2][]% keys, link text
{\setkeys{cnxn}{#1}{\underline{#2}}\footnote{{\ttfamily\@ifundefined{cnxn@doc}{\cnxn@doc}{}\#\cnxn@target}}}
\newcommand\@makefntext[1]{\parindent 1em\noindent\hb@xt@1.8em{\hss\@makefnmark}#1}
%</cls>
%<*ltxml>
DefKeyVal('cnxn','document','Semiverbatim');
DefKeyVal('cnxn','target','Semiverbatim');
DefKeyVal('cnxn','strength','Semiverbatim');
DefConstructor('\cnxn OptionalKeyVals:cnxn {}','<cnx:cnxn %&KeyVals(#1)>#1</cnx:cnxn>');
%</ltxml>
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{link}
% \begin{macrocode}
%<*cls>
\define@key{link}{src}{}
\newcommand{\link}[2][]{\setkeys{link}{#1}\underline{#2}}
%</cls>
%<*ltxml>
DefKeyVal('link','src','Semiverbatim');
DefConstructor('\link OptionalKeyVals:link {}','<cnx:link %&KeyVals(#1)>#2</cnx:link>');
%</ltxml>
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{cfigure}
% The |cfigure| only gives us one of the possible instances of the |<figure>|
% element\ednote{extend that}.\ednote{do more about required and optional keys in
% arguments.} In {\LaTeX}, we just pipe the size information through to
% |includegraphics|, in {\latexml}, we construct the {\cnxml} structure\ednote{what do
% we do with the graphicx information about size,... CSS?}
% \begin{macrocode}
%<*cls>
\define@key{cfigure}{id}{\def\cf@id{#1}}
\define@key{cfigure}{type}{}
\define@key{cfigure}{caption}{\def\cf@caption{#1}}
\newcounter{figure}
\newcommand{\cfigure}[3][]{% cnx_keys, graphicx_keys, path
\begin{center}%
\includegraphics[#2]{#3}%
\setkeys{cfigure}{#1}%
\@ifundefined{cfigure@caption}{}{{\par\noindent Figure\refstepcounter{figure}} {\arabic{figure}}: \cf@caption%
\protected@edef\@currentlabel{\arabic{figure}}%
\@ifundefined{cf@id}{}{\label{\cf@id}}}%
\end{center}}
%</cls>
%<*ltxml>
DefKeyVal('cfigure','id','Semiverbatim');
DefKeyVal('cfigure','name','Semiverbatim');
DefKeyVal('cfigure','type','Semiverbatim');
DefKeyVal('cfigure','caption','Semiverbatim');
DefConstructor('\cfigure OptionalKeyVals:cfigure Semiverbatim Semiverbatim',
"<cnx:figure ?&KeyVal(#1,'id')(id='&KeyVal(#1,'id')')()>"
. "?&KeyVal(#1,'name')(<cnx:name>&KeyVal(#1,'name')</cnx:name>\n)()"
. "<cnx:media type='&KeyVal(#1,'type')' src='#3'/>"
. "?&KeyVal(#1,'caption')(<cnx:caption>&KeyVal(#1,'caption')</cnx:caption>\n)()"
. "</cnx:figure>");
%</ltxml>
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{ccite}
% \begin{macrocode}
%<*cls>
\define@key{ccite}{src}{}
\newcommand{\ccite}[2][]{\setkeys{ccite}{#1}\emph{#2}}
%</cls>
%<*ltxml>
DefKeyVal('ccite','src','Semiverbatim');
DefConstructor('\ccite OptionalKeyVals:ccite {}','<cnx:cite %&KeyVals(#1)>#2</cnx:cite>');
%</ltxml>
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{term}
% \begin{macrocode}
%<*cls>
\newcommand{\term}[1]{{\bfseries\underline{#1}}}
%</cls>
%<*ltxml>
DefConstructor('\term[]{}',"<cnx:term>#2</cnx:term>");
%</ltxml>
% \end{macrocode}
% \end{macro}
%
% \subsection{Metadata}
%
% \begin{environment}{metadata}
% \begin{macrocode}
%<*cls>
\define@key{metadata}{version}{}
\define@key{metadata}{created}{}
\define@key{metadata}{revised}{}
\newsavebox{\metadatabox}
\newenvironment{metadata}[1][]%
{\noindent\hfill\begin{lrbox}{\metadatabox}
\begin{minipage}{.8\textwidth}%
{\Large\bfseries CNX Module: \cnx@title\hfill\strut}\\[2ex]}%
{\end{minipage}\end{lrbox}\fbox{\usebox\metadatabox}\hfill}
% \newenvironment{metadata}[1][]%
% {\noindent\strut\hfill\begin{lrbox}{\metadatabox}\begin{minipage}{10cm}%
% {\strut\hfill\Large\bfseries CNX Module: \cnx@title\hfill\strut}\\[2ex]}%
% {\end{minipage}\end{lrbox}\fbox{\usebox\metadatabox}\hfill\strut\\[3ex]}
%</cls>
%<*ltxml>
DefKeyVal('metadata','version','Semiverbatim');
DefKeyVal('metadata','created','Semiverbatim');
DefKeyVal('metadata','revised','Semiverbatim');
DefEnvironment('{metadata}OptionalKeyVals:metadata',
"<cnx:metadata>\n"
. "<md:version>&KeyVal('#1','version')</md:version>\n"
. "<md:created>&KeyVal('#1','created')</md:created>\n"
. "<md:revised>&KeyVal('#1','revised')</md:revised>\n"
. "#body\n"
. "</cnx:metadata>");
%</ltxml>
% \end{macrocode}
% \end{environment}
%
% \begin{environment}{authorlist}
% \begin{macrocode}
%<*cls>
\newenvironment{authorlist}{{\bfseries{Authors}:~}}{\\[1ex]}
%</cls>
%<*ltxml>
DefEnvironment('{authorlist}',"<md:authorlist>#body</md:authorlist>");
%</ltxml>
% \end{macrocode}
% \end{environment}
%
% \begin{environment}{maintainerlist}
% \begin{macrocode}
%<*cls>
\newenvironment{maintainerlist}{{\bfseries{Maintainers}:~}}{\\[1ex]}
%</cls>
%<*ltxml>
DefEnvironment('{maintainerlist}',"<md:maintainerlist>#body</md:maintainerlist>");
%</ltxml>
% \end{macrocode}
% \end{environment}
%
% \begin{macro}{cnxauthor}
% \begin{macrocode}
%<*cls>
\define@key{auth}{id}{}
\define@key{auth}{honorific}{\def\auth@honorific{#1}}
\define@key{auth}{firstname}{\def\auth@first{#1}}
\define@key{auth}{other}{\def\auth@other{#1}}
\define@key{auth}{surname}{\def\auth@sur{#1}}
\define@key{auth}{lineage}{\def\auth@line{#1}}
\define@key{auth}{email}{}
\newcommand{\cnxauthor}[1][]{\setkeys{auth}{#1}\auth@first~\auth@sur,}
%</cls>
%<*ltxml>
DefKeyVal('auth','id','Semiverbatim');
DefKeyVal('auth','firstname','Semiverbatim');
DefKeyVal('auth','surname','Semiverbatim');
DefKeyVal('auth','email','Semiverbatim');
DefConstructor('\cnxauthor OptionalKeyVals:auth',
"<md:author id='&KeyVal('#1','id')'>\n"
. "?&KeyVal(#1,'honorific')(<md:honorific>&KeyVal('#1','honorific')</md:honorific>\n)()"
. "?&KeyVal(#1,'firstname')(<md:firstname>&KeyVal('#1','firstname')</md:firstname>\n)()"
. "?&KeyVal(#1,'other')(<md:other>&KeyVal('#1','other')</md:other>\n)()"
. "?&KeyVal(#1,'surname')(<md:surname>&KeyVal('#1','surname')</md:surname>\n)()"
. "?&KeyVal(#1,'lineage')(<md:lineage>&KeyVal('#1','lineage')</md:lineage>\n)()"
. "?&KeyVal(#1,'email')(<md:email>&KeyVal('#1','email')</md:email>\n)()"
. "</md:author>\n");
%</ltxml>
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{maintainer}
% \begin{macrocode}
%<*cls>
\newcommand{\maintainer}[1][]{\setkeys{auth}{#1}\auth@first~\auth@sur,}
%</cls>
%<*ltxml>
DefConstructor('\maintainer OptionalKeyVals:auth',
"<md:maintainer id='&KeyVal('#1','id')'>\n"
. "?&KeyVal(#1,'honorific')(<md:honorific>&KeyVal('#1','honorific')</md:honorific>\n)()"
. "?&KeyVal(#1,'firstname')(<md:firstname>&KeyVal('#1','firstname')</md:firstname>\n)()"
. "?&KeyVal(#1,'other')(<md:other>&KeyVal('#1','other')</md:other>\n)()"
. "?&KeyVal(#1,'surname')(<md:surname>&KeyVal('#1','surname')</md:surname>\n)()"
. "?&KeyVal(#1,'lineage')(<md:lineage>&KeyVal('#1','lineage')</md:lineage>\n)()"
. "?&KeyVal(#1,'email')(<md:email>&KeyVal('#1','email')</md:email>\n)()"
. "</md:maintainer>\n");
%</ltxml>
% \end{macrocode}
% \end{macro}
%
% \begin{environment}{keywordlist}
% \begin{macrocode}
%<*cls>
\newenvironment{keywordlist}{\bfseries{Keywords}:~}{\\[1ex]}
%</cls>
%<*ltxml>
DefEnvironment('{keywordlist}',"<md:keywordlist>\n#body\n</md:keywordlist>");
%</ltxml>
% \end{macrocode}
% \end{environment}
%
% \begin{macro}{keyword}
% \begin{macrocode}
%<*cls>
\newcommand{\keyword}[1]{#1,}
%</cls>
%<*ltxml>
DefConstructor('\keyword {}',"<md:keyword>#1</md:keyword>");
%</ltxml>
% \end{macrocode}
% \end{macro}
%
% \begin{environment}{cnxabstract}
% \begin{macrocode}
%<*cls>
\newenvironment{cnxabstract}%
{\par\noindent\strut\hfill\begin{minipage}{10cm}{\bfseries{Abstract}:~}}%
{\end{minipage}\hfill}
%</cls>
%<*ltxml>
DefEnvironment('{cnxabstract} OptionalKeyVals:cnxabstract',
"<md:abstract>\n#body\n</md:abstract>\n");
1;
%</ltxml>
% \end{macrocode}
% \end{environment}
% \Finale
\endinput
% \iffalse
%%% Local Variables:
%%% mode: doctex
%%% TeX-master: t
%%% End:
% \fi
|