-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrjlnewsp4.dtx
1975 lines (1973 loc) · 75.2 KB
/
rjlnewsp4.dtx
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
% \iffalse meta-comment
%
% Copyright (C) 2017 by Robert J Lee <latex@rjlee.homelinux.org>
% --------------------------------------------------------------
%
% This file 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 Robert J Lee.
%
% This work consists of the files rjlnewsp4.dtx and rjlnewsp4.ins
% and the derived file rjlnewsp4.cls
%
% \fi
%
% \iffalse
%<*driver>
\ProvidesFile{rjlnewsp4.dtx}
%</driver>
%<package> \NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package> \ProvidesPackage{rjlnewsp4}
%<*package>
[2017/06/27 v0.1 .dtx rjlnewsp4 file]
%</package>
%
%<*driver>
\documentclass{ltxdoc}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\usepackage{indentfirst}
\usepackage{relsize}
\begin{document}
\makeatletter
\makeatother
\DocInput{rjlnewsp4.dtx}
\end{document}
%</driver>
% \fi
%
% \CheckSum{0}
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
% Digits \0\1\2\3\4\5\6\7\8\9
% Exclamation \! Double quote \" Hash (number) \#
% Dollar \$ Percent \% Ampersand \&
% Acute accent \' Left paren \( Right paren \)
% Asterisk \* Plus \+ Comma \,
% Minus \- Point \. Solidus \/
% Colon \: Semicolon \; Less than \<
% Equals \= Greater than \> Question mark \?
% Commercial at \@ Left bracket \[ Backslash \\
% Right bracket \] Circumflex \^ Underscore \_
% Grave accent \` Left brace \{ Vertical bar \|
% Right brace \} Tilde \~}
%
%
% \changes{v0.5}{2004/11/05}{Unstable version}
%
% \GetFileInfo{rjlnewsp4.dtx}
%
% \DoNotIndex{\newcommand,\newenvironment}
%
%
% \title{The \textsf{rjlnewsp4} class\thanks{This document
% corresponds to \textsf{rjlnewsp4}~\fileversion, dated \filedate.}}
% \author{Robert J Lee \\ \texttt{latex@rjlee.homelinux.org}}
%
% \maketitle
%
% \section{Introduction}
%
% \subsection{Features}
%
% \begin{itemize}
% \item Part of the newspaper typesetting package
% \item Determines the size of individual articles prior to
% typesetting, at various column counts.
% \item Accepts a layout file with the location of individual articles
% to perform final typesetting
% \end{itemize}
%
% \subsection{Background}
%
% There is still significant lack of support for decent
% newspaper-style output from \LaTeX, and this package is one intended
% to improve the situation. While several solutions have already been
% tried (many of which are available on \textsmaller{CTAN}), most seem
% to revolve around the |multicol| package, which is excellent for
% general multicolumn documents, but is far too strict in its
% implementation to allow for the styles of headings and column
% layouts found in all modern newspapers.
%
% The major limitation of |multicol| for newspapers is that it
% requires all text to be set to the same width throughout each
% multicolumn environment, which comes out of the fact that \TeX's
% page builder must build more than a whole page of text before it can
% determine the optimum place for each page break, and since text can
% only be set into lines once, its width must be known
% beforehand. This makes it difficult to change the width in any way
% that is page-aware. The usual solution --- and the solution used by
% |multicol| --- is to simply declare a rule that all text must be
% the same width; however, it is actually possible to change the width
% at any known point in the \textit{source} document.
%
% This package does not seek to avoid this limitation; indeed, the
% |multicol| package is used directly at the time of
% writing. This is simply the minimal code necessary to layout
% newspapers in paste-up style without human placement of
% articles. Once working, it is intended to remove the |multicol|
% code and replace it with our own implementation, to allow
% significant changes to the document.
%
% This package was born out of the realisation that each article could
% be set with a different width to the others --- even though
% typesetting each page with a different width would be hard, so if an
% article spilled across pages then its width could not easily be
% match different column widths on each page.
%
% The practical upshot of this is that, provided the user is prepared
% to accept that each article will have constant width, an efficient
% solution to the newspaper problem is possible.
%
% \subsection{Current Limitations}
%
% \begin{itemize}
% \item Currently, only one page is supported.
% \item The maximum length of any individual article is~16,384~points
% (around 5 metres, or nearly 19 feet)
% \item A \texttt{C++} program is used to calculate a page layout.
% This is still under development, so the ideal layout may change.
% Generated layout files are stored to allow the final document to
% be repeatedly generated through \TeX.
% \item Each page is a separate document, with no automated support
% for continuation of articles between pages.
% \item No support is provided for changing the page size or
% orientation when injecting a newspaper into another document
% \item The package provides its own document class.
% Other formats may set up environments that conflict with
% |rjlnewsp4|. it is especially easy to produce text that overtypes
% the newspaper articles.
% \item Running in a |minipage| environment is untested, and unlikely
% to work
% \item All articles must be in constant-width columns (although the
% width may differ between articles). Magazine-style graphics that
% descend into columns are not supported, except by injecting
% |\parshape| and friends into the source text.
% \item An interface for the specification of alternate widths per
% article is yet to be implemented.
% \item No support for many familiar markup constructs, including
% footnotes or endnotes, page markers, running headers and so on. It
% may be possible to add these in future.
% \item No support for page titles and similar; these are expected to
% be added in the near future.
% \end{itemize}
%
% \subsection{Paste-Up Newspapers}
%
% \textit{Paste-up} refers to an early form of electronic typesetting
% for newspapers. An operator would type text into an electronic
% machine, which would typeset the text neatly into columns of a
% prescribed width. The operator would then cut the columns into
% lengths, and literally paste them onto the a master copy to form the
% newspaper.
%
% This package uses a similar technique to produce neatly typeset
% newspapers using \LaTeX, along with a couple of tricks to make the
% document look neater.
%
% \section{Usage}
% \subsection{Structure of a Newspaper}
%
% \DescribeEnv{newspaper}|\begin{newspaper}|
% \par\hspace{1in}\vdots\par
% |\end{newspaper}|
%
% The |newspaper| environment encloses the entire newspaper. If used
% in the middle of a document, it will end the current page and embed
% a newspaper in one or more pages of its own.
%
% Generally, a |newspaper| environment should surround each newspaper
% in your document. Unless specified otherwise, all other commands
% described below should appear in a |newspaper| environment.
%
% \DescribeMacro{article}\marg{filename}\marg{headline}\oarg{subtitle}
%
% Use inside |newspaper|
%
% The |article| macro defines a single article for the
% newspaper. The |filename| determines the file from which this
% article is read.
%
% The |headline| is the headline for the article.
%
% The optional |subtitle| is the subtitle for the article. This can be
% used for the author's name.
%
% All text in the environment will be set out in balanced columns at
% the full page height.
%
% \subsection{Changing the Appearance}
%
% \DescribeMacro{\alleyleft}
%
% Between two adjacent columns is a gap known as an \textit{alley},
% which prevents the reader's eye from jumping from one column to the
% next. In |rjlnewsp|, the alley is built up of two spaces (determined
% by |\alleyleft| and |\alleyright|) and a downrule (a vertical line,
% determined by |\downrulethick|).
%
% This length holds the partial width of the alley. This is space
% added at the left-hand side of each column.
%
% \DescribeMacro{\alleyright}
%
% This length holds the partial width of the alley. This is space
% added at the right-hand side of each column.
%
% \DescribeMacro{\downrulethick}
%
% A vertical line, known as a downrule, normally appears in the alley
% between two adjacent columns. |\downrulethick| holds the width of the
% dark vertical lines between columns. To avoid these lines, set this
% length to~|0pt|.
%
% \DescribeMacro{\downruletop}
%
% If the rules between articles are drawn to their logical full
% length, the effect is to create a grid, with each article's columns
% surrounded by a complete paragraph box. This is usually considered
% to be too imposing, so newspapers add extra whitespace by stopping
% the rules a few points short of their natural termination.
%
% The length |\downruletop| is extra space added to the top of a
% downrule, shortening it. It should usually be the same as
% |\downrulebottom|. By default, it is also the same as
% |\sideruleleft| and |\sideruleright|.
%
% \DescribeMacro{\downrulebottom}
%
% The length |\downrulebottom| is extra space added to the bottom of a
% downrule, shortening it. It should usually be the same as
% |\downruletop|. By default, it is also the same as
% |\sideruleleft| and |\sideruleright|.
%
% \DescribeMacro{\alleytop}
%
% Between two vertically-adjacent articles is a gap known as an
% \textit{alley}, which indicates the end of one article and the start
% of the next. In |rjlnewsp|, the alley is built up of two spaces
% (determined by |\alleytop| and |\alleybottom|) and a rule (a
% horizontal line, determined by |\siderulethick|).
%
% This length holds the partial width of the alley. This is space
% added at the top of each article (typically extra space above the
% headline, or space between the rule and the article body text if
% this is a continuation column).
%
% \DescribeMacro{\alleybottom}
%
% This length holds the partial width of the alley. This is space
% added at the bottom of each article column.
%
% \DescribeMacro{\siderulethick}
%
% A horizontal line, known as a rule, normally appears in the alley
% between vertically adjacent articles. Since there can be many
% ``rules'' in a newspaper, we call this a
% \textit{siderule}. |\siderulethick| holds the width of the
% dark horizontal lines between articles. To avoid these lines, set
% this length to~|0pt|.
%
% \DescribeMacro{\sideruleleft}
%
% The length |\sideruleleft| is extra space added to the left of a
% siderule, shortening it. It should usually be the same as
% |\sideruleright|. By default, it is also the same as
% |\downruletop| and |\downrulebottom|.
%
% \DescribeMacro{\sideruleright}
%
% The length |\sideruleright| is extra space added to the right of a
% siderule, shortening it. It should usually be the same as
% |\sideruleleft|. By default, it is also the same as
% |\downruletop| and |\downrulebottom|.
%
% \section{Implementation}
% \subsection{Preamble}
%
% \begin{macrocode}
\ProvidesClass{rjlnewsp4}[2017/07/12 Robert J Lee]
\NeedsTeXFormat{LaTeX2e}
% \end{macrocode}
%
% There hasn't been a document class for newspapers before.
% Using |article| as a parent class seemed like a bad idea because it
% pulls in a lot of article-related notes for typesetting titles,
% articles, sections and so on that don't really apply to newspapers.
%
% Using |minimal| as a base class is also a bad idea for the reasons
% set out in that package. So instead we start from scratch.
%
% All document classes must define |\normalsize|, |\textwidth| and
% |\textheight|. |10pt| seems like a good standard to go with, and
% the page sizes have been copied from |minimal| until I can think of
% something better to use.
% \begin{macrocode}
\renewcommand\normalsize{\fontsize{10pt}{12pt}\selectfont}
\setlength{\textwidth}{6.5in}
\setlength{\textheight}{8in}
% \end{macrocode}
%
% We will handle any page numbers.
% \begin{macrocode}
\pagenumbering{arabic} % but no page numbers are printed because:
\pagestyle{empty} % this is actually already in the kernel
% \end{macrocode}
%
% \section{Dependencies}
% Next declare our pagkage dependencies. Effort has been made to
% minimise our dependencies somewhat, but there are a few that are
% still used.
%
% |ifthen| provides a \LaTeX-style |\ifthenelse| macro, used mostly in
% validation.
%
% |forloop| is used to iterate through articles and columns.
%
% |multicol| is used as an easy way to build rectangular
% articles. This may be removed in a future release to provide more
% control over article spacing and to allow non-rectangular articles
% in the layout.
%
% Note that |eso-pic| is requiled later on, but only during the final
% layout. This provides a slightly convenient low-level primative that
% we use for setting text at exact coordinates on the page.
% \begin{macrocode}
\RequirePackage{ifthen}
\RequirePackage{forloop}
% \end{macrocode}
%
% The next section is copied from the article class. It sets up the
% options for |draft|, |final|, |10pt|, |11pt| and |12pt|.
% |draft| has been modified to also declare |\rjl@unbalance|; we want
% to show free vertical space in the final column so the editor knows
% how many column inches of text are available to fill.
% \begin{macrocode}
\newcommand\@ptsize{0}
\DeclareOption{draft}{\setlength\overfullrule{5pt}\newcommand{\rjl@unbalance}{0}}
\DeclareOption{final}{\setlength\overfullrule{0pt}}
\DeclareOption{10pt}{\renewcommand\@ptsize{0}}
\DeclareOption{11pt}{\renewcommand\@ptsize{1}}
\DeclareOption{12pt}{\renewcommand\@ptsize{2}}
% \end{macrocode}
%
% Standard lengths as per |article|. These may be tweaked before
% release to better support text in narrow columns.
%
% \begin{macrocode}
\setlength\arraycolsep{5\p@}
\setlength\tabcolsep{6\p@}
\setlength\arrayrulewidth{.4\p@}
\setlength\doublerulesep{2\p@}
\setlength\tabbingsep{\labelsep}
\skip\@mpfootins = \skip\footins
\setlength\fboxsep{3\p@}
\setlength\fboxrule{.4\p@}
\setlength\columnsep{10\p@}
\setlength\columnseprule{0\p@}
% \end{macrocode}
%
% \DescribeMacro{\verse}
% verse is copied from |article|.
% \DescribeMacro{\quotation}
% quotation is copied from |article|.
% \DescribeMacro{\quote}
% quote is copied from |article|.
% \DescribeMacro{\table}
% table is copied from |article|.
% \begin{macrocode}
\newenvironment{verse}
{\let\\\@centercr
\list{}{\itemsep \z@
\itemindent -1.5em%
\listparindent\itemindent
\rightmargin \leftmargin
\advance\leftmargin 1.5em}%
\item\relax}
{\endlist}
\newenvironment{quotation}
{\list{}{\listparindent 1.5em%
\itemindent \listparindent
\rightmargin \leftmargin
\parsep \z@ \@plus\p@}%
\item\relax}
{\endlist}
\newenvironment{quote}
{\list{}{\rightmargin\leftmargin}%
\item\relax}
{\endlist}
\newcounter{table}
\renewcommand\thetable{\@arabic\c@table}
\def\fps@table{tbp}
\def\ftype@table{2}
\def\ext@table{lot}
\def\fnum@table{\tablename\nobreakspace\thetable}
\newenvironment{table}
{\@float{table}}
{\end@float}
\newenvironment{table*}
{\@dblfloat{table}}
{\end@dblfloat}
\newlength\abovecaptionskip
\newlength\belowcaptionskip
\setlength\abovecaptionskip{10\p@}
\setlength\belowcaptionskip{0\p@}
\long\def\@makecaption#1#2{%
\vskip\abovecaptionskip
\sbox\@tempboxa{#1: #2}%
\ifdim \wd\@tempboxa >\hsize
#1: #2\par
\else
\global \@minipagefalse
\hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
\fi
\vskip\belowcaptionskip}
% \end{macrocode}
%
% \DescribeMacro{\today}
% |\today| is a macro from |article|, so we'd better provide a definition.
%
% This version has been modified to put out dates in British format,
% with proper superscripts.
%
% To use the American-style default as per |article|, use the option
% |ltxtoday|.
%
% Some packages cause problems if you want this format; if you use a
% style such as |babel| --- which overrides the definition of |\today|
% in |english.ldf| at the start of the document --- or |datetime| or
% |datetime2| --- which redefines |\today| in the style file as well
% as giving many other options for date formatting.
%
% If you do want this format, the option |forcetoday| will also
% redefine |\today| at the start of the |newspaper| environment,
% overwriting any changes from other packages.
% \begin{macrocode}
\newcommand{\rjl@today@}{%
\number\day\textsuperscript{\ifcase\day th%0
\or st\or nd\or rd\else th\fi}\,% \, shorter than \space due to superscript
\ifcase\month\or
January\or February\or March\or April\or May\or June\or
July\or August\or September\or October\or November\or December\fi
\space\number\year}
\newcommand{\today}{\rjl@today@}%
% \end{macrocode}
%
% \DescribeMacro{\rjl@multicol@}
% Holds the name of the multicols environment to use for breaking text
% into multple columns. The |rjl@multicols| environment, defined by
% this class, is used by default; this may be modified by the
% |multicols| option.
% \begin{macrocode}
\newcommand{\rjl@multicol@}{rjl@multicols}
% \end{macrocode}
%
% \DescribeMacro{\DeclareOption}
% Here we process some class options.
% \begin{itemize}
% \item \texttt{draft} Draft option as per |article| (defined above);
% puts black rectangle on the page to mark where boxes have overfilled
% (where you need to reword the text or modify spacing
% registers). Also prevents stretching of the final column of an
% article, to preview the amount of free space left.
% \item \texttt{final} Final option as per |article|. This ensures
% that all options are printed in their final published form.
% \item \texttt{10pt} Selects a 10-point font
% \item \texttt{11pt} Selects an 11-point font
% \item \texttt{12pt} Selects a 12-point font
% \item \texttt{multicols} Load the |multicol| package and use its
% |multicols| environment for balancing articles. This may better
% balancing of article text than the built-in version, which simply
% stretches the final column. This is especially noticable when large
% items are inserted into the text. However; it is expected that
% |multicols| will only work with rectangular articles going forward.
% \item \texttt{multicol} Synonym for |multicols|. Mostly included
% because it is very easy to get confused between the |multicols|
% environment and the |multicol| package.
% \begin{macrocode}
\DeclareOption{multicols}{\AtBeginDocument{\RequirePackage{multicol}}\renewcommand{\rjl@multicol@}{multicols}}
\DeclareOption{multicol}{\AtBeginDocument{\RequirePackage{multicol}}\renewcommand{\rjl@multicol@}{multicols}}
% \end{macrocode}
% \item \texttt{unbalance} Normally an attempt is made to balance the
% text between the columns of an article; that is, to put the same
% amount of text into each column. The |draft| option prevents this
% and allows extra space at the end of the final column. If you want
% to produce this effect in a final (non-|draft|) document for some
% reason, use the |unbalance| option. NB: This does not work with
% |multicols|.
% \begin{macrocode}
\DeclareOption{unbalance}{\newcommand{\rjl@unbalance}{1}}
% \end{macrocode}
% \item \texttt{ltxtoday} Option that can be passed to use the
% US-style date format used by the standard |article| class.
% \begin{macrocode}
\DeclareOption{ltxtoday}{
\renewcommand{\today}{\ifcase\month\or
January\or February\or March\or April\or May\or June\or
July\or August\or September\or October\or November\or December\fi
\space\number\day, \number\year}
}
% \end{macrocode}
% \item \texttt{sizing} Passed by the C++ program to indicate that articles
% are being sized, to generate the layout file. Note that the file is
% generated in C++, not in \LaTeX. \textit{This option is ignored;
% sizing wil be performed if the |layout| option is not given}.
% \begin{macrocode}
\DeclareOption{sizing}{%
% NB: We need this line. |\jobname.lay| is read by the C++ program.
\typeout{Generating Layout file \jobname.lay}%
}
% \end{macrocode}
% \item \texttt{layout} Instead of sizing, the article will be typeset
% using the layout file. Usually passed by the C++ program.
% \begin{macrocode}
\DeclareOption{layoutnews}{%
\typeout{This shalt be the final output. Reading \jobname.lay}%
\newcommand{\rjl@dofinal}{}%
}
% \end{macrocode}
% \item \texttt{forcetoday} Allow our |\today| command to overwrite
% the version used by |babel|, which does not use superscripts.
% \end{itemize}
% \begin{macrocode}
\newcommand{\rjl@today}{}
\DeclareOption{forcetoday}{%
\renewcommand{\rjl@today}{\renewcommand{\today}{\rjl@today@}}%
}%
\ProcessOptions%
% Copied from article:
\input{size1\@ptsize.clo}
\setlength\lineskip{1\p@}
\setlength\normallineskip{1\p@}
\renewcommand\baselinestretch{}
\@lowpenalty 51
\@medpenalty 151
\@highpenalty 301
% \end{macrocode}
%
%
% \begin{macrocode}
% \DescribeMacro{\theartfile}
% \DescribeMacro{\theheadline}
% \DescribeMacro{\thesubhead}
% Get the file, headline and subhead
\newcommand{\theartfile}{}
\newcommand{\theheadline}{}
\newcommand{\thesubhead}{}
% \end{macrocode}
%
% \begin{macro}{\headline}
% \marg{theheadline}
%
% Typesets the headline. Called automatically during article layout.
% By default, this is passed |\theheadline| which is a macro expanding to the
% user-supplied headline. By default, it typesets its argument in a larger font,
% bold and centered.
%
% \begin{macrocode}
\newcommand{\headline}[1]{%
\centerline{\large \textbf{#1}}%
\vspace{-1em}%
\par%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\subheadline}
% \marg{thesubhead}
%
% Typesets the sub-headline. Called automatically during article layout.
% By default, this is passed |\thesubhead| which is a macro expanding to the
% user-supplied headline. By default, it typesets its argument in a slanted font
% and centered. This macro is called even if no subheadline is given.
%
% \begin{macrocode}
\newcommand{\subheadline}[1]{%
\centerline{\textsl{#1}}%
\vspace{0.2em}%
\par%
}
% \end{macrocode}
% \end{macro}
%
% \DescribeMacro{rjl@mincols}\DescribeMacro{rjl@maxcols}
% Define counters used to store the range of column options for the
% current article:
% \begin{macrocode}
\newcounter{rjl@mincols}
\newcounter{rjl@maxcols}
% \end{macrocode}
%
% \begin{macro}{\rjl@readnumcols}
% |\rjl@readnumcols| is a macro to parse the human-entered number of
% columns (used in |\article| to parse the first optional parameter)e
%
% It is passed 4 single-character parameters from the user's input
% option, with subsequent parameters filled with |\relax|.
%
% Would be nice to do more validation here, but this'll do for parsing
% for now\dots
% \begin{macrocode}
\def\rjl@readnumcols#1#2#3#4{
\setcounter{rjl@mincols}{1}
\setcounter{rjl@maxcols}{5}
\ifthenelse{\equal{#1}{\relax}}{
\ClassError{rjlnewsp4}{First optianal \string\article argument
badly formatted}{The first argument must either be the maximum
number of columns allowed, or (minimun)-(maximum)}
}{
\ifthenelse{\equal{#2}{\relax}}{
\setcounter{rjl@maxcols}{#1}
}{
\ifthenelse{\equal{#3}{-}}{
\setcounter{rjl@mincols}{#1}
\setcounter{rjl@maxcols}{#4}
}{
\ifthenelse{\equal{#2}{-}}{
\setcounter{rjl@mincols}{#1}
\setcounter{rjl@maxcols}{#3}
}{
\ClassError{rjlnewsp4}{First optianal \string\article argument
badly formatted}{The first argument must either be the maximum
number of columns allowed, or (minimun)-(maximum)}
}
}
}
}
\ifthenelse{\value{rjl@maxcols} < \value{rjl@mincols}}{
\ClassError{rjlnewsp4}{First optianal \string\article\space argument
is invalid}{The first argument must either be the maximum
number of columns allowed, or (minimun)-(maximum); you cannot
specify \arabic{rjl@mincols}--\arabic{rjl@maxcols}: maximum is
less than minimum. Swapping maximum and minimun values.}
\edef\rjl@tmp{\value{rjl@mincols}} % local
\setcounter{rjl@maxcols}{\value{rjl@mincols}}
\setcounter{rjl@mincols}{\rjl@tmp}
}{}
\ifthenelse{\value{rjl@mincols} < 1}{
\ClassError{rjlnewsp4}{First optianal \string\article\space argument
is invalid}{The first argument must either be the maximum
number of columns allowed, or (minimun)-(maximum); you cannot
specify \arabic{rjl@mincols}--\arabic{rjl@maxcols}: illegal
minimum. Using 1--\arabic{rjl@maxcols} instead.}
\setcounter{rjl@mincols}{1}
}{}
\ifthenelse{\value{rjl@mincols} > 9}{
\ClassError{rjlnewsp4}{First optianal \string\article\space argument
is invalid}{The first argument must either be the maximum
number of columns allowed, or (minimun)-(maximum); you cannot
specify \arabic{rjl@mincols}--\arabic{rjl@maxcols}: illegal
minimum (only 9 columns supported). Using 9 columns instead.}
\setcounter{rjl@mincols}{9}
\setcounter{rjl@maxcols}{1}
}{}
\ifthenelse{\value{rjl@maxcols} < 1}{
\ClassError{rjlnewsp4}{First optianal \string\article\space argument
is invalid}{The first argument must either be the maximum
number of columns allowed, or (minimun)-(maximum); you cannot
specify \arabic{rjl@mincols}--\arabic{rjl@maxcols}: illegal
maximum. Using \arabic{rjl@mincols}--\arabic{rjl@mincols} instead.}
\setcounter{rjl@maxcols}{\value{rjl@mincols}}
}{}
\ifthenelse{\value{rjl@maxcols} > 9}{
\ClassError{rjlnewsp4}{First optianal \string\article\space argument
is invalid}{The first argument must either be the maximum
number of columns allowed, or (minimun)-(maximum); you cannot
specify \arabic{rjl@mincols}--\arabic{rjl@maxcols}: illegal
maximum (only 9 columns supported). Using 9 columns instead.}
\setcounter{rjl@maxcols}{9}
}{}
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\article}
% \marg{filename}
% \marg{headline}
% \oarg{subheadline}
%
% This is where we get the metainformation for an article.
% - \oarg{max cols}: Maximum number of columns to set an article
% at. Currently must be no more than 10. Default is 5.
% - \marg{filename}: stored in |\theartfile|
% - \marg{headline}: stored in |\theheadline|
% - \oarg{subheadline}: stored in |\thesubhead|
%
% NB: increasing the number of column options will significantly
% increase the amount of time that it takes to process your document,
% and slightly increase the chance of finding a layout solution that
% better fills the page.
% \begin{macrocode}
\newcommand{\article}[3][5]{
\rjl@readnumcols#1\relax\relax\relax\relax
\renewcommand{\theartfile}{#2}
\renewcommand{\theheadline}{#3}
% If we are follewed by a [ char, then the optional subhead is present.
% In which case, read it in and then process article sizes.
% Otherwise, we process article sizes directly.
% This is a bit clunky due to \TeX's low-level handling of optional
% parameters, hence we need to declare the call twice (once for each
% control path).
\@ifnextchar[{\rjl@readsubhead@and@process}{\renewcommand{\thesubhead}{}\rjl@process@article}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\rjl@readsubhead}
% This is used in the definition of |\article|. It consumes
% one argument in square brackets and assigns it to |\thesubhead|
% \begin{macrocode}
\def\rjl@readsubhead@and@process[#1]{
\renewcommand{\thesubhead}{#1}
\rjl@process@article
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\rasterimage}
% \oarg{captionplacement} T or B, then I or E (default BI for internal bottom)
% \marg{caption} Text to display above or below the article content
% \oarg{incrudegraphics-args} Arguments to pass to |\includegraphics|;
% defaults to |width=|\textit{width}|,height=|\textit{height}
% \marg{width} Width of the article
% \marg{height} Height of the article
% \marg{filename} Filename of the image. \textsc{png}, \textsc{pdf},
% TODO: extra arguments to includegraphics; use the starred form to
% crop rather than extend outside the box
% \textsc{jpeg} are supported by |pdflatex|.
% Include an image from the given file, scaled to the given
% dimensions.
%
% Because I want to minimise required dependencies, this is only
% usefully defined if the |graphicx| package is loaded; otherwise we
% out out an error on use.
%
% Note that the |draft| option is passed to |graphicx| by
% \LaTeX\ automatically, and disables the output of images, to speed
% up the preview.
%
% The placement of the image and caption are handled by the |rasterarticle|
% envinonment, defined below.
%
% \LaTeX\ has very poor support for commands with multiple optional
% arguments, so this uses nexted calls in plain-\TeX style to fill in
% each optional argument in turn, before finally calling |\rjl@rasterimage|.
% \begin{macrocode}
\newcommand{\rasterimage}{\@ifstar{\rjl@rasterimage@opts{*}}{\rjl@rasterimage@opts{}}}
\def\rjl@rasterimage@opts#1{\@ifnextchar[{\rjl@rasterimage@opts@{#1}}{\rjl@rasterimage{#1}{BI}}}
\def\rjl@rasterimage@opts@#1[#2]{\rjl@rasterimage@{#1}{#2}}
\def\rjl@rasterimage@#1#2{\@ifnextchar[{\rjl@rasterimage@opt{#1}{#2}}{\rjl@rasterimage{#1}{#2}{default}}}
\def\rjl@rasterimage@opt#1#2[#3]{\rjl@rasterimage{#1}{#2}{#3}}
\AtBeginDocument{
\@ifpackageloaded{graphicx}{
\newcommand{\rjl@rasterimage}[7]{
\begin{rasterarticle}[#2]{#4}{#5}{#6}
\typeout{graphin 1#1 2#2 3#3 4(#4) 5#5 6#6 7#7}
\ifthenelse{\equal{#3}{default}}{
\includegraphics#1[width=#5,height=#6]{#7}
}{
\includegraphics#1[#3]{#7}
}
\end{rasterarticle}
}
}{
\newcommand{\rjl@rasterimage}[7][]{
\ClassError{rjlnewsp4}{To use the \protect\rasterimage\space
command, you musc include the graphicx package in your preamble%
}{Add the line \protect\usepackage\protect{graphicx\protect} before
\protect\begin\protect{document\protect} in your main .tex file}
}
}
}
% \end{macrocode}
% \end{macro}
%
% \begin{environment}{rasterarticle}
% \oarg{captionplacement} T or B, then I or E (default BI for internal bottom)
% \marg{caption} Text to display above or below the article content
% \marg{width} Width of the article
% \marg{height} Height of the article
% Place a fixed-size item on the page (eg a photograph).
% The \LaTeX\ source inside the environment is evaluated inside a box
% of the given size.
%
% The |captionplacement| is a 2-letter code:
%\begin{itemize}
% \item[TI] \textbf{T}op, \textbf{I}nternal; the caption is placed
% above the content and the |height| specified includes the caption
% size (space of content is reduced to accommodate the caption)
% \item[TE] \textbf{T}op, \textbf{E}xternal: the caption is placed
% above the content and the |height| specified excludes the caption
% size (additional space is added to accommodate the caption)
% \item[BI] \textbf{B}ottom, \textbf{I}nternal; the caption is placed
% below the content and the |height| specified includes the caption
% size
% \item[BE] \textbf{B}ottom, \textbf{E}xternal: the caption is placed
% below the content and the |height| specified excludes the caption
% size
%\end{itemize}
% \begin{macrocode}
\newenvironment{rasterarticle}[4][BI]{
\typeout{Raster article #1}
\setlength{\newsartwidth}{#3} % for output
\hsize=#3\vsize=#4
\rjl@ifflag{#1}{Tt}{\global\rjl@captiontoptrue}{}
\rjl@ifflag{#1}{Bb}{\global\rjl@captiontopfalse}{}
\rjl@ifflag{#1}{Ii}{\addtolength{\vsize}{\dimexpr\ht\@tempboxa+\dp\@tempboxa}}{}
\rjl@ifflag{#1}{Ee}{}{}
\renewcommand{\theheadline}{#2}
\setbox\@tempboxa=\hbox to #3{\hfill\theheadline\hfill}
\setbox\rjl@parabox\vbox\bgroup
\ifrjl@captiontop\vbox{\usebox\@tempboxa}\fi
\vbox\bgroup
}{
\egroup
\ifrjl@captiontop\else\vbox{\usebox\@tempboxa}\fi
\egroup
\rjl@process@article@raster
}
% \end{macrocode}
%
% \begin{macro}{\ifrjl@captiontop}
% This is a \LaTeX flag used inside |rasterarticle|, to determine if
% the caption should be drawn above or below the content. It is set by
% a call to |\rjl@ifflag| when reading the arguments, and evaluated
% once before the macro (for above) and once after (below). This will
% probably do the opposite of what you expect in a bottom-to-top language.
% \begin{macrocode}
\newif\ifrjl@captiontop
% \end{macrocode}
% \end{macro}
% \end{environment}
%
% \begin{macro}{\rjl@ifflag}
% \marg{usertext}
% \marg{chars}
% \marg{macro}
%
% Executes |macro| if any characters in |chars| occur within
% |usertext|. All output is discarded. No ``else'' case is supported.
%
% This checks the first character, uses |\@gobble#1| to strip the
% first character, then calls itself recursively until |#1| is empty.
% It also recurses on |#2| using |\@gobble| to process any unprocessed
% flags.
%
% \LaTeX's temporary |\@tempboxa| (normally used for |\settowidth|
% etc) is commandeered to remove the trailing characters that would
% build up on the output.
%
% This is quite quick-and-dirty; in particular, |#3| may be
% expanded multiple times.
%
% \begin{macrocode}
\newcommand{\rjl@ifflag}[3]{
\setbox\@tempboxa\hbox{
\rjl@readflag#2
\ifthenelse{\equal{#2}{\rjl@flag}}{}{
\edef\rjl@nextflag{\@gobble#2}
\expandafter\rjl@ifflag\expandafter{#1}{\rjl@nextflag}{#3}
}
\ifthenelse{\equal{#1}{}}{}{
\expandafter\@ifnextchar\rjl@flag{
#3}{}#1
\expandafter\rjl@ifflag\expandafter{\@gobble#1}{#2}{#3}
}
}
\setbox\@tempboxa\box\voidb@x
}
\def\rjl@readflag#1{\edef\rjl@flag{#1}}
% \end{macrocode}
% \end{macro}
%
%
% \subsection{Lengths affecting alleys between articles}
% TODO: Be more clear about the distinction between alleys and gutters.
%
% \DescribeMacro{alleyleft}
% |\alleyleft| is the space of an alley placed to the left a downrule
% between articles.
% \begin{macrocode}
\newlength{\alleyleft}\setlength{\alleyleft}{0.06in}
% \end{macrocode}
%
% \DescribeMacro{downrulethick}
% |\downrulethick| is the thickness of a downrule between articles.
% \begin{macrocode}
\newlength{\downrulethick}\setlength{\downrulethick}{0.005in}
% \end{macrocode}
%
% \DescribeMacro{downruletop}
% |\downruletop| is the gap at the top of a downrule between articles.
% \begin{macrocode}
\newlength{\downruletop}\setlength{\downruletop}{0.25in}
% \end{macrocode}
%
% \DescribeMacro{downrulerbottom}
% |\downrulebottom| is the gap at the bottom of a downrule between articles.
% \begin{macrocode}
\newlength{\downrulebottom}\setlength{\downrulebottom}{0.25in}
% \end{macrocode}
%
% \DescribeMacro{alleyright}
% |\alleyright| is the space of an alley placed to the right of a downrule
% between articles.
% \begin{macrocode}
\newlength{\alleyright}\setlength{\alleyright}{0.06in}
% \end{macrocode}
%
% Aside: Unsure if \textit{siderule} is the correct term;
% vertical space between articles is common in newspaper layouts but
% not often talked about; most references I've seen just call any
% horizontal line a ``rule''. Here we need to be specific about rules
% in an alley between articles, so we'll stick with it for now.
%
% \DescribeMacro{alleytop}
% |\alleytop| is the space of an alley placed to the top a siderule
% between articles.
% \begin{macrocode}
\newlength{\alleytop}\setlength{\alleytop}{0.06in}
% \end{macrocode}
%
% \DescribeMacro{siderulethick}
% |\siderulethick| is the thickness of a siderule between articles.
% \begin{macrocode}
\newlength{\siderulethick}\setlength{\siderulethick}{0.005in}
% \end{macrocode}
%
% \DescribeMacro{sideruleleft}
% |\sideruleleft| is the gap at the left of a siderule between articles.
% \begin{macrocode}
\newlength{\sideruleleft}\setlength{\sideruleleft}{0.25in}
% \end{macrocode}
%
% \DescribeMacro{siderulerright}
% |\siderulelright| is the gap at the bottom of a siderule between articles.
% \begin{macrocode}
\newlength{\sideruleright}\setlength{\sideruleright}{0.25in}
% \end{macrocode}
%
% \DescribeMacro{alleybottom}
% |\alleybottom| is the space of an alley placed to the bottom of a siderule
% between articles.
% \begin{macrocode}
\newlength{\alleybottom}\setlength{\alleybottom}{0.06in}
% \end{macrocode}
%
% \begin{macro}{\newscolwidth}
% \begin{macro}{\newsartwidth}
% |\newscolwidth| (length) is the width of a column including
% gutters/alleys.
% It is set to 1.5" by default, but can be modified before an |\article|
% is included to change the size of that article. TODO: test me.
%
% |\newsartwidth| (length) is set automatically to the width of the article
% currently being typeset, up to the current column. This can be
% used to place dynamically-sized elements within an article;
% however, it will be larger than the current |\newscolwidth| if the
% article has multiple columns. TODO: This should really be the full
% article width, and we should use an @ length internally
%
% \begin{macrocode}
\newlength{\newscolwidth}
\setlength{\newscolwidth}{1.5in}
\newlength{\newsartwidth}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\rjl@output@headlines@common}
% This routine outputs the headlines.
%
% It takes no parameters, but experts |\theheadline| and |\thesubhead|
% to be set.
%
% We also define \DescribeMacro{\rjl@junkbox} a box register to hold
% the subheadline. This is so we can discard it without adding extra