-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcnltx_en.tex
2946 lines (2704 loc) · 123 KB
/
cnltx_en.tex
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
% arara: pdflatex: { shell: on }
% arara: pdflatex
% arara: biber
% arara: pdflatex
% arara: pdflatex
% --------------------------------------------------------------------------
% the CNLTX bundle
%
% LaTeX source code and output
%
% --------------------------------------------------------------------------
% Clemens Niederberger
% Web: https://github.com/cgnieder/cnltx/
% E-Mail: [email protected]
% --------------------------------------------------------------------------
% Copyright 2013--2019 Clemens Niederberger
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Clemens Niederberger.
% --------------------------------------------------------------------------
% If you have any ideas, questions, suggestions or bugs to report, please
% feel free to contact me.
% --------------------------------------------------------------------------
\PassOptionsToPackage{ngerman,english}{babel}
\documentclass[load-preamble+]{cnltx-doc}
\usepackage[utf8]{inputenc}
\usepackage{varioref}
\usepackage{amsmath}
\usepackage{array,booktabs}
\usepackage{tikz}
\usetikzlibrary{chains}
\setcnltx{
name = cnltx ,
title = the cnltx bundle ,
version = \csname cnltx@@version\endcsname ,
date = \csname cnltx@@date\endcsname ,
subtitle = Documentation for \LaTeXe\ Packages or Classes ,
info = \LaTeX\ tools and documenting facilities the
\texorpdfstring{\textsc{cn}}{CN} way ,
authors = Clemens Niederberger ,
email = [email protected] ,
url = https://github.com/cgnieder/cnltx ,
abstract = {%
A versatile bundle of packages and classes for consistent formatting of
control sequences, package options, source code examples, and writing a
package manual (including an index containing the explained control
sequences, options, \ldots).\par
The bundle also provides several other small ideas of mine such as a
mechansim for providing abbreviations \etc. Not at least it provides a
number of programming tools.%
} ,
index-setup = { othercode=\footnotesize,level=\section},
add-cmds = {
% internal macros:
cnltx@babel@options,
cnltx@bibtex@listings@style,
cnltx@caption@font, cnltx@captionlabel@font,
cnltx@define@colorscheme,
cnltx@gobble,
cnltx@ifcounter,
cnltx@ifisnum,
cnltx@ifpunctuation,
cnltx@ifsym,
cnltx@listings@style, cnltx@load@module, cnltx@load@modules,
cnltx@make@active, cnltx@make@letter, cnltx@make@other,
cnltx@makeindex@listings@style,
cnltx@mdframed@options,
cnltx@restore@catcode, cnltx@restore@catcodes,
cnltx@save@catcode, cnltx@save@catcodes,
cnltx@set@catcode, cnltx@set@catcodes,
cnltx@scrartcl@options,
cnltx@trailpunct,
cnltx@treat@lst@index,
% official macros:
AD, AM, BC,
changedversion, cls, cnltxacronym, cnltxat, cnltxbang, cnltxequal, code,
codefont, command, cs, csidx, ctan, CTAN, CTANurl,
darg, DeclareCounterRepresentation, Default, default, definecolorscheme,
dsh,
eg, env, envidx, environment, expandable,
iftest, indexcs, inputexample, inputsidebyside, inputsourcecode,
key, keybool, keychoice, keyval,
lppl, LPPL,
marg, Marg, module, Module,
name, newabbr, newarg, newcounterrepresentation, newname, newnote,
newpackagename, newinputsourcefilecmd, newsourcecodeenv,
oarg, opt, option,
PM, pkg, providecounterrepresentation,
renewcounterrepresentation,
sarg, setcnltx, sinceversion, sourceformat,
unexpandable, usf, usw,
vgl, Vgl,
zB, ZB
},
add-silent-cmds = {
@foo,
ab,AB, at,
carlisle, cd, chead, circled,circlenumber, cnltx,
foo, foothree,
GetTranslation,
href,
KOMAoptions,
lipsum,
minusone,multoffourrm,
nohyperpage,
pdf@shellescape,
superiors@spaced,
textsu,
twodigits
} ,
add-envs = {
commands,
environments,
example,
options,
sidebyside,sourcecode
},
add-frame-options = {
innerleftmargin=2em
}
}
\usepackage{csquotes}
\defbibheading{bibliography}[\bibname]{\section{#1}}
\makeatletter
\newcommand*\cnltxhyphen{\texorpdfstring{\cnltx@hyphen}{-}}
\newrobustcmd*\cnltx@hyphen{\penalty\@M-\hskip\z@skip}
\makeatother
\newpackagename\cnltxbase{cnltx\cnltxhyphen base}
\newpackagename\cnltxcsnames{cnltx\cnltxhyphen csnames}
\newpackagename\cnltxdoc{cnltx\cnltxhyphen doc}
\newpackagename\cnltxexample{cnltx\cnltxhyphen example}
\newpackagename\cnltxlistings{cnltx\cnltxhyphen listings}
\newpackagename\cnltxtools{cnltx\cnltxhyphen tools}
\newpackagename\cnltxtranslations{cnltx\cnltxhyphen translations}
\newnote*\bypackage[1]{provided by \csname cnltx#1\endcsname}
\newnote*\byclass{provided by \cnltxdoc}
\newname\oberdiek{Heiko Oberdiek}
\newname\egreg{Enrico Gregorio}
\newname\heinz{Carsten Heinz}
\newname\moses{Brooks Moses}
\newname\hoffmann{Jobst Hoffmann}
\newname\daniel{Marco Daniel}
\usepackage{fixfoot}
\DeclareFixedFootnote\oberdiekfn{\CTANurl{oberdiek}}
\newcommand*\file[1]{\code{#1}}
\newidxcmd\prg{\code{#1}}[ (program)]
\newcommand*\latin[1]{\cnltxlatin{#1}}
\newcommand*\PDF{\cnltxacronym{PDF}{pdf}}
\newenvironment{colors}
{%
\def\colour##1{\item[]\code{\textcolor{##1}{##1}}\hfill\newline}%
\cnltxlist
}
{\endcnltxlist}
\def\at{\cnltxat}
\def\bang{\cnltxbang}
\def\equal{\cnltxequal}
\newcommand*\BibTeX{\texorpdfstring{\hologo{BibTeX}}{BibTeX}}
\begin{document}
\part{About The Bundle}
\section{Background}
The \cnltx\ bundle contains different packages and classes\footnote{Well,
\emph{one} class for the time being,}. I developed it as a successor of my
class \cls{cnpkgdoc}~\cite{cls:cnpkgdoc} that I used until now for writing the
documentation of my packages. The intention behind the new bundle is a
cleaner interface and less unnecessary ballast, hence the separation into
packages and classes. This is actually a bit of a contradiction: the document
class \cnltxdoc\ loads \emph{all} packages of the bundle which makes it more
feature-rich than \cls{cnpkgdoc} ever used to be. The bundle provides source
code environments that also print the output and defines quite a lot of macros
for formatting of control sequence names, package names, package options and
so on.
Part of the motivation is also that users have asked me how I created the
manuals for my packages. Now I can refer to this bundle.
Another reason for the splitting into separate packages is -- besides the
advantage of easier maintenance -- is that I wanted to add programming tools
that I often use into \cnltxbase\ which may allow me (and others) to use them
for other packages, too, without having to define them each time. So it is
quite likely that \cnltxbase\ will get extended in the future.
The bundle provides \pkg{listings} style for \LaTeX\ code, bibliography
database files and index style files. It provides a \pkg{biblatex} citation
and bibliography style closely linked to \cnltxdoc. It provides a
bibliography database file containing many \LaTeX\ packages. It
provides\ldots\ Let's stop here. You see that the bundle provides a lot of
different features which explains why this manual is more than 60~pages long.
The most detailed documentation for the bundle is as always the source code of
the \file{sty} and \file{cls} files but I'm trying to provide a documentation
as comprehensive as possible. Reading the source files may show how things
are implemented but the intended use only becomes clear when you read this
manual.
The bundle reflects the fact that I haven't started using literate
programming, yet. I don't use \code{docstrip} and don't write \file{dtx}
files but always write the \file{sty} or \code{cls} files directly. I write
the manual always at the same time but as a separate file. While I'm entirely
aware of the advantages of literate programming I never could bring myself to
start to use it myself. As a consequence I have no idea if this bundle can be
used for it or not.
Source code formatting is done with the help of the powerful
\pkg{listings} package~\cite{pkg:listings} by \heinz\ and later \moses, now
maintained by \hoffmann. The only real drawback I have found with it is
recognizing starred und un-starred versions of an environment as different
keywords. This does not seem to be possible which is why indexing of such
environments will lead to wrong page numbers.
The fancy frames of the source code examples are realized with the
\pkg{mdframed} package by \daniel~\cite{pkg:mdframed}, loaded with the option
\keyis*-{framemethod}{tikz}.
Besides all this I included some other ideas of mine in this bundle which are
all provided by \cnltxtools. This includes a mechansim for defining clever
abbreviations or macros that make it easy to index names the same way
\pkg{biblatex} does.
\section{Bundled Packages, Classes and Files}
The \cnltx\ bundle currently bundles the following packages, classes and
files:
\begin{itemize}
\item \sinceversion{0.9}\cnltx\ -- a wrapper package for usage in documents.
It loads one or more of the following packages. See
section~\ref{sec:usage-bundle} for details on the usage. \\
\verbcode+\usepackage{cnltx}+
\item \cnltxbase\ -- a package that defines base macros for error-messaging,
expansion control, tokenlist manipulation and defining of expandable
macros. It also provides color definitions and defines a few color
schemes for the \cnltxdoc\ class. All other packages and classes of the
\cnltx\ bundle load this package. This package can be used
stand-alone. \\
\verbcode+\usepackage{cnltx-base}+\\
The packages commands are not described in the main part of this
documentation but only in section~\ref{sec:defined-cnltxbase}, \ie, in the
appendix.
\item \cnltxdoc\ -- a class for writing package manuals. Loads
\cnltxexample\ and \cnltxtools\ and implicitly all other files of the
bundle. \\
\verbcode+\documentclass{cnltx-doc}+
\item \cnltxexample\ -- a package that defines macros and environments for
describing control sequences and options and for including source code.
Loads \cnltxlistings. This package can be used stand-alone. \\
\verbcode+\usepackage{cnltx-example}+
\item \sinceversion{0.4}\cnltxlistings\ -- a package that defines the
listings language `BibTeX'. Also defines a list of highlighted control
sequence names and environment names, loaded by \cnltxexample. The
additional control sequence and environment names used to be defined in
\cnltxcsnames. That package got removed and its contents are now provided
by \cnltxlistings. This package can be used stand-alone. \\
\verbcode+\usepackage{cnltx-listings}+
\item \sinceversion{0.2}\cnltxtools\ -- a package that defines tools used by
\cnltxdoc\ that are unrelated to \LaTeX\ documentation \latin{per se}.
This package can be used stand-alone. \\
\verbcode+\usepackage{cnltx-tools}+
\item \sinceversion{0.11}\cnltxtranslations\ -- a package that provides
translations needed by the other modules. It makes no sense to use this
package standalone although it's possible.
\item \file{cnltx.ist} -- an index style file that is used when the option
\option{add-index} for \cnltxdoc\ is activated and the option
\option{index-style} is not used.
\item \sinceversion{0.4}\file{cnltx.bib} -- a bibliography file that
contains a small but growing number of package entries, see
section~\ref{sec:list-entr-bib}. Used by \cnltxdoc\ when the
\option{add-bib} is used.
\item \sinceversion{0.4}\file{cnltx.bbx}, \file{cnltx.cbx} and
\file{cnltx.dbx} -- files related to the \pkg{biblatex} style
\code{cnltx}. The \pkg{biblatex} style defined in those files is used
when the \option{add-bib} for \cnltxdoc\ is used.
\end{itemize}
\section{License and Requirements}\label{sec:license}
\license
The \cnltxbase\ package loads the following packages:
\needpackage{pgfopts}~\cite{pkg:pgfopts},
\needpackage{etoolbox}~\cite{pkg:etoolbox},
\pkg{ltxcmds}\oberdiekfn~\cite{pkg:ltxcmds},
\pkg{pdftexcmds}\oberdiekfn~\cite{pkg:pdftexcmds},
\needpackage{trimspaces}~\cite{pkg:trimspaces} and
\needpackage{xcolor}~\cite{pkg:xcolor}.
The \cnltxdoc\ class loads the packages \cnltxbase, \cnltxexample,
\cnltxtranslations, \needpackage{ulem}~\cite{pkg:ulem},
\needpackage[macros/latex/required/tools]{multicol}~\cite{pkg:multicol},
\needpackage[macros/latex/contrib/ms]{ragged2e}~\cite{pkg:ragged2e},
\needpackage{marginnote}~\cite{pkg:marginnote} and
\needpackage{hyperref}~\cite{pkg:hyperref}. It is a wrapper class for the
\KOMAScript\ class
\cls{scrartcl}\footnote{\CTANurl{koma-script}}~\cite{bnd:koma-script}. The
class has the option \option{load-preamble} which when used will load
additional packages, see section~\vref{sec:preamble} for details.
The \cnltxexample\ package loads the packages: \cnltxbase, \cnltxlistings,
\cnltxtools, \cnltxtranslations, \needpackage{mdframed}~\cite{pkg:mdframed},
\needpackage{textcomp}~\cite{pkg:textcomp},
\needpackage{idxcmds}~\cite{pkg:idxcmds},
\needpackage{ifxetex}~\cite{pkg:ifxetex},
\needpackage{adjustbox}~\cite{pkg:adjustbox}.
The \cnltxlistings\ package loads the packages \cnltxbase,
\needpackage{listings}~\cite{pkg:listings} and
\needpackage{catchfile}~\cite{pkg:catchfile}.
The \cnltxtools\ package loads the packages \cnltxbase, \cnltxtranslations and
\pkg{accsupp}\oberdiekfn~\cite{pkg:accsupp}.
\cnltxtranslations\ loads the \pkg{translations}
package~\cite{pkg:translations}.
All other packages that are loaded are loaded by the mentioned packages and
not directly by any of the packages or classes of the \cnltx\ bundle. Like
all of my packages \cnltx\ implicitly relies on an up to date \TeX\
distribution.
\section{Usage of the Bundle}\label{sec:usage-bundle}
The intended use of this bundle is three-fold:
\begin{itemize}
\item The main use-case is documenting my own \LaTeX\ packages. This is
done with
\begin{sourcecode}[gobble=6]
\documentclass{cnltx-doc}
\end{sourcecode}
and actually loads most if not all of the bundle.
\item The module \cnltxbase\ is also intended as a programming tools package
that will be used in other packages eventually. For example it is used by
the \pkg{cntformats} package.
\item In case parts of this bundle prove useful to be used in a document the
recommended way is to add
\begin{sourcecode}[gobble=6]
\usepackage{cnltx}
\end{sourcecode}
to the preamble which will load the \cnltxbase\ module. Other needed
modules can be given as package option by using the name part after the
dash as option.
\begin{sourcecode}[gobble=6]
\usepackage[example]{cnltx}
\end{sourcecode}
would load \cnltxexample.
\item Parts of the bundle -- especially \cnltxbase\ -- may prove useful in
other packages. The loading the packages directly as indicated in
section~\ref{sec:license} seems the best way. After loading \cnltxbase\
the other modules can also be loaded with \verbcode+\cnltx@load@module+,
see section~\ref{sec:related-bundle} for details.
\end{itemize}
\part{Details of Available Commands, Environments and Options}
\section{Options and Setup}
The \cnltx\ bundle has a large number of options. The \cnltxdoc\ class only
knows a few options (described in section~\vref{sec:class:options}) as
\emph{class} options, though. All other options regardless if they're defined
by a package or a class can and should be set with the setup command:
\begin{commands}
\command{setcnltx}[\marg{options}]
Setup command for the \cnltx\ bundle. This command is provided by
\cnltxbase.
\end{commands}
The source code environments defined by the \cnltxexample\ package also have
optional arguments that can be used to set the options for the environment
locally.
\section{Available Commands}
\subsection{Description of Macros, Environments and Options}\label{sec:cmds:macros}
The commands described in this section all are provided by the \cnltxexample\
package\bypackage{example}. They all are related to the typesetting of
provided macros, options and the like.
\begin{commands}
\command{code}[\marg{arg}]
Formatting of source code. This is \emph{no} verbatim command. Used
internally in the following commands.
\command{verbcode}[\meta{char}\meta{code}\meta{char}]
\sinceversion{0.2}A verbatim command that uses the same formatting as the
source code example environments, \cf\ section~\ref{sec:usage:examples}.
This is a wrapper for \cs*{lstinline} which loads the corresponding
style.
\command{cs}[\sarg\marg{name}]
Format the control sequence \meta{name}, \cs{cs}\Marg{name}:
\cs*{name}. Adds a corresponding index entry. The starred form does not
add an index entry.
\command{csidx}[\marg{name}]
Adds an index entry but does not typeset the control sequence
\meta{name}.
\command{env}[\sarg\marg{name}]
Format the environment \meta{name}, \cs{env}\Marg{name}:
\env*{name}. Adds a corresponding index entry with a hint that the entry
refers to an environment. The starred form does not add an index entry.
\command{envidx}[\marg{name}]
Adds an index entry but does not typeset the environment \meta{name}.
\command{meta}[\marg{meta}]
Description of an argument, \cs{meta}\Marg{meta}: \meta{meta}.
\command{marg}[\marg{arg}]
A mandatory argument. \meta{arg} is formatted with \cs{meta} if it is not
blank, \cs{marg}\Marg{arg}: \marg{arg}.
\command{Marg}[\marg{arg}]
\sinceversion{0.2}A mandatory argument. \meta{arg} is formatted with
\cs{code} if it is not blank, \cs{Marg}\Marg{arg}: \Marg{arg}.
\command{oarg}[\marg{arg}]
An optional argument. \meta{arg} is formatted with \cs{meta} if it is not
blank, \cs{oarg}\Marg{arg}: \oarg{arg}.
\command{Oarg}[\marg{arg}]
\sinceversion{0.2}An optional argument. \meta{arg} is formatted with
\cs{code} if it is not blank, \cs{Oarg}\Marg{arg}: \Oarg{arg}.
\command{darg}[\marg{arg}]
An argument with parentheses as delimiters. \meta{arg} is formatted with
\cs{meta} if it is not blank, \cs{darg}\Marg{arg}: \darg{arg}.
\command{Darg}[\marg{arg}]
\sinceversion{0.2}An argument with parentheses as delimiters. \meta{arg}
is formatted with \cs{code} if it is not blank, \cs{Darg}\Marg{arg}:
\Darg{arg}.
\command{sarg}
An optional star argument, \cs{sarg}: \sarg.
\command{newarg}[\oarg{arg formatting}\marg{cs}\marg{left delim}\marg{right delim}]%
\Default{\cs{meta}}
\changedversion{0.2}Command used to define the argument commands:
\verbcode+\newarg\marg{\{}{\}}+. The optional argument determines how the
argument of the new command will be formatted. This is done with
\cs{meta} per default. \cs{Marg} is defined
\verbcode+\newarg[\code]\Marg{\{}{\}}+.
\command{option}[\sarg\marg{name}]
An option \meta{name}, \cs{option}\Marg{name}: \option{name}. Adds a
corresponding index entry. The starred form does not add an index entry.
\command{optionidx}[\marg{name}]
Adds an index entry but does not typeset the option \meta{name}.
\command{module}[\sarg\marg{name}]
A module \meta{name}, \cs{module}\Marg{name}: \module{name}. Adds a
corresponding index entry. The starred form does not add an index entry.
In some of my packages I like to organize options by grouping them in
different classes that I call ``modules''. This command refers to those
modules.
\command{moduleidx}[\sarg\marg{name}]
Adds an index entry but does not typeset the option \meta{name}.
\command{key}[\sarg\code{-}\marg{name}\marg{value}]
A key \meta{name} with value \meta{value}, the optional star prevents an
index entry, the optional \code{-} strips the braces around \meta{value};
\cs{key}\Marg{key}\Marg{value}: \key{key}{value};
\cs{key}\code{-}\Marg{key}\Marg{value}: \key-{key}{value}
\command{keyis}[\sarg\code{-}\marg{name}\marg{value}]
\sinceversion{0.2}A key \meta{name} set to value \meta{value}, the
optional star prevents an index entry, the optional \code{-} strips the
braces around \code{value}; \cs{key}\Marg{keyis}\Marg{value}:
\keyis{key}{value}.
\command{choices}[\marg{clist of choices}]
A list of choices, \cs{choices}\Marg{one,two,three}:
\choices{one,two,three}
\command{choicekey}[\marg{name}\marg{clist of choices}]
A key \meta{name} with a list of possible values,
\cs{choicekey}\Marg{key}\Marg{one,two,three}:
\choicekey{key}{one,two,three}
\command{boolkey}[\marg{name}]
A boolean key \meta{name} with choices \code{true} and \code{false},
\cs{boolkey}\Marg{key}: \boolkey{key}
\command{default}[\marg{value}]
Markup for a default choice,
\cs{choices}\Marg{one,\cs{default}\Marg{two},three}:
\choices{one,\default{two},three}
\end{commands}
\subsection{Versioning Commands, Licensing and Related Stuff}\label{sec:cmds:versioning}
The commands described in this section are provided by the \cnltx\
class\byclass\ except where indicated differently. These commands are related
to information about the legal stuff of a package and where to find it on th
world wide web.
\begin{commands}
\command{sinceversion}[\marg{version}]
\sinceversion{0.0}Gives a sidenote like the one on the left.
\command{changedversion}[\marg{version}]
\changedversion{0.0}Gives a sidenote like the one on the left.
\command{newnote}[\sarg\marg{cs}\oarg{num}\oarg{optional}\marg{definition}]
Defines a note like \cs{sinceversion}. The syntax of the command is the
same as the one of \cs*{newcommand}. \cs{sinceversion} was defined as
follows:\\
\verbcode+\newnote*\sinceversion[1]{Introduced in version~#1}+\\
or actually like this:\\
\verbcode+\newnote*\sinceversion[1]{\GetTranslation{cnltx-introduced}~#1}+
\command{newpackagename}[\marg{cs}\marg{name}]
Define a comand \meta{cs} that prints \meta{name} formatted like \cnltx,
\ie\ in small caps and colored with the color \code{cnltx} (see
section~\ref{sec:actual-used-color}).
\command{lppl}
Typesets ``\lppl'' and adds a corresponding index entry.
\command{LPPL}
Typesets ``\LPPL'' and adds the same index entry as \cs{lppl}.
\command{license}[\sarg\oarg{maintenance status}]\Default{maintained}
\changedversion{0.2}Typesets `\license*'. The un-starred variant adds a
\cs*{par}.
\command{ctan}
Typesets ``\ctan'' and adds a corresponding index entry.
\command{CTAN}
Typesets ``\CTAN'' and adds the same index entry as \cs{ctan}.
\command{pkg}[\sarg\marg{package}]
\bypackage{example}Format the package name \meta{package} and add an
index entry. The starred variant adds nothing to the index.
\command{pkgidx}[\marg{package}]
\bypackage{example}Add an index entry for the package \meta{package}.
\command{cls}[\sarg\marg{class}]
\bypackage{example}Format the class name \meta{class} and add an index
entry. The starred variant adds nothing to the index.
\command{clsidx}[\marg{class}]
\bypackage{example}Add an index entry for the class \meta{class}.
\command{CTANurl}[\oarg{directory}\marg{name}]
Writes a \ctan\ link like the ones in section~\vref{sec:license} in the
footnotes. The predefined directory is \code{macros/latex/contrib}. The
link address will be:\par
\code{http://mirrors.ctan.org/\meta{directory}/\meta{name}/}.
\command{email}[\marg{email address}]
\sinceversion{0.11}A wrapper for \verbcode+\href{mailto:#1}{#1}+.
\command{website}[\marg{web address}]
\sinceversion{0.11}A wrapper for \verbcode+\href{http://#1/}{#1}+.
\command{securewebsite}[\marg{web address}]
\sinceversion{0.11}A wrapper for \verbcode+\href{https://#1/}{#1}+.
\command{needpackage}[\oarg{directory}\marg{name}]
\sinceversion{0.2}A wrapper for
\verbcode+\pkg{#2}\footnote{\CTANurl[#1]{#2}}+
\command{needclass}[\oarg{directory}\marg{name}]
\sinceversion{0.2}A wrapper for
\verbcode+\cls{#2}\footnote{\CTANurl[#1]{#2}}+
\end{commands}
\begin{example}
\newpackagename{\foothree}{foo-3}%
now \foothree\ looks like \cnltx.
\end{example}
\subsection{Input Source Code Files}
Similar to the environments described in section~\vref{sec:envs:sourcecode}
\cnltxexample\ provides a few commands for inputting source code files,
formatting and printing the source code and inputting the file directly.
\begin{commands}
\command{inputexample}[\oarg{options}\marg{file name}]
The equivalent of the \env{example} environment, see
section~\vref{sec:envs:sourcecode}.
\command{inputsidebyside}[\oarg{options}\marg{file name}]
The equivalent of the \env{sidebyside} environment, see
section~\vref{sec:envs:sourcecode}.
\command{inputsourcecode}[\oarg{options}\marg{file name}]
The equivalent of the \env{sourcecode} environment, see
section~\vref{sec:envs:sourcecode}.
\command{implementation}[\oarg{options}\marg{file name}]
\sinceversion{0.5}A wrapper for
\verbcode+\lstinputlisting[style=cnltx,#1]{#2}+
\end{commands}
It is possible to define further commands like this:
\begin{commands}
\command{newinputsourcefilecmd}[\oarg{option}\marg{control sequence}]
Defines \meta{control sequence} as a new source code input command where
\meta{options} are preset.
\end{commands}
The existing commands have been defined like this:
\begin{sourcecode}
\newinputsourcefilecmd\inputexample
\newinputsourcefilecmd[side-by-side]\inputsidebyside
\newinputsourcefilecmd[code-only]\inputsourcecode
\end{sourcecode}
\section{Available Environments}\label{sec:envs}
\subsection{Description Environments}\label{sec:envs:description}
\cnltxdoc\ defines some description environments used to describe macros,
environments or options.
\begin{environments}
\environment{commands}
A description-like environment for describing commands. While this
environment is a list internally and thus recognizes \cs*{item} own
commands are used to describe macros. They are explained in
section~\vref{sec:usage:commands}.
\environment{options}
A description-like environment for describing options. While this
environment is a list internally and thus recognizes \cs*{item} own
commands are used to describe options. They are explained in
section~\vref{sec:usage:options}.
\environment{environments}
A description-like environment for describing environments. While this
environment is a list internally and thus recognizes \cs*{item} own
commands are used to describe environments. They are explained in
section~\vref{sec:usage:environments}.
\end{environments}
These environments are lists all using the same internal \cs*{list}. The
setup of this list can be changed via an option:
\begin{options}
\keyval{list-setup}{definitions}{}
\Default{\cs*{leftmargin}=0pt \cs*{labelwidth}=2em \cs*{labelsep}=0pt
\cs*{itemindent}=-1em }
The setup of the \cs*{list} used by the \env{commands}, \env{options} and
\env{environments} environments.
\end{options}
\subsection{Source Code Environments}\label{sec:envs:sourcecode}
\cnltxexample\ defines the following environments that are used to display
source code and possibly the output of the source code, too.
\begin{environments}
\environment{example}[\oarg{options}]
This environment is a formatted verbatim environment that also inputs the
output of the inputted code. This environment is described in
section~\vref{sec:usage:examples}.
\environment{sidebyside}[\oarg{options}]
This environment is a formatted verbatim environment that also inputs the
output of the inputted code. Source and output are printed side-by-side.
This environment is described in section~\vref{sec:usage:examples}.
\environment{sourcecode}[\oarg{options}]
This environment is a formatted verbatim environment. This environment is
described in section~\vref{sec:usage:examples}.
\end{environments}
\sinceversion{0.2}In each of these environments certain hooks are provided
that can be used to add definitions you like:
\begin{options}
\keyval{pre-code}{definitions}
\meta{definitions} are placed before the source code is inserted.
\keyval{after-code}{definitions}
\meta{definitions} are placed after the source code is inserted.
\keyval{pre-output}{definitions}
\meta{definitions} are placed before the output of the source code is
inserted.
\keyval{after-output}{definitions}
\meta{definitions} are placed after the output of the source code is
inserted.
\end{options}
It is possible to define further environments like this:
\begin{commands}
\command{newsourcecodeenv}[\oarg{option}\marg{name}]
Defines \meta{name} as a new source code environment where
\meta{options} are preset.
\end{commands}
The existing environments have been defined like this:
\begin{sourcecode}
\newsourcecodeenv{example}
\newsourcecodeenv[side-by-side]{sidebyside}
\newsourcecodeenv[code-only]{sourcecode}
\end{sourcecode}
\section{Usage of the Various Functions}
\subsection{Command Descriptions}\label{sec:usage:commands}
Inside of the environment \env{commands} that was introduced in
section~\vref{sec:envs:description} items are input via the following command:
\begin{commands}
\command{command}[\sarg\marg{name}\oarg{stuff after}]
This macro formats a control sequence with \cs{cs} and puts a line break
after it. The optional argument allows printing things directly after the
command name and can thus be used for adding arguments. The star prevents
the creation of an index entry.
\command{Default}[\sarg\code{!}\marg{code}]
\changedversion{0.3}This command can be placed after \cs{command} or
\cs{opt} in order to give a default definition of a macro or a default
value of an option. The definition will then be placed on the same line
flush right. The star prevents the insertion of \cs*{newline} after it.
The optional bang adds the information that an option is mandatory, \ie\
has to be set.
\command{expandable}
\sinceversion{0.5}Adds the symbol \expandablesymbol\ to the left of a
command in the margin to indicate that the command is expandable. This
command should be used \emph{immediately} before \cs{command}.
\command{unexpandable}
\sinceversion{0.5}Adds the symbol \unexpandablesymbol\ to the left of a
command in the margin to indicate that the command is not expandable.
This command should be used \emph{immediately} before \cs{command}.
\command{expandablesign}\Default{\cs*{textasteriskcentered}}
\sinceversion{0.5}The macro that holds the sign used by \cs{expandable}
and \cs{unexpandable}.
\command{expandablesymbol}
\sinceversion{0.11}The symbol \expandablesymbol, \ie, \cs{expandablesign}
formatted with the color \code{expandable}.
\command{unexpandablesymbol}
\sinceversion{0.11}The symbol \unexpandablesymbol, \ie,
\cs{expandablesign} formatted with the color \code{unexpandable}.
\end{commands}
\begin{example}
\begin{commands}
\command{cs}
This is about foo bar baz.
\command{cs}[\marg{arg}]
This one has an argument.
\command{cs}[\sarg\oarg{option}]
This has a star variant and an optional argument.
\command{cs}\Default{foo bar}
This one has the default replacement text \code{foo bar}
\expandable\command{cs}
This macro is expandable.
\end{commands}
\end{example}
The \cs{expandablesign} can of course be redefined to something else you like
better. For the sake of completeness there is an option that does exactly
this:
\begin{options}
\keyval{expandable-sign}{definition}\Default{\cs*{textasteriskcentered}}
\sinceversion{0.5}Redefines \cs{expandablesign} to \meta{definition}.
\end{options}
\subsection{Option Descriptions}\label{sec:usage:options}
The \env{options} environment knows a few more commands to meet all the
different kinds of options.
\begin{commands}
\command{opt}[\sarg]
An option. The star prevents an index entry.
\command{keyval}[\sarg\code{-}\marg{key}\marg{value}]
A key/value option. The optional star prevents an index entry. The
optional \code{-} strips the braces around \meta{value}, see the example
below.
\command{keychoice}[\sarg\marg{key}\marg{list of choices}]
A key/value option where the value is one of a list of choices. The star
prevents an index entry.
\command{keybool}[\sarg\marg{name}]
A boolean key, that ist a choice key with choices \code{true} and
\code{false}. The star prevents an index entry.
\command{Default}[\sarg\code{!}\marg{code}]
\changedversion{0.3}This command can be placed after \cs{command} or
\cs{opt} (or any of the other commands for adding an option to the
\env{options} list) in order to give a default definition of a macro or a
default value of an option. The definition will then be placed on the
same line flush right. The star prevents the insertion of \cs*{newline}
after it. The optional bang adds the information that an option is
mandatory, \ie, it has to be set.
\command{Module}[\sarg\code{!}\marg{name}]
\sinceversion{0.3}This command can be placed after \cs{option} but before
\cs{Default} in order to determine the module the option belongs to. It
will be written in the left margin next to the option name. The star
prevents the insertion of \cs*{newline} after it. The optional bang
\emph{adds} an index entry for the module. This is somehow inconsistent
with many of the other commands where an optional star \emph{prevents} an
index entry but it fits to the functionality of \cs{Default} which is why
this syntax was chosen.
\end{commands}
The following demonstrates how the commands would be used to create option
descriptions:
\begin{sourcecode}
\begin{options}
\opt{foo}
This makes stuff. Let's add a few more words so that the line gets
filled and we can see how the output actually looks.
\opt*{foo}\Default{bar}
This makes stuff. Let's add a few more words so that the line gets
filled and we can see how the output actually looks.
\opt{foo}\Module{bar}
This option belongs to \module*{bar}. Let's add a few more words so
that the line gets filled and we can see how the output actually
looks.
\opt{foo}\Module{bar}\Default{baz}
This option belongs to \module*{bar}. Let's add a few more words so
that the line gets filled and we can see how the output actually
looks.
\keyval{foo}{bar}\Default
This makes stuff. Let's add a few more words so that the line gets
filled and we can see how the output actually looks.
\keyval{foo}{bar}\Default!
This makes stuff. Let's add a few more words so that the line gets
filled and we can see how the output actually looks.
\keyval*{foo}{bar}
This makes stuff. Let's add a few more words so that the line gets
filled and we can see how the output actually looks.
\keyval-{foo}{bar}
This makes stuff. Let's add a few more words so that the line gets
filled and we can see how the output actually looks.
\keychoice{foo}{one,two,three}
This makes stuff. Let's add a few more words so that the line gets
filled and we can see how the output actually looks.
\keybool{foo}
This makes stuff. Let's add a few more words so that the line gets
filled and we can see how the output actually looks.
\end{options}
\end{sourcecode}
The code above gives the following output:
\begin{options}
\opt{foo}
This makes stuff. Let's add a few more words so that the line gets
filled and we can see how the output actually looks.
\opt*{foo}\Default{bar}
This makes stuff. Let's add a few more words so that the line gets
filled and we can see how the output actually looks.
\opt{foo}\Module{bar}
This option belongs to the module \module{bar}. Let's add a few more
words so that the line gets filled and we can see how the output actually
looks.
\opt{foo}\Module{bar}\Default{baz}
This option belongs to the module \module{bar}. Let's add a few more
words so that the line gets filled and we can see how the output actually
looks.
\keyval{foo}{bar}\Default
This makes stuff. Let's add a few more words so that the line gets
filled and we can see how the output actually looks.
\keyval{foo}{bar}\Default!
This makes stuff. Let's add a few more words so that the line gets
filled and we can see how the output actually looks.
\keyval*{foo}{bar}
This makes stuff. Let's add a few more words so that the line gets
filled and we can see how the output actually looks.
\keyval-{foo}{bar}
This makes stuff. Let's add a few more words so that the line gets
filled and we can see how the output actually looks.
\keychoice{foo}{one,two,three}
This makes stuff. Let's add a few more words so that the line gets
filled and we can see how the output actually looks.
\keybool{foo}
This makes stuff. Let's add a few more words so that the line gets
filled and we can see how the output actually looks.
\end{options}
\subsection{Environment Descriptions}\label{sec:usage:environments}
Environment descriptions are made -- unsurprisingly -- with the
\env{environments} environment. It knows the command \cs{environment}:
\begin{commands}
\command{environment}[\sarg\marg{name}\oarg{stuff after}]
This macro prints the environment name and puts a line break
after it. The optional argument allows printing things directly after the
environment name and can thus be used for adding arguments.
\end{commands}
\begin{example}
\begin{environments}
\environment*{foobar}[\oarg{options}]
This is environment \env*{foobar}. The star prevents it from being
added to the index.
\end{environments}
\end{example}
\subsection{Code Examples}\label{sec:usage:examples}
Code examples can be included through the \env{example} environment or the
\env{sourcecode} environment. The \env{sourcecode} only shows the piece of
\LaTeX code while the \env{example} environment also shows the output of the
\LaTeX\ code.
\begin{sourcecode}
\begin{example}
a \LaTeX\ code example
\end{example}
\end{sourcecode}
This example would give:
\begin{example}
a \LaTeX\ code example
\end{example}
Both environments can be influenced by options:
\begin{options}
\keybool{code-only}\Default{false}
Only typeset the code as code but don't include it afterwards. The
code box above is an example for the usage of this option. This option
has no effect on the \env{sourcecode} environment: is is already set for
this environment.
\keybool{side-by-side}\Default{false}
Typeset source and output side by side. The code is input on the left and
the output on the right. Side by side examples are typeset in
\env*{minipage} environments with all consequences that come with them
(think of \cs*{parindent}, page breaks \ldots). Since a \code{minipage}
cannot be broken across pages the surrounding \pkg{mdframed} frame gets
the option \keyis*-{nobreak}{true}. This option has no effect on the
\env{sourcecode} environment.
\keybool{code-left}\Default{true}
If \code{true} and the option \option{side-by-side} is chosen the source
code is printed on the right side else on the left. This option has no
effect on the \env{sourcecode} environment.
\keyval{code-sep}{definition}\Default{\cs*{hrulefill}}
Code that is inserted between a source code and the corresponding output
when printed below each other. This option has no effect on the
\env{sourcecode} environment.
\keybool{outside}\Default{false}
\sinceversion{0.10}If \code{true} the output of an example is put outside
of the frame in the input stream. This can be useful if the example code
contains a floating environment for example.
\end{options}
The same example again, this time using \option{side-by-side} (which is the
same as using the \env{sidebyside} environment):
\begin{example}[side-by-side]
a \LaTeX\ code example
\end{example}
\option{side-by-side} and \keyis-{code-left}{false}:
\begin{example}[side-by-side,code-left=false]
a \LaTeX\ code example
\end{example}
The frame around the examples is done by the
\pkg{mdframed} package~\cite{pkg:mdframed}. It is of course possible to
customize it:
\begin{options}
\keyval{add-frame-options}{\pkg{mdframed} options}\Default
Add options to the predefined settings.
\keyval{frame-options}{\pkg{mdframed} options}{}
\Default{backgroundcolor=cnltxbg,linecolor=cnltx,roundcorner=5pt}
Overwrite the settings with new ones.
\keyval{add-local-frame}{\pkg{mdframed} options}
\sinceversion{0.10}Add \pkg{mdframed} options to the environment where the
option is used only. This is
basically \beginenv*\Marg{\env{mdframed}}\Oarg{style=cnltx,\meta{options}}.
\keyval{local-frame}{\pkg{mdframed} options}
\sinceversion{0.10}replace the default \pkg{mdframed} options to the
environment where the option is used only. This is
basically \beginenv*\Marg{\env{mdframed}}\oarg{options}.
\end{options}
The source code is formatted using the great \pkg{listings}
package~\cite{pkg:listings} by \heinz, \moses, and \hoffmann. Similar options
exist to adapt \pkg{listings}' options that are used for formatting the source
code. The predefined style has many options that will not be mentioned here.
If you're interested you can find them in \file{cnltx-example.sty} or in
section~\vref{sec:listings-sourcecode}.
\begin{options}
\keyval-{gobble}{integer}\Default{2}
The number of initial characters that is gobbled from each line.
\keyval{add-cmds}{list of csnames}\Default
A list of control sequence names that should be recognized as a command
sequence in the source code examples and should be formatted accordingly.
The control sequence names in this list will also get an index entry when
they're used in the source example. This is done internally via
\cs{csidx}. The option should be used to add the new commands that are
defined by the package for which you are writing the manual for.
\keyval{add-silent-cmds}{list of csnames}
A list of control sequence names that should be recognized as a command
sequence in the source code examples and should be formatted accordingly.
The control sequence names in this list will \emph{not} get an index entry
when they're used in the source example. There already is quite a large
but far from comprehensive list of silent commands but many are still
missing. This option allows you to extend the list on a per document
basis.
\keyval{add-listings-options}{\pkg{listings} options}\Default
Additional options for the \pkg{listings}~\cite{pkg:listings}
environments. \emph{This redefines the \code{cnltx} \pkg{listings} style
which will affect all sourcecode environments!}
\keyval{listings-options}{\pkg{listings} options}
Overwrite existing options with new ones. This can be used to build an own
style from scratch. \emph{This redefines the \code{cnltx} \pkg{listings}
style which will affect all sourcecode environments!}
\keyval{add-sourcecode-options}{\pkg{listings} options}
\sinceversion{0.4}These options are added to the \pkg{listings} options of
the source code environments without redefing the main style. Hence it
can be used to locally add options to a source code environment. This is
basically \cs*{lstset}\Marg{style=cnltx,\meta{options}}.
\keyval{sourcecode-options}{\pkg{listings} options}
\sinceversion{0.10}These options are added to the \pkg{listings} options
of the source code environments without redefing or using the main style.
Hence it can be used to locally add options to a source code environment.
This is basically \cs*{lstset}\marg{options}.
\keyval{add-envs}{list of environment names}\Default
Like \option{add-cmds} but for environment names.
\keyval{add-silent-envs}{list of environment names}
Like \option{add-silent-cmds} but for environment names.
\end{options}
\subsection{Compile Source Examples}\label{sec:comp-source-exampl}
\subsubsection{The Compliation Process}\label{sec:compliation-process}
When you input an example like
\begin{sourcecode}
\begin{example}
\documentclass{article}
\begin{document}
foo
\end{document}
\end{example}
\end{sourcecode}
you'll get an error since the code is input as is and you'll end up with
\cs*{documentclass} after \verbcode=\begin{document}=. There's a way out,
though.