1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
|
% \iffalse
%<*internal>
\begingroup
%</internal>
%<*batchfile>
\input docstrip.tex
\keepsilent
\preamble
___________________________________________________________
Copyright (C) 2008, 2015 Will Robertson
<will.robertson@latex-project.org>
Distributable under the LaTeX Project Public License,
version 1.3c or higher (your choice). The latest version of
this license is at: http://www.latex-project.org/lppl.txt
This work is "maintained" (as per LPPL maintenance status)
by Will Robertson.
This work consists of the file vwcol.dtx
and the derived files vwcol.sty,
vwcol.ins, and
vwcol.pdf.
___________________________________________________________
\endpreamble
\postamble
\endpostamble
\askforoverwritefalse
\generate{\file{\jobname.sty}{\from{\jobname.dtx}{package}}}
%</batchfile>
%<batchfile>\endbatchfile
%<*internal>
\nopreamble\nopostamble
\generate{\file{\jobname.ins}{\from{\jobname.dtx}{batchfile}}}
\generate{\file{dtx-style.sty}{\from{\jobname.dtx}{dtx-style}}}
\endgroup
\immediate\write18{mv README.txt README}
\immediate\write18{makeindex -s gind.ist -o \jobname.ind \jobname.idx}
\immediate\write18{makeindex -s gglo.ist -o \jobname.gls \jobname.glo}
%</internal>
%
%<*driver>
\documentclass{ltxdoc}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
%\OnlyDescription
\usepackage{dtx-style}
\begin{document}
\DocInput{\jobname.dtx}
\end{document}
%</driver>
%
%
% \fi
%
% \GetFileInfo{\jobname.sty}
% \CheckSum{0}
% \makeatletter
%
% \title{The \pkg{vwcol} package}
% \author{Will Robertson}
% \date{\filedate \qquad \fileversion}
%
% \maketitle
%
% \section{Introduction}\seclabel{intro}
%
% This package provides an environment that allows paragraph text to be typeset into multiple columns of uneven width, with text that flows from one column to the next. The columns can not span over multiple pages.
%
% Due to difficulties with the processing of such a thing, little else \emph{besides} text is allowed within (feel free to experiment, but you're on your own). Here's an example:\footnote{Requires the \pkg{lipsum} package to print the sample text.}
% \begin{example}{firstline=2}
% \tiny
% \begin{vwcol}[widths={0.3,0.2,0.5}]
% \lipsum[1]
% \end{vwcol}
% \end{example}
%
% \section{Options}
%
% As shown above, at heart this package is quite simple. This section discusses the options that can be passed to the |vwcol| environment. The options are:
% \begin{description}[noitemsep,font=\ttfamily,leftmargin=6em,style=nextline]
% \item [widths] The number and size of the columns.
% \item [sep] The width of the space between the columns.
% \item [sidesep] Whether to add space on the outside of the columns (equiv.\ to the following two options together).
% \item [presep] Whether to add space before the columns.
% \item [postsep] Whether to add space after the columns.
% \item [rule] The width of the rule.
% \item [siderule] Whether to draw a rule on the outside of the columns (equiv.\ to the following two options together).
% \item [prerule] Whether to draw a rule before the columns.
% \item [postrule] Whether to draw a rule after the columns.
% \item [rulecolor] The colour of the rule.\footnote{Added in v0.2.}
% \item [justify] Paragraph justification within the columns.
% \item [indent] Indentation size within the columns (if relevant).
% \end{description}
% Paragraph options |justify| and |indent| are covered in \secref[vref]{para}, and some advanced options are discussed in \secref[vref]{advanced}.
%
% \bigskip
%
% \noindent\DescribeMacro{\vwcolsetup}
% This macro may be used to set the default values for the options (described subsequently) of the |vwcol| environment.
% \begin{example}{firstline=2}
% \tiny
% \vwcolsetup{widths={0.3,0.2,0.5},rule=2pt}
% \begin{vwcol}
% \lipsum[1]
% \end{vwcol}
% \end{example}
%
% \noindent\DescribeMacro{widths}
% This option must always be present (either as a default value previously set in \cmd\vwcolsetup\ or specified in the environment directly) and consists of any number of comma-separated lengths or ratios. Lengths set the column width to an explicit size, whereas a ratio (as above) sets the column width to a fraction of the available linewidth (leaving some space for some separation between the columns).
%
% As shown in the example in \secref{intro}, when the width ratios sum to 100\% then the multi-columns will span the entire line width regardless of the chosen separation between the columns. A set of widths may be any combination of ratios and lengths, but the total width should not exceed the linewidth available (a warning will be given if so).
%
% \bigskip\noindent\DescribeMacro{sep}
% The separation between the columns can be chosen as either
% a length, a ratio of the linewidth, or the keyword |fill|.
% The default is |sep=0.05| (\ie, 5\% of the linewidth).
% \begin{example}{firstline=2}
% \tiny
% \begin{vwcol}[widths={0.35,0.25,0.4},sep=5pt]
% \lipsum[1]
% \end{vwcol}
% \end{example}
%
% \noindent
% The keyword |fill| adds stretchable space between the columns so the multi-columns fill the entire linewidth (without altering the widths of the columns themselves):
%
% \begin{example}{firstline=2}
% \tiny
% \begin{vwcol}[widths={2cm,2cm,0.4},sep=fill]
% \lipsum[1]
% \end{vwcol}
% \end{example}
%
% \noindent
% If ratio column widths are used with a variable separation gap,
% then the separation gap is considered zero for the total width calculation.
% In this example, because the ratios for the column widths sum to 100\% there is no room left over
% for a separation gap:
% \begin{example}{firstline=2}
% \tiny
% \begin{vwcol}[widths={0.3,0.2,0.5},sep=fill]
% \lipsum[1]
% \end{vwcol}
% \end{example}
%
% \bigskip\noindent\DescribeMacro{presep}\DescribeMacro{postsep}\DescribeMacro{sidesep}
% These options control whether an extra separation is added before and/or after the multicolumns. |presep| (or |presep=true|) adds space before the columns (and |presep=false| suppresses it); |postsep| adds space after the columns; |sidesep| is a shorthand for activating both at once.
% \begin{example}{firstline=2}
% \tiny\par
% \begin{vwcol}[widths={0.3,0.25,0.4}]
% \lipsum[1]
% \end{vwcol}
%
% \setlength\fboxsep{0pt}
% \fbox{\begin{vwcol}[widths={0.3,0.25,0.4},sidesep]
% \lipsum[1]
% \end{vwcol}}
% \end{example}
%
% \bigskip\noindent\DescribeMacro{rule}
% The width of the rule is configurable (again, either a length or a ratio of the line width) and does not affect the separation gap. Use |rule=none| or |rule=0pt| to suppress drawing the rule. The default is |rule=0.4pt|.
% \begin{example}{firstline=2}
% \tiny
% \begin{vwcol}[widths={0.35,0.25,0.4}]
% \lipsum[1]
% \end{vwcol}
% \begin{vwcol}[widths={0.35,0.25,0.4},rule=0.02]
% \lipsum[1]
% \end{vwcol}
% \end{example}
%
% \bigskip\noindent\DescribeMacro{prerule}\DescribeMacro{postrule}\DescribeMacro{siderule}
% These options control whether extra vertical rules are added before and/or after the columns. |prerule| places a rule before the columns; |postrule| after them. (Again, |prerule=false| (\etc) turns this feature off.) And |siderule| is a shorthand to activate both. Using these options implicitly activates the relevant |presep| and/or |postsep| options, because you can't have the rule without the gap.
% \begin{example}{firstline=2}
% \par\tiny
% \begin{vwcol}[widths={0.35,0.25,0.4},siderule]
% \lipsum[1]
% \end{vwcol}
% \end{example}
%
% \bigskip\noindent\DescribeMacro{rulecolor}
% The colour of each rule.
% Either used a pre-defined name or define your own using \pkg{color} or \pkg{xcolor}.
% The \pkg{color} package is loaded by this package.
% \begin{example}{firstline=2}
% \tiny
% \vwcolsetup{widths={0.35,0.25,0.4},siderule,rule=2pt}
% \begin{vwcol}[rulecolor=red]
% \lipsum[6]
% \end{vwcol}
% \definecolor{myrulecol}{rgb}{0.1,0.6,0.3}
% \begin{vwcol}[rulecolor=myrulecol]
% \lipsum[6]
% \end{vwcol}
% \end{example}
%
%
% \section{Paragraph settings}\seclabel{para}
%
% \bigskip\noindent\DescribeMacro{justify}
% The justification to use; one of |ragged| (\emph{default}), |flush|, |raggedleft|, or |center|. These settings are made using the \pkg{ragged2e} package, with the result that hyphenation is enabled even in the ragged settings (this is a good thing!); due to a limitation of \TeX's \cmd\parshape, \LaTeX's ordinary \cmd\raggedright\ setting cannot be used.
% \begin{example}{firstline=2}
% \tiny
% \begin{vwcol}[widths={0.35,0.25,0.4}]
% \lipsum[66]
% \end{vwcol}
% \begin{vwcol}[widths={0.35,0.25,0.4},justify=flush]
% \lipsum[66]
% \end{vwcol}
% \begin{vwcol}[widths={0.35,0.25,0.4},justify=raggedleft]
% \lipsum[66]
% \end{vwcol}
% \begin{vwcol}[widths={0.35,0.25,0.4},justify=center]
% \lipsum[66]
% \end{vwcol}
% \end{example}
%
% \bigskip\noindent\DescribeMacro{indent}
% This option is used to set the paragraph indent for ragged right and justified paragraph shapes (by default |[indent=1.5em]|).
% \begin{example}{firstline=2}
% \tiny
% \begin{vwcol}[widths={0.35,0.25,0.4},indent=5em]
% \lipsum[66]\lipsum[66]
% \end{vwcol}
% \end{example}
% Note that the first column always begins with a \cmd\noindent. Let me know if you don't like this idea.
%
%
% \section{Advanced (read: not very useful) options}
% \seclabel{advanced}
%
% \bigskip\noindent\DescribeMacro{quiet}
% The \pkg{vwcol} package passes certain information about what it's doing via errors in compilation, warnings in the console output, and info in the |.log| file. Loading \pkg{vwcol} with the |[quiet]| option `demotes' the priority of these diagnostics: errors become warnings, warnings become info in the |.log| file, and info is suppressed entirely.
%
% \bigskip\noindent\DescribeMacro{lines}
% With the default |[lines=auto]|, the |vwcol| environment tries to
% estimate how much space is required but it will
% sometimes get it wrong. Pass an integer to the |lines| option to specify
% exactly how many
% lines to use (which will also save processing time), but if the value chosen
% is too small then text will be lost (and an error given):
% \begin{example}{firstline=2}
% \tiny
% \begin{vwcol}[widths={0.35,0.25,0.4},lines=4]
% \lipsum[1]
% \end{vwcol}
% \begin{vwcol}[widths={0.35,0.25,0.4},lines=11]
% \lipsum[1]
% \end{vwcol}
% \end{example}
% The rationale behind producing an error is that you really want to be alerted if text in your input is not making it into the output document (\cf\ with trying to insert a character that doesn't exist in the current font).
%
% \bigskip\noindent\DescribeMacro{maxrecursion}
% When the estimate number of
% lines is calculated, the value is sometimes too small. |vwcol| will increment
% the number of lines one-by-one at most |maxrecursion| times until the text completely fits into the columns. If it hits |maxrecursion|, then an error is reported explaining what's going on.
%
% The default is |5|, but I'd be surprised if you ever need to adjust this parameter.
%
% \section{Usage notes}
%
% If you want the |widths| ratios to use a different width to denote 100\% (instead of \cmd\linewidth), put the whole thing in a |minipage| or \cmd\parbox:
% \begin{example}{firstline=2}
% \tiny
% \begin{minipage}{0.8\linewidth}
% \begin{vwcol}[widths={0.3,0.7},indent=1.8em]
% \lipsum[66]\lipsum[66]
% \end{vwcol}
% \end{minipage}
% \end{example}
% \noindent (I might add an option to |vwcol| to allow this directly; \Eg, |[totalwidth=0.8\linewidth]|. Let me know if you like the idea.)
%
% The |vwcol| environment ends the previous paragraph at |\begin{vwcol}| and terminates the paragraph it is contained within at |\end{vwcol}|. This means you can't place two |vwcol| environments next to each other, for example (or next to anything else, for that matter). If you want to be able to do this, again, put them in |minipage|s or \cmd\parbox es:
% \begin{example}{firstline=2}
% \tiny
% \rule{0.1\linewidth-\fboxsep}{1ex}%
% %
% \fbox{\parbox{0.8\linewidth}{%
% \begin{vwcol}[widths={0.3,0.7},indent=1.8em]
% \lipsum[66]\lipsum[66]
% \end{vwcol}}}%
% %
% \rule{0.1\linewidth-\fboxsep}{1ex}%
% \end{example}
% \noindent (I might add an option to |vwcol| to allow this directly; \Eg, |[par=false]| or |[block=par]| vs.\ |[block=inline]|. Let me know if you like the idea.)
%
% Note in both of these cases that the \cmd\parindent\ length had to be redefined after |{minipage}| or \cmd\parbox\ defined it to zero inside themselves.
%
% \section{Acknowledgements}
%
% Many thanks to Flavio Costa for testing an early version of this package and especially for proof-reading this documentation. In large part due to him this manual makes much more sense |:)|
%
% \StopEventually{}
%
% \clearpage
% \part{\pkg{\jobname} implementation}
%\iffalse
%<*package>
%\fi
%
% \PrintChanges
%
% This is the package.
%
% \begin{macrocode}
\ProvidesPackage{vwcol}
[2015/02/10 v0.2 Variable-width multicolumn text]
% \end{macrocode}
%
% \section{Preamble}
%
% \subsection{Packages}
%
% \begin{macrocode}
\RequirePackage{calc}
\RequirePackage{color}
\RequirePackage{environ}[2008/06/18]
\RequirePackage{keyval}
\RequirePackage{ragged2e}
% \end{macrocode}
%
% \subsection{Things we need}
%
% \begin{macrocode}
\newlength\vwcol@sep
\newlength\vwcol@rule
\newlength\vwcol@totalwidth
\newlength\vwcol@averagewidth
\newlength\vwcol@parindent
% \end{macrocode}
%
% \begin{macrocode}
\newcount\vwcol@last
\newcount\vwcol@Ncols
\newcount\vwcol@Nlines
\newcount\vwcol@maxrecursion
% \end{macrocode}
%
% \begin{macrocode}
\newbox\vwcol@box
\newbox\vwcol@plainbox
\newbox\vwcol@outputbox
% \end{macrocode}
%
% \begin{macrocode}
\newif\if@vwcol@boxready
\newif\if@vwcol@prerule
\newif\if@vwcol@postrule
\newif\if@vwcol@presep
\newif\if@vwcol@postsep
% \end{macrocode}
%
% \subsection{Conveniences}
%
% Start error and warning text on a new line coz I think it looks better that way:
% \begin{macrocode}
\newcommand\vwcol@PackageError[2]{%
\PackageError{vwcol}{^^J\space\space#1}{#2}}
% \end{macrocode}
%
% \begin{macrocode}
\newcommand\vwcol@PackageWarning[1]{%
\PackageWarning{vwcol}{%
^^J\space\space#1^^JThis warning occurred}}
% \end{macrocode}
%
% \begin{macrocode}
\newcommand\vwcol@PackageInfo[1]{%
\PackageWarning{vwcol}{%
^^J\space\space#1^^JThis warning occurred}}
% \end{macrocode}
%
% \subsection{Package option}
%
% \begin{macrocode}
\DeclareOption{quiet}{%
\renewcommand\vwcol@PackageError[2]{%
\vwcol@PackageWarning{#1.}}%
\let\vwcol@PackageInfo\@gobble}
\ProcessOptions
% \end{macrocode}
%
% \section{Auxiliary macros}
%
% \begin{macro}{\vwcol@test@length}
% \darg{Rational number or length (\ie, with unit)}
% \darg{Multiplier for the rational (\eg, \cmd\linewidth)}
% This macro returns \cs{@tempswa} true if the input is a rational number (\eg, |0.1|, |1|, \etc) or false if it is a length (\eg, |2pt|, |3cm|). \note{Based on a similar macro by David Kastrup: \url{http://groups.google.com/group/comp.text.tex/msg/9bd5349ea2416c95}} \cs{@tempdima} contains the length corresponding to the rational number multiplier of |#2| or the length input, respectively.
% \begin{example}{}
% \vwcol@test@length{1}{\linewidth}
% \if@tempswa Rational\else Length\fi\\
% \vwcol@test@length{1cm}{\linewidth}
% \if@tempswa Rational\else Length\fi
% \end{example}
% \begin{macrocode}
\def\vwcol@test@length#1#2{%
\afterassignment\vwcol@test@@
\@tempdima=#1#2\@nil}
% \end{macrocode}
% The afterassignment macro:
% \begin{macrocode}
\def\vwcol@test@@#1\@nil{%
\ifx\@nil#1\@nil
\@tempswatrue
\else
\@tempswafalse
\fi}
% \end{macrocode}
% \end{macro}
% Actually, I don't use \cs{if@tempswa} in this package (I use \cmd\@tempdima\ directly), but I've left the conditional in there in case someone else finds it useful.
%
%
% \section{Environment options}
%
% \begin{macro}{\vwcolsetup}
% To set the defaults:
% \begin{macrocode}
\def\vwcolsetup{\setkeys{vwcol}}
% \end{macrocode}
% \end{macro}
%
% \paragraph{widths} The number and size of each column.
% \begin{macrocode}
\define@key{vwcol}{widths}{\def\vwcol@widths{#1}}
% \end{macrocode}
% No defaults.
%
% \paragraph{maxrecursion}
% Number of iterations used to estimate the number of lines.
% I doubt if it will ever need to be changed from the default.
% \begin{macrocode}
\define@key{vwcol}{maxrecursion}{\vwcol@maxrecursion=#1}
% \end{macrocode}
% Default:
% \begin{macrocode}
\vwcolsetup{maxrecursion=5}
% \end{macrocode}
%
% \paragraph{rule}
% The width of the intercolumn rule as a length or as a ratio of the total line width or as the keyword |none|.
% \begin{macrocode}
\define@key{vwcol}{rule}{%
\def\@tempa{#1}%
\def\@tempb{none}%
\ifx\@tempa\@tempb
\vwcol@rule=0pt
\else
\vwcol@test@length{#1}{\linewidth}%
\vwcol@rule=\@tempdima
\fi}
% \end{macrocode}
% Default:
% \begin{macrocode}
\vwcolsetup{rule=0.4pt}
% \end{macrocode}
%
% \paragraph{lines} The number of lines of text in each column or the keyword |auto|.
% \begin{macrocode}
\define@key{vwcol}{lines}{%
\def\@tempa{#1}%
\def\@tempb{auto}%
\ifx\@tempa\@tempb
\vwcol@Nlines=0
\else
\vwcol@Nlines=#1
\fi}
% \end{macrocode}
% Default:
% \begin{macrocode}
\vwcolsetup{lines=auto}
% \end{macrocode}
%
% \paragraph{sep} The distance between each column (including space taken up by the rule, if any) as a length or as a ratio or as the keyword |fill|.
% \begin{macrocode}
\define@key{vwcol}{sep}{%
\def\@tempa{#1}%
\def\@tempb{fill}%
\ifx\@tempa\@tempb
\vwcol@sep=1sp
\else
\vwcol@test@length{#1}{\linewidth}%
\vwcol@sep=\@tempdima
\fi}
% \end{macrocode}
% Default:
% \begin{macrocode}
\vwcolsetup{sep=0.05}
% \end{macrocode}
%
% \paragraph{presep}
% Whether to include a gap before the first column.
% \begin{macrocode}
\define@key{vwcol}{presep}[true]{%
\def\@tempa{#1}%
\def\@tempb{true}%
\ifx\@tempa\@tempb
\@vwcol@preseptrue
\else
\def\@tempb{false}%
\ifx\@tempa\@tempb
\@vwcol@presepfalse
\else
\vwcol@PackageWarning{%
'#1' not a valid option for option 'presep';
'true' or 'false' only.}%
\fi
\fi}
% \end{macrocode}
% Default:
% \begin{macrocode}
\vwcolsetup{presep=false}
% \end{macrocode}
%
% \paragraph{postsep}
% Whether to include a gap after the last column.
% \begin{macrocode}
\define@key{vwcol}{postsep}[true]{%
\def\@tempa{#1}%
\def\@tempb{true}%
\ifx\@tempa\@tempb
\@vwcol@postseptrue
\else
\def\@tempb{false}%
\ifx\@tempa\@tempb
\@vwcol@postsepfalse
\else
\vwcol@PackageWarning{%
'#1' not a valid option for option 'postsep';
'true' or 'false' only.}%
\fi
\fi}
% \end{macrocode}
% Default:
% \begin{macrocode}
\vwcolsetup{postsep=false}
% \end{macrocode}
%
% \paragraph{sidesep}
% Shorthand for setting both |presep| and |postsep| at once.
% \begin{macrocode}
\define@key{vwcol}{sidesep}[true]{%
\def\@tempa{#1}%
\def\@tempb{true}%
\ifx\@tempa\@tempb
\@vwcol@preseptrue
\@vwcol@postseptrue
\else
\def\@tempb{false}%
\ifx\@tempa\@tempb
\@vwcol@presepfalse
\@vwcol@postsepfalse
\else
\vwcol@PackageWarning{%
'#1' not a valid option for option 'sidesep';
'true' or 'false' only.}%
\fi
\fi}
% \end{macrocode}
%
% \paragraph{prerule}
% Whether to place a rule before the first column (implies |presep|).
% \begin{macrocode}
\define@key{vwcol}{prerule}[true]{%
\def\@tempa{#1}%
\def\@tempb{true}%
\ifx\@tempa\@tempb
\@vwcol@preseptrue
\@vwcol@preruletrue
\else
\def\@tempb{false}%
\ifx\@tempa\@tempb
\@vwcol@prerulefalse
\else
\vwcol@PackageWarning{%
'#1' not a valid option for option 'prerule';
'true' or 'false' only.}%
\fi
\fi}
% \end{macrocode}
% Default:
% \begin{macrocode}
\vwcolsetup{prerule=false}
% \end{macrocode}
%
% \paragraph{postrule}
% Whether to place a rule after the last column (implies |postsep|).
% \begin{macrocode}
\define@key{vwcol}{postrule}[true]{%
\def\@tempa{#1}%
\def\@tempb{true}%
\ifx\@tempa\@tempb
\@vwcol@postseptrue
\@vwcol@postruletrue
\else
\def\@tempb{false}%
\ifx\@tempa\@tempb
\@vwcol@postrulefalse
\else
\vwcol@PackageWarning{%
'#1' not a valid option for option 'postrule';
'true' or 'false' only.}%
\fi
\fi}
% \end{macrocode}
% Default:
% \begin{macrocode}
\vwcolsetup{postrule=false}
% \end{macrocode}
%
% \paragraph{siderule}
% Shorthand for setting |prerule| and |postrule| simultaneously.
% \begin{macrocode}
\define@key{vwcol}{siderule}[true]{%
\def\@tempa{#1}%
\def\@tempb{true}%
\ifx\@tempa\@tempb
\@vwcol@preseptrue
\@vwcol@postseptrue
\@vwcol@preruletrue
\@vwcol@postruletrue
\else
\def\@tempb{false}%
\ifx\@tempa\@tempb
\@vwcol@prerulefalse
\@vwcol@postrulefalse
\else
\vwcol@PackageWarning{%
'#1' not a valid option for option 'siderule';
'true' or 'false' only.}%
\fi
\fi}
% \end{macrocode}
%
% \paragraph{justify}
% The justification to use; one of |flush|/|ragged|/|raggedleft|/|center|.
% \begin{macrocode}
\define@key{vwcol}{justify}{%
\def\@tempa{#1}%
\def\@tempb{ragged}%
\ifx\@tempa\@tempb
\let\vwcol@justify\RaggedRight
\else
\def\@tempb{flush}%
\ifx\@tempa\@tempb
\let\vwcol@justify\justifying
\else
\def\@tempb{raggedleft}%
\ifx\@tempa\@tempb
\let\vwcol@justify\RaggedLeft
\else
\def\@tempb{center}%
\ifx\@tempa\@tempb
\let\vwcol@justify\Centering
\else
\vwcol@PackageWarning{%
'#1' not a valid option for option 'justify';
one of 'flush'/'ragged'/'raggedleft'/'center' only.}%
\fi
\fi
\fi
\fi}
% \end{macrocode}
% Default:
% \begin{macrocode}
\vwcolsetup{justify=ragged}
% \end{macrocode}
%
% \paragraph{indent}
% The paragraph indent to use with |flush| or |ragged| justification.
% \begin{macrocode}
\define@key{vwcol}{indent}{\setlength\vwcol@parindent{#1}}
% \end{macrocode}
% Default:
% \begin{macrocode}
\vwcolsetup{indent=1.5em}
% \end{macrocode}
%
% \paragraph{rulecolor} The colour of each rule.
% \begin{macrocode}
\define@key{vwcol}{rulecolor}{\def\vwcol@rulecol{#1}}
\vwcolsetup{rulecolor=black}
% \end{macrocode}
% No defaults.
%
% \section{\texttt{vwcol} environment definition}
%
% \begin{environment}{vwcol}
% Always start a new par.
% \begin{macrocode}
\NewEnviron{vwcol}[1][]{%
\par\noindent
% \end{macrocode}
% Initialisation:
% \begin{macrocode}
\@vwcol@boxreadyfalse
\vwcolsetup{#1}%
% \end{macrocode}
% Ensure the space at the top of each column is uniform:
% \begin{macrocode}
\splittopskip=\ht\strutbox
% \end{macrocode}
% Setup widths (this counts the columns and calculates the average and total widths of the columns):
% \begin{macrocode}
\expandafter\vwcol@process@widths\expandafter{\vwcol@widths}%
% \end{macrocode}
% Set up the paragraph parameters:
% \begin{macrocode}
\vwcol@para@setup
% \end{macrocode}
% From the width of the columns, the total width of the environment can be calculated. First, if |sep=fill| then the whole linewidth will be used:
% \begin{macrocode}
\ifdim\vwcol@sep=1sp
\vwcol@totalwidth=\linewidth
% \end{macrocode}
% Otherwise calculate the total from the number of separation gaps:\\ (\cmd\vwcol@totalwidth\ is currently the total of the columns widths, which was calculated above in \cmd\vwcol@process@widths)
% \begin{macrocode}
\else
\vwcol@totalwidth=\numexpr
\vwcol@totalwidth+(\vwcol@Ncols-1)*\vwcol@sep
\relax sp
% \end{macrocode}
% Add on extra space due to the optional pre- and post-separation gaps and rules. Note that while rules between columns do not contribute to the total width of the columns (they subtract from the empty space in the gaps between the columns, which explains why the correction is needed in the |presep|/|postsep| length processing), pre- or post-rules \emph{do}.
% \begin{macrocode}
\if@vwcol@presep
\advance\vwcol@totalwidth\dimexpr(\vwcol@sep-\vwcol@rule)/2\relax
\fi
\if@vwcol@postsep
\advance\vwcol@totalwidth\dimexpr(\vwcol@sep-\vwcol@rule)/2\relax
\fi
\if@vwcol@prerule \advance\vwcol@totalwidth \vwcol@rule\fi
\if@vwcol@postrule\advance\vwcol@totalwidth \vwcol@rule\fi
\fi
% \end{macrocode}
% Finally, warn the author if their columns are going to be too large:
% \begin{macrocode}
\ifdim\vwcol@totalwidth > \linewidth
\vwcol@PackageWarning{%
Total width of columns plus their separations
is greater than the linewidth^^J\space\space
(by \the\vwcol@totalwidth\space - \the\linewidth\space =
\the\dimexpr \vwcol@totalwidth-\linewidth\relax)}%
\fi
\ifnum\vwcol@Nlines=0%
% \end{macrocode}
% If the |lines| are not explicitly selected then they must be estimated.
% Typeset the text into a single box of the average column width (while ignoring overfull/underfull boxes):
% \begin{macrocode}
\@tempcnta=\hbadness
\hbadness=\maxdimen
\setbox\vwcol@plainbox\hbox{%
\parbox{\vwcol@averagewidth}{\vwcol@justify\BODY}}%
\hbadness=\@tempcnta
% \end{macrocode}
% Now the estimate of the number of lines per column, $L$, can be calculated.
% Start by assuming that the `area' of the material in the single block will be about the same when split into columns of un-equal width, $w_i$.
% (By `area' we \emph{actually} mean the number of lines in a block multiplied by the number of lines $N$.)
% If $T$ is the total number of lines of the single block typeset above (which is calculated by dividing the height of the block by the baselineskip), this gives
% \[ T\times w_a \approx L\times w_1+L\times w_2+\cdots = L\times\sum_{i=1}^N w_i .\]
% The width of the single block is defined above to be the average of the column widths:
% \[ w_a = \mathrm{ave}(w_i) = \sum_{i=1}^N w_i/N\]
% These two expressions are easily combined to give
% \[ L = \frac{T\times \mathrm{ave}(w_i)}{\sum_{i=1}^N w_i} = \frac{T}{N} . \]
% In words, the number of lines per column is simply to simply the number of lines in the single block divided by the number of columns.
% \begin{macrocode}
\vwcol@Nlines=\numexpr
(\ht\vwcol@plainbox+\dp\vwcol@plainbox)/
(\baselineskip*\vwcol@Ncols)
\relax
% \end{macrocode}
% However, differences may arise due to rounding (due to \TeX's integer arithmetic, the floor of the resultant value is always calculated\footnote{I think.}) and hyphenation/justification variations between the two cases.
%
% Due to these differences, we start with the calculated number of lines and increment in a loop if necessary to ensure all of the material does actually fit. It's unlikely that the number of lines estimated will be \emph{greater} than the number of lines required due to the effect of the `flooring' of the calculations.
% \begin{macrocode}
\@tempcnta=1%
\loop\unless\if@vwcol@boxready
\savebox\vwcol@outputbox{%
\hbox to \vwcol@totalwidth{\vwcol@{\BODY}}}%
\unless\if@vwcol@boxready
\advance\@tempcnta 1%
\advance\vwcol@Nlines 1%
% \end{macrocode}
% Here we could keep looping for as long as necessary, but in case of weird input we put a hard limit on the number of iterations. Stop after the line number has been incremented five times (by default) because surely the calculation couldn't have been that far wrong.
% \begin{macrocode}
\ifnum\@tempcnta>\vwcol@maxrecursion
\@vwcol@boxreadytrue
\vwcol@PackageError{%
The estimated number of lines is greater than
\the\vwcol@maxrecursion\space lines too small,%
^^J\space\space
so I gave up (last tried maximum value of
[lines=\the\vwcol@Nlines])%
}{%
Text will be truncated in the multicolumns;
please select the%
^^J\space\space
number of lines explicitly or increase
[maxrecursion=\the\vwcol@maxrecursion].%
}%
\fi
\fi
\repeat
\usebox\vwcol@outputbox
% \end{macrocode}
% If the |lines| was chosen explicitly then just run with it, giving an error if the lines were too small. I can imagine an |approxlines| option that varies the number of lines over a range of say, 5 lines up and down then chooses the best one, but I can't be bothered implementing that right now.
% \begin{macrocode}
\else
\hbox to \vwcol@totalwidth{\vwcol@{\BODY}}%
\unless\if@vwcol@boxready
\vwcol@PackageError{%
Not enough lines to fit the entire text;
some text has been truncated.^^J\space\space
Increase [lines=\the\vwcol@Nlines] to fit more%
}{%
Or remove [lines=\the\vwcol@Nlines] altogether
to have 'vwcol' estimate the value.}%
\fi
\fi\par}
% \end{macrocode}
% That's it!
% \end{environment}
%
% \begin{macro}{\vwcol@para@setup}
% Set up the paragraph options.
% \begin{macrocode}
\def\vwcol@para@setup{%
% \end{macrocode}
% Justification:
% \begin{macrocode}
\vwcol@justify
% \end{macrocode}
% \cmd\parindent\ override if |justify| is |ragged| or |flush|:
% \begin{macrocode}
\@tempswafalse
\ifx\vwcol@justify\RaggedRight
\@tempswatrue
\else\ifx\vwcol@justify\justifying
\@tempswatrue
\fi\fi
\if@tempswa
\parindent=\vwcol@parindent
\else
\vwcol@PackageInfo{%
'indent' ignored for [justify=raggedleft]
or [justify=center]}
\fi
% \end{macrocode}
% The algorithm, unfortunately, doesn't work with non-zero \cmd\parskip:
% \begin{macrocode}
\parskip=0pt}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\vwcol@process@widths}
% This macros takes the |widths| input and calculates the number of columns and the total and average widths of the columns.
% \begin{macrocode}
\def\vwcol@process@widths#1{%
% \end{macrocode}
% Count the number of columns: (this must be done in a loop before the main one so that \cmd\vwcol@Ncols\ is known first)
% \begin{macrocode}
\@for\@ii:=#1\do{\advance\vwcol@Ncols 1}%
% \end{macrocode}
% Based on the colsep and rule width, calculate allowable space. For stretchable column gaps, the separation gap counts as zero but the rules still take up some space:
% \begin{macrocode}
\ifdim\vwcol@sep=1sp
\@tempdimb=\numexpr
\linewidth-(\vwcol@Ncols-1)*\vwcol@rule
\relax sp
% \end{macrocode}
% And for fixed-width column gaps: (chuck in the warning here about |sep|$\ge$|rule| coz it's convenient)
% \begin{macrocode}
\else
\ifdim\vwcol@rule > \vwcol@sep
\vwcol@sep=\vwcol@rule
\vwcol@PackageWarning{%
'sep' must be greater than or equal to 'rule'}%
\fi
\@tempdimb=\numexpr
\linewidth-(\vwcol@Ncols-1)*\vwcol@sep
\relax sp
% \end{macrocode}
% Remember that the rules do not take up any space of their own between the columns, so they subtract from the white space of the separation gap; this must be mirrored when additional space is included before or after the columns:
% \begin{macrocode}
\if@vwcol@presep
\advance\@tempdimb\dimexpr(-\vwcol@sep+\vwcol@rule)/2\relax
\fi
\if@vwcol@postsep
\advance\@tempdimb\dimexpr(-\vwcol@sep+\vwcol@rule)/2\relax
\fi
\fi
% \end{macrocode}
% The prerule and postrule both contribute to the total width, unlike the rules between the columns:
% \begin{macrocode}
\if@vwcol@prerule\advance\@tempdimb-\vwcol@rule\fi
\if@vwcol@postrule\advance\@tempdimb-\vwcol@rule\fi
% \end{macrocode}
% \cmd\@tempdimb\ now contains the maximum width that the columns can span before the environment is wider the \cmd\linewidth, after the rules and gaps are added in too. Use this as the reference length to calculate the lengths of the columns that have widths specified as ratios.
%
% Now iterate to do stuff:
% \begin{macrocode}
\@for\@ii:=#1\do{%
% \end{macrocode}
% If the column width is a plain rational number (like |0.4|) then set the columnwidth to be that fraction of the allowable width.
% \begin{macrocode}
\vwcol@test@length\@ii\@tempdimb
% \end{macrocode}
% Keep a running total of the total width being used:
% \begin{macrocode}
\advance\vwcol@totalwidth\@tempdima
% \end{macrocode}
% Save the column widths for later in the \cmd\parshape\ processing:
% \begin{macrocode}
\expandafter\expandafter\expandafter\def
\expandafter\expandafter\expandafter\vwcol@setup@parlines
\expandafter\expandafter\expandafter{%
\expandafter\vwcol@setup@parlines
\expandafter\vwcol@addlines
\expandafter{\the\@tempdima}}}%
% \end{macrocode}
% End the loop. Finally, calculate the average width of the columns:
% \begin{macrocode}
\vwcol@averagewidth=\dimexpr \vwcol@totalwidth/\vwcol@Ncols \relax}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\vwcol@setup@parlines}
% This is the macro used to locally store the setup for the \cmd\parshape\ line specification: (see a few lines back for the \cmd\expandafter\ fun of getting stuff into it)
% \begin{macrocode}
\def\vwcol@setup@parlines{\let\vwcol@parlines\@empty}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\vwcol@addlines}
% Adds paragraph specifications to \cmd\vwcol@parlines for a single column in the \cmd\parshape\. For $N$ columns there will be $N$ calls to this macro inside \cmd\vwcol@setup@parlines, which gets expanded at the beginning of every paragraph to create the required \cmd\parshape\ specification.
%
% \cmd\@tempcntb\ starts at |0| at the beginning of each paragraph and counts the number of lines over all the columns.
% \cmd\vwcol@last\ is the total number of lines that have so far been
% put into the columns. \cmd\vwcol@parlines\ is initialised at the beginning of each paragraph.
%
% Each time \cmd\vwcol@addlines\ is executed, \cmd\@tempcnta\ iterates through each line in that column. Once the total line count reaches the number of lines that have been typeset, \cmd\vwcol@parlines\ starts filling up with \cmd\parshape\ lines for the next paragraph.
% \begin{macrocode}
\def\vwcol@addlines#1{%
\@tempcnta=0
\loop\ifnum\@tempcnta<\vwcol@Nlines
\advance\@tempcntb 1
\ifnum\@tempcntb>\vwcol@last
\xdef\vwcol@parlines{\vwcol@parlines 0cm #1 }%
\fi
\advance\@tempcnta 1
\repeat}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\vwcol@}
% This is the macro for splitting the text into variable-width columns.
% \begin{macrocode}
\newcommand\vwcol@[1]{%
% \end{macrocode}
% \paragraph{Setting the paragraphs}
% First set the text into a special box that varies width at the appropriate places so when it is split into equal segments they can be arranged into variable-width columns.
% \begin{macrocode}
\setbox\vwcol@box\vbox{%
% \end{macrocode}
% The trick is to keep a running counter of lines that we've gone through by inspecting every paragraph after it is typeset:
% \begin{macrocode}
\def\par{\endgraf\advance\vwcol@last\the\prevgraf}%
% \end{macrocode}
% (see \cmd\vwcol@addlines\ for a more detailed explanation):
% \begin{macrocode}
\everypar{%
\@tempcntb=0
\vwcol@setup@parlines
\parshape=\numexpr \vwcol@Nlines*\vwcol@Ncols-\vwcol@last \relax
\vwcol@parlines}%
% \end{macrocode}
% Insert a \cmd\strut\ at the top to ensure we chop off the first column at the same height as all the others:
% \begin{macrocode}
\noindent\strut#1}%
% \end{macrocode}
% \paragraph{Splitting the columns}
% First insert a pre-sep and -rule, if appropriate:
% \begin{macrocode}
\if@vwcol@presep
\if@vwcol@prerule
\begingroup
\color{\vwcol@rulecol}
\vrule width \vwcol@rule
\endgroup
\fi
\hskip\dimexpr (\vwcol@sep-\vwcol@rule)/2 \relax
\fi
% \end{macrocode}
% Iterate over the total number of columns:
% \begin{macrocode}
\@tempcnta=0
\loop\ifnum\@tempcnta < \vwcol@Ncols
\advance\@tempcnta 1
% \end{macrocode}
% Skip the separations and rules in the first case:
% \begin{macrocode}
\unless\ifnum\@tempcnta=1
% \end{macrocode}
% Sep and rule between the columns if |[sep=fill]|:
% \begin{macrocode}
\ifdim\vwcol@sep=1sp
\hfill
\begingroup
\color{\vwcol@rulecol}
\vrule width \vwcol@rule
\endgroup
\hfill
\else
% \end{macrocode}
% Sep and rule between the columns if |sep| is a length:
% \begin{macrocode}
\@tempdima=\dimexpr (\vwcol@sep-\vwcol@rule)/2 \relax
\hskip\@tempdima
\begingroup
\color{\vwcol@rulecol}
\vrule width \vwcol@rule
\endgroup
\hskip\@tempdima
\fi
\fi
% \end{macrocode}
% Split off and place the text column, then loop:
% \begin{macrocode}
\vsplit\vwcol@box to \numexpr
(\vwcol@Nlines-1)*\baselineskip+\ht\strutbox \relax sp
\repeat
% \end{macrocode}
% Finally place the post-sep and -rule, if appropriate:
% \begin{macrocode}
\if@vwcol@postsep
\hskip\dimexpr (\vwcol@sep-\vwcol@rule)/2 \relax
\if@vwcol@postrule
\begingroup
\color{\vwcol@rulecol}
\vrule width \vwcol@rule
\endgroup
\fi
\fi
% \end{macrocode}
% If \cs{vwcol@box} is void then we've used up all the material. This fact is passed on so we can re-run the algorithm with a different number of lines (or give a warning) if the material was truncated.
% \begin{macrocode}
\ifvoid\vwcol@box
\global\@vwcol@boxreadytrue
\fi}
% \end{macrocode}
% \end{macro}
%
% \newpage
% \section{Problem with \cmd\raggedright\ and \cmd\parshape}
%
% Check it out; when you make a \cmd\parshape\ with more lines specified than necessary, the linebreak of the first line is totally wrong:
%
% \begin{example}{}
% \raggedright
% \newlength\tmp\tmp=241.84842pt
%
% \def\oneline{ 2.5em \tmp}
% \def\fivelines{\oneline\oneline\oneline\oneline\oneline}
%
% \textbf{Wrong}:\\
% \parshape 10 \fivelines\fivelines
% \lipsum[66]
%
% \textbf{Right}:\\
% \parshape 7 \fivelines\oneline\oneline
% \lipsum[66]
% \end{example}
% This is why this package uses \pkg{ragged2e}'s \cmd\RaggedRight\ instead of \LaTeX's \cmd\raggedright.
%
% In actual fact, when isolated into plain \TeX\ code this reveals a legitimate bug in \TeX's line-breaking algorithm. Unfortunately discovered too late in \TeX's life to be awarded a cheque.
%
%\iffalse
%</package>
%\fi
%
% \Finale
%
%
%\iffalse
%<*dtx-style>
% \begin{macrocode}
\ProvidesPackage{dtx-style}
\errorcontextlines=999
\def\@dotsep{1000}
\setcounter{tocdepth}{2}
\setlength\columnseprule{0.1pt}
\renewcommand\tableofcontents{\relax
\begin{multicols}{2}[\section*{\contentsname}]\small
\@starttoc{toc}\relax
\end{multicols}}
\setcounter{IndexColumns}{2}
\renewenvironment{theglossary}
{\small\list{}{}
\item\relax
\glossary@prologue\GlossaryParms
\let\item\@idxitem \ignorespaces
\def\pfill{\hspace*{\fill}}}
{\endlist}
\usepackage[svgnames]{xcolor}
\usepackage{amsmath,array,bm,booktabs,calc,enumitem,fancyvrb,graphicx,ifthen,lipsum,longtable,microtype,refstyle,subfig,varioref,url}
\usepackage[center,it]{titlesec}
\usepackage[quiet]{vwcol}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage[sc,osf]{mathpazo}
\linespread{1.1} % A bit more space between lines
\frenchspacing % Remove ugly extra space after punctuation
\setlength\parindent{2em}
\definecolor{niceblue}{rgb}{0.2,0.4,0.8}
\newenvironment{example}[1]
{\VerbatimEnvironment
\def\Options{#1}%
\begin{VerbatimOut}[gobble=2]{\examplefilename}}
{\end{VerbatimOut}\relax
\typesetexample}
\fvset{formatcom=\color{niceblue}}
\DefineShortVerb{\|}
\def\theCodelineNo{\textcolor{niceblue}{\sffamily\tiny\arabic{CodelineNo}}}
\let\examplesize\normalsize
\let\auxwidth\relax
\newsavebox\verbatimbox
\edef\examplefilename{\jobname.example}
\newcommand\typesetexample{\relax
\par\noindent
\begin{trivlist}\item[]
\begin{minipage}[t]{\linewidth}
\begin{quote}
\edef\@tempa{[gobble=2,fontsize=\noexpand\small,\Options]}%
\begin{lrbox}{\verbatimbox}\relax
\expandafter\BVerbatimInput\@tempa{\examplefilename}%
\end{lrbox}
\noindent\usebox\verbatimbox\par
\vspace{-0.7\baselineskip}%
{\color{gray}\hrulefill}\par
\catcode`\%=14
\input\examplefilename
\end{quote}
\end{minipage}
\end{trivlist}}
\newcommand*\name[1]{{#1}}
\newcommand*\pkg[1]{\textsf{#1}}
\newcommand*\feat[1]{\texttt{#1}}
\newcommand*\opt[1]{\texttt{#1}}
\newcommand*\note[1]{\unskip\footnote{#1}}
\let\latin\textit
\def\eg{\latin{e.g.}}
\def\Eg{\latin{E.g.}}
\def\ie{\latin{i.e.}}
\def\cf{\latin{cf.}}
\def\etc{\@ifnextchar.{\latin{etc}}{\latin{etc.}\@}}
\def\STIX{\textsc{stix}}
\def\MacOSX{Mac~OS~X}
\def\ascii{\textsc{ascii}}
\def\OMEGA{Omega}
\def\CTAN{\textsc{ctan}}
\newcounter{argument}
\g@addto@macro\endmacro{\setcounter{argument}{0}}
\newcommand*\darg[1]{%
\stepcounter{argument}%
{\ttfamily\char`\{\char`\#\theargument\char`\}:~}#1\par\noindent\ignorespaces}
\newcommand*\doarg[1]{%
\stepcounter{argument}%
{\ttfamily[\char`\#\theargument]:~}#1\par\noindent\ignorespaces}
\def\codeline{\par\hspace{\parindent}}% two \indents in total
% \end{macrocode}
%</dtx-style>
%\fi
%
% \typeout{*************************************************************}
% \typeout{*}
% \typeout{* To finish the installation you have to move the following}
% \typeout{* file into a directory searched by TeX:}
% \typeout{*}
% \typeout{* \space\space\space vwcol.sty}
% \typeout{*}
% \typeout{*************************************************************}
%
\endinput
|