summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/cjw/cjwplain.dtx
blob: 494882b5a55bf2f757ffb10e39728f0b274fe369 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
% \iffalse -*- LaTeX -*-
%
%    This is file `cjwplain.dtx'.  You can run this file through
%    LaTeX2e to get a .dvi file of documentation.  The file
%    `cjwplain.ins' should have come with this file.  Run LaTeX2e on
%    it to produce the actual input files.
%
%<+package|tabbing|output> \NeedsTeXFormat{LaTeX2e}
%<+package> \ProvidesPackage{cjwplain}
%<+tabbing> \ProvidesFile{cjwpltab.clo}
%<+output>  \ProvidesFile{cjwplout.clo}
%<+package|tabbing|output> [1995/05/01 v0.5
%<+package>                         Plain TeX Macros for LaTeX2e---CJW]
%<+tabbing>                 Plain TeX Tabbing Macros for LaTeX2e---CJW]
%<+output>                   Plain TeX Output Macros for LaTeX2e---CJW]
%
% \fi
\def\RCSinfo{$Id: cjwplain.dtx,v 1.2 1998/08/31 22:57:40 cwynne Exp $}

\def\RCSsplit $#1: #2,v #3 #4 #5 #6 #7${
  \gdef\filename   {#2}
  \gdef\fileversion{#3}
  \gdef\filedate   {#4}
  \gdef\filetime   {#5}
  \gdef\fileauthor {#6}
  \gdef\filelocker {#7}}

\expandafter\RCSsplit\RCSinfo
%% \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         \~}
%%
%  \CheckSum{1208}
% 
% \iffalse
%
%<*driver>
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{cjwplain.dtx}
   [\filedate\space v\fileversion\space
    The cjwplain Package for LaTeX2e---CJW]
\documentclass{ltxdoc}
  \GetFileInfo{cjwplain.dtx}
  \RecordChanges
\begin{document}
 \DocInput{\filename}
\end{document}
%</driver>
% \fi
%
% \DeclareRobustCommand{\cseq}[1]{\texttt{\bslash#1}}
% \DeclareRobustCommand{\pkg} [1]{\textsf{#1}}
% \DeclareRobustCommand{\env} [1]{\textsf{#1}}
%
% \title{The \textsf{cjwplain} Package\thanks{%
%   This file has version \fileversion.} \\
%   (\PlainTeX{} under \LaTeXe)}
% \author{Colin J.~Wynne\thanks{E-Mail at:
%   \texttt{cwynne@brutus.mts.jhu.edu},
%   \texttt{cwynne@jhu.edu}\,.}}
% \date{\filedate}
%
% \maketitle
%
% \setcounter{StandardModuleDepth}{1}
%
% {\parskip 0pt		^^A% This is the hack used by |doc.dtx|.
%  			^^A% (bug in \LaTeX?)
%  \tableofcontents
% }
%
% \section*{Introduction}
%
% I first started using \TeX{} some two-and-a-half years ago, having
% been introduced to it by several \TeX nophiles in my college math
% department.  I was aware from the start that there was a somehow
% `bastardised' version of this very good program which went by the
% name `\LaTeX'---invariably referred to by my \TeX{} mentors as
% `Lame\TeX'.  Most of you have probably heard this epithet before.
%
% Well, I count it as a good thing that I was discouraged from using
% \LaTeX{} at first, as I ended up writing quite a lot of \TeX{} code
% for myself before I ever got around to actually reading \textit{The
% \TeX book} in its entirety, which I did only a few
% months ago.  My first real project for \TeX{} was writing a large
% macro set for my undergraduate thesis---table of contents, marks for
% the running heads, chapter and section delineation and so forth.
% This growing library was expanded as I decided I wanted a good set
% of macros for writing outlines and by requirements for various
% papers, such as using endnotes in lieu of footnotes.  This rather
% haphazard collection of mine underwent a major change when I found
% the macro package for NFSS (version 1) under \PlainTeX{}, of which I
% promptly took advantage.
%
% This year I finally got my own computer, mainly to run \TeX{}.
% Given my newly purchased copy of \textit{The \TeX book} and some
% free time, I began to try to organise that cluster of code.  Having
% learned something in the meanwhile about generic markup, and why
% it is preferable, I started rewriting for more generalisation.  Also
% in the meanwhile, \LaTeXe{} had come along, greatly enhancing
% \LaTeX's own use of generic markup.  It also standardised the NFSS,
% which I had so come to appreciate.  Basically, between the various
% chunks of \LaTeXe{} which I had already hacked to work under my
% custom format and the movement towards increasingly generic code by
% both myself and the \LaTeX{} folks, that a convergence was taking
% place, so I finally decided to give \LaTeXe{} a serious looking-at.
%
% I started by printing out the documented source code.  I liked a lot
% of what I saw---but there were two problems.  Some of my favourite
% bits of \PlainTeX{} got left by the wayside.  For doing a lot of
% mathematics, I still find |\eqalign| to be the easiest way of
% aligning a bunch of related equations.  First, it involves less
% typing than a |\begin|\ldots|\end| pair, and I don't often need
% equation numbers---something not easily done away with under vanilla
% \LaTeX.  The bigger concern was that I had a bunch of source files
% that were written under \PlainTeX{} (or, rather, under \emph{my}
% \PlainTeX), and I didn't want to have to make the dozens of minor
% modifications necessary to get them to work under \LaTeX.
%
% So, I decided to learn how \LaTeX{} does things and to do so by
% writing a package that would, at its simplest, let me add a
% |\documentclass| and a |\begin{document}| line to one of my existing
% \PlainTeX{} sourc files and get it to compile under \LaTeX.
%
% Thus, I have written my first \LaTeX{} package.  I consider the main
% feature to be the ability to very easily add NFSS commands to a
% document written under \PlainTeX.  Secondly, maybe it will help
% convince some other \PlainTeX{} die-hards to give \LaTeX{} a try,
% inasmuch as all of their standard commands will be supported.
% Finally, it should let those who use \LaTeX{} exclusively to easily
% deal with \PlainTeX{} files if the need arises.
%
% \pagebreak
% Feel free to let me know if you find this package useful or, of
% course, if you find any bugs or wish to suggest improvements.
%
% \subsection*{This Package}
%
% This package is built over the file |ltplain.dtx|, or, more
% correctly, over those parts of |ltplain.dtx| which were changes to 
% or omissions of the original \PlainTeX{} source.  Some parts,
% specifically font changes, have not been reproduced in their
% entirety, due basically to the fact that such would be a pointless
% exercise.  See the comments in Section \ref{sec:font} for the
% explanation.
%
% Finally, this document prints with all source code because I feel
% the source itself, and the modifications to it, are the best
% documentation. 
%
%
% \section{Package Options}
%
% According to the documented \LaTeXe{} source file |ltplain.dtx|,
%  \begin{quote}
%    \LaTeX\ includes almost all of the functionality of Knuth's
%    original `Basic Macros' That is, the plain \TeX\ format described
%    in Appendix~B of the \TeX{}Book.
%  \end{quote}
% It seems to me that removing the qualifying `almost' would be no bad
% thing. 
%
% The idea behind the available options is that a given user may need
% only certain aspects of \PlainTeX{} added back in for a document.
% Furthermore, the additional code can sometimes be specified in
% different ways---\emph{i.e.}, either strictly according to the
% definitions of \PlainTeX{} or in a manner syntactically identical to
% \PlainTeX{} but functionally grounded in \LaTeX.  The overall goal,
% though, is completeness; I have therefore included everything, in
% one form or another, even when I can't think of a reason why some
% things would be necessary.
%
% There are nineteen regular and two special options available for the
% |cjwplain| package.  (All are entered in standard \LaTeX{} form, as
% optional arguments to the |\usepackage| command.  I only call two of
% them `special' so as to draw attention to them.)
%
% \subsection{Regular Options}
%
% \DescribeMacro{Options}
% The regular options are:
% \changes{v0.5}{1995/06/08}{Added \env{plainskips} and
% \env{plainskipsoff}.} 
%     \begin{center}
%   \begin{tabular}{llll}
% outerallocs     & diagnostics      & plainskips     \\
% outerallocsoff  & diagnosticsoff   & plainskipsoff  \\
% strictline      & tabbing          & strictitem     \\
% strictlineoff   & tabbingoff       & strictitemoff  \\
% eqalign         & magnification    & plainoutput    \\
% eqalignoff      & magnificationoff & plainoutputoff \\
% strictfootnotes & altfootnotes     & footnotesoff   \\
%   \end{tabular}
%     \end{center}
% Note that most of these options come in
% \meta{option}/\meta{option}|off| pairs.  These are
% particularly useful in conjunction with the special options
% (\ref{sec:spec-opts}) or to toggle the default options.  By default,
% the options |diagnostics|, |tabbing| and |eqalign| are active (just
% what I tend to use\ldots).
%
% The actual options will be explained in section \ref{sec:code}.
% Keep in mind, though, that some options affect others---for example
% selecting one of |strictfootnotes| and |altfootnotes| will
% automatically turn the other off; you can, however, disable both
% forms either with |footnotesoff| or by giving the two separate
% \ldots|off| commands separately.  Also, |plainoutput| requires
% |strictfootnotes| and |magnification|, but |plainoutputoff| itself
% does not disable the \PlainTeX{} footnote macros or magnification.
%
% \subsection{Special Options}
%   \label{sec:spec-opts}
%
% \DescribeMacro{none}\DescribeMacro{all}
% Two options, called |none| and |all|, are available to allow maximum
% flexibility.  These function because |cjwplain| calls the starred
% command |\ProcessOptions*| and therefore processes options in the
% order specified to |\usepackage|, and not the package's internal
% declaration order.  Thus, to make only \PlainTeX's tabbing commands
% available, one would use the call
%   \begin{verbatim}
% \usepackage[none,tabbing]{cjwplain}
%   \end{verbatim}
% and to use everything while leaving \LaTeX's |\item| command alone
% one would enter the command
%   \begin{verbatim}
% \usepackage[all,strictitemoff]{cjwplain}
%   \end{verbatim}
% in the preamble.
%
%\StopEventually{\PrintChanges\PrintIndex}
%
% \section{The Code}
%   \label{sec:code}
%
% \subsection{Declarations}
%
% The options are implemented as |\if| statements, as that seemed to
% me to be the easiest way of including or excluding relatively large
% sections of code.  First we allocate the |\if|s.
% \changes{v0.5}{1995/06/04}{Added \cseq{if@plainskips} and related macros
%   for the \textsf{plainskips} option.}
%    \begin{macrocode}
%<*package>
\newif\if@outerallocs     \@outerallocsfalse
\newif\if@diagnostics     \@diagnosticstrue
\newif\if@plainskips      \@plainskipsfalse
\newif\if@strictline      \@strictlinetrue
\newif\if@tabbing         \@tabbingtrue
\newif\if@strictitem      \@strictitemfalse
\newif\if@eqalign         \@eqaligntrue
\newif\if@strictfootnotes \@strictfootnotesfalse
\newif\if@altfootnotes    \@altfootnotesfalse
\newif\if@plainoutput     \@plainoutputfalse
\newif\if@magnification   \@magnificationfalse
%    \end{macrocode}
%
% Now we declare how the options affect these |\if| tests.
%
%    \begin{macrocode}
\DeclareOption{outerallocs}{\@outerallocstrue}
\DeclareOption{outerallocsoff}{\@outerallocsfalse}

\DeclareOption{diagnostics}{\@diagnosticstrue}
\DeclareOption{diagnosticsoff}{\@diagnosticsfalse}

\DeclareOption{plainskips}{\@plainskipstrue}
\DeclareOption{planiskipsoff}{\@plainskipsfalse}

\DeclareOption{strictline}{\@strictlinetrue}
\DeclareOption{strictlineoff}{\@strictlinefalse}

\DeclareOption{tabbing}{\@tabbingtrue}
\DeclareOption{tabbingoff}{\@tabbingfalse}

\DeclareOption{strictitem}{\@strictitemtrue}
\DeclareOption{strictitemoff}{\@strictitemfalse}

\DeclareOption{eqalign}{\@eqaligntrue}
\DeclareOption{eqalignoff}{\@eqalignfalse}
%    \end{macrocode}
%
% We will have two possible ways of providing a |\footnote| command.
% As these are mutually exclusive, we make sure that they cannot both
% be true.
%    \begin{macrocode}
\DeclareOption{strictfootnotes}{%
  \@strictfootnotestrue \@altfootnotesfalse}
\DeclareOption{altfootnotes}{%
  \@altfootnotestrue \@strictfootnotesfalse}
\DeclareOption{footnotesoff}{%
  \@altfootnotesfalse \@strictfootnotesfalse}

\DeclareOption{magnification}{\@magnificationtrue}
\DeclareOption{magnificationoff}{\@magnificationfalse}
%    \end{macrocode}
% To use \PlainTeX's entire output routine will require that
% magnification code as well as \PlainTeX{} style footnotes be
% defined.
%    \begin{macrocode}
\DeclareOption{plainoutput}{%
  \@plainoutputtrue \@strictfootnotestrue
  \@altfootnotesfalse \@magnificationtrue}
\DeclareOption{plainoutputoff}{\@plainoutputfalse}
%    \end{macrocode}
% The two special options are given.
%    \begin{macrocode}
\DeclareOption{none}{%
  \@outerallocsfalse    \@eqalignfalse
  \@diagnosticsfalse    \@plainskipsfalse
  \@strictfootnotesfalse\@strictlinefalse
  \@altfootnotesfalse   \@tabbingfalse
  \@magnificationfalse  \@strictitemfalse
  \@plainoutputfalse}

\DeclareOption{all}{%
  \@outerallocstrue    \@eqaligntrue
  \@diagnosticstrue    \@plainskipstrue
  \@strictfootnotestrue\@strictlinetrue
  \@altfootnotestrue   \@tabbingtrue
  \@magnificationtrue  \@strictitemtrue
  \@plainoutputtrue}
%    \end{macrocode}
% Finally we define a default option handling routine.  I prefer only
% a warning as opposed to an error.
%    \begin{macrocode}
\DeclareOption*{%
  \PackageWarning{cjwplain}{Unknown option `\CurrentOption'}}
%    \end{macrocode}
% Now that all the options are declared, we process them in the order
% specified in the package call.
%    \begin{macrocode}
\ProcessOptions*
%    \end{macrocode}
%
% \subsection{Allocation Calls: \env{outerallocs}}
%
%\DescribeMacro{\newcount}
%\DescribeMacro{\newdimen}
%\DescribeMacro{\newskip}
%\DescribeMacro{\newbox}
%\DescribeMacro{\newwrite}
%\DescribeMacro{\newfam}
% Originally \PlainTeX{} had all allocation macros (|\newcount|, etc.)
% defined as |\outer|.  \LaTeX{} redefines several of them to be
% non-outer.  Careful consideration has failed to yield to me why
% these would need to be rewritten as |\outer| in this package---any
% \PlainTeX{} file which expects |\outer| definitions would not call
% them in a non-outer position, and any other files would themselves
% have redefined versions of the macros.
%
% Since, however, it is such a small change, we will provide it.
% \textsc{Note:}  Using the |outerallocs| option  will break a good
% deal of standard \LaTeX{} code, namely the standard macros for
% counters and lengths.  This means you probably do \emph{not} want
% to use it.  It is here only for completeness's sake.
%    \begin{macrocode}
\if@outerallocs

\outer\def\newcount{\alloc@0\count\countdef\insc@unt}
\outer\def\newdimen{\alloc@1\dimen\dimendef\insc@unt}
\outer\def\newskip{\alloc@2\skip\skipdef\insc@unt}

\outer\def\newbox{\alloc@4\box\chardef\insc@unt}
\outer\def\newwrite{\alloc@7\write\chardef\sixt@@n}
\outer\def\newfam{\alloc@8\fam\chardef\sixt@@n}

\fi
%    \end{macrocode}
%
% \subsection{Error Processing: \env{diagnostics}}
%
% Any \PlainTeX{} afficianados using this package will feel more
% comfortable to have the standard values for error processing
% information.  One change, though.  \LaTeXe{} uses a \emph{counter}
% named |errorcontextlines|, and not a count.
%
%    \begin{macrocode}
\if@diagnostics

\showboxbreadth=5
\showboxdepth=3
\setcounter{errorcontextlines}{5}

\fi
%    \end{macrocode}
%
% \subsection{Skips: \env{plainskips}}
% \changes{v0.5}{1995/06/08}{Added the sub-section `Skips'.}
%
% When the |plainskips| option is selected, the three |\|\dots|skip|
% macros should unconditionally leave horizontal mode and insert a
% skip, like in \PlainTeX.
%    \begin{macrocode}
\if@plainskips
  \def\smallskip{\vskip\smallskipamount}
  \def\medskip{\vskip\medskipamount}
  \def\bigskip{\vskip\bigskipamount}
\fi
%    \end{macrocode}
%
% \subsection{Fonts}
%  \label{sec:font}
%
% A package already exists whereby oldstyle font commands can be
% given, namely |oldlfont|.  Furthermore, one can use |rawfonts|, if
% necessary, to load in such specific fonts as |\ninebf|, etc.
%
%    \begin{macrocode}
%\font\tenrm=cmr10 % roman text
%    \end{macrocode}
% \qquad$\vdots$
%    \begin{macrocode}
%\textfont\ttfam=\tentt
%    \end{macrocode}
%
% \subsection{The \cseq{line} Macro: \env{strictline}}
%
%\DescribeMacro{\line}
%\DescribeMacro{\latex@line}
% Now we get to the first tricky part.  The |\line| macro needs to be
% available to the |picture| environment in \LaTeX, as well as
% restoring the original \PlainTeX{} definition for our usage here.
% The good news is that \LaTeX{} \emph{only} uses |\line| inside of
% the |picture| environment.  So we employ the following solution:  we
% keep the definition of |\@@line| as per \LaTeX{} convention, and
% give in any case a user accessible |\plainline|.
%    \begin{macrocode}
\let\plainline\@@line

\if@strictline

%\def\@@line{\hbox to\hsize}		% Defined in |ltplain.dtx|
%    \end{macrocode}
% Now we define an internal name for the standard \LaTeX{} macro and
% restore the \PlainTeX{} definition.
%    \begin{macrocode}
\let\latex@line\line
\let\line\@@line
%    \end{macrocode}
% The definitions of  |\leftline|, |\rightline| and |\centerline| can
% be left as is (though users depending upon personal redefinitions of
% |\line| for special effects in these macros should simply put their
% redefinition into the macro |\@@line|).
%    \begin{macrocode}
%\def\leftline#1{\@@line{#1\hss}}
%\def\rightline#1{\@@line{\hss#1}}
%\def\centerline#1{\@@line{\hss#1\hss}}
%    \end{macrocode}
% Now we make a patch to the definition of |\@picture| (the workhorse
% macro for the |picture| environment) which will restore the \LaTeX{}
% definition only within that environment.
%    \begin{macrocode}
\def\@picture(#1,#2)(#3,#4){%
  \let\line\latex@line%
  \@picht#2\unitlength
  \setbox\@picbox\hbox to#1\unitlength\bgroup
    \hskip -#3\unitlength
    \lower #4\unitlength\hbox\bgroup
      \ignorespaces}

\fi
%    \end{macrocode}
%
% \subsection{Tab Alignments: \env{tabbing}}
%
% The tabbing macros from \PlainTeX{} use the |\newif| construction,
% so must occur at an |\outer| level.  Thus, they are included in a
% separate package.
% \changes{v0.5}{1995/06/04}{Use \cseq{InputIfFileExists} instead of
%   \cseq{RequirePackage} to input \pkg{cjwpltab.clo}; otherwise a
%   warning (error?) is produced, since the latter expects a
%   \pkg{.sty} file.}
%    \begin{macrocode}
\if@tabbing
  \InputIfFileExists{cjwpltab.clo}{}{%
    \PackageWarning{cjwplain}{Option `cjwpltab.clo' not found.}
    \@tabbingfalse}
\fi
%</package>
%<*tabbing>
%    \end{macrocode}
%
%\DescribeMacro{\cleartabs}
%\DescribeMacro{\settabs}
%\DescribeMacro{\tabalign}
%\DescribeMacro{\+}
% \LaTeX{} may have it's own tabbing environment, but I like
% \PlainTeX's.  The only potential conflict I saw was with the
% \verb|\+| macro.  However, \LaTeX{} only defines \verb|\+| inside of
% the |tabbing| environment itself, so there should be absolutely no
% problem.
%    \begin{macrocode}
\newif\ifus@ \newif\if@cr
\newbox\tabs \newbox\tabsyet \newbox\tabsdone

\def\cleartabs{\global\setbox\tabsyet\null \setbox\tabs\null}
\def\settabs{\setbox\tabs\null \futurelet\next\sett@b}
\let\+=\relax % in case this file is being read in twice
\def\sett@b{\ifx\next\+\let\next\relax
\def\next{\afterassignment\s@tt@b\let\next}%
  \else\let\next\s@tcols\fi\next}
\def\s@tt@b{\let\next\relax\us@false\m@ketabbox}
\def\tabalign{\us@true\m@ketabbox} % non-\outer version of \+
\outer\def\+{\tabalign}
\def\s@tcols#1\columns{\count@#1 \dimen@\hsize
  \loop\ifnum\count@>\z@ \@nother \repeat}
\def\@nother{\dimen@ii\dimen@ \divide\dimen@ii\count@
  \setbox\tabs\hbox{\hbox to\dimen@ii{}\unhbox\tabs}%
  \advance\dimen@-\dimen@ii \advance\count@\m@ne}

\def\m@ketabbox{\begingroup
  \global\setbox\tabsyet\copy\tabs
  \global\setbox\tabsdone\null
  \def\cr{\@crtrue\crcr\egroup\egroup
\ifus@\unvbox\z@\lastbox\fi\endgroup
\setbox\tabs\hbox{\unhbox\tabsyet\unhbox\tabsdone}}%
  \setbox\z@\vbox\bgroup\@crfalse
\ialign\bgroup&\t@bbox##\t@bb@x\crcr}

\def\t@bbox{\setbox\z@\hbox\bgroup}
\def\t@bb@x{\if@cr\egroup % now \box\z@ holds the column
  \else\hss\egroup \global\setbox\tabsyet\hbox{\unhbox\tabsyet
      \global\setbox\@ne\lastbox}% now \box\@ne holds its size
\ifvoid\@ne\global\setbox\@ne\hbox to\wd\z@{}%
\else\setbox\z@\hbox to\wd\@ne{\unhbox\z@}\fi
\global\setbox\tabsdone\hbox{\box\@ne\unhbox\tabsdone}\fi
  \box\z@}
%</tabbing>
%<*package>
%    \end{macrocode}
%
% \subsection{Itemising: \env{strictitem}}
%
%\DescribeMacro{\@@item}
%\DescribeMacro{\plainitem}
% Now we have another problem, namely the |\item| macro.  I
% unfortunately see no way to get around the fact that |\item| is a
% general macro in \LaTeX{}, and that the formats are completely
% different: i.e., \PlainTeX{} expects the \meta{label} to be the one
% mandatory argument, whereas \LaTeX's |\item| macro takes the
% \meta{label} as an optional argument.  Thus, the best I can think of
% is the following.  We redefine \PlainTeX's |\item| after standard
% \LaTeX{} practice,
%    \begin{macrocode}
\def\@@item{\par\hang\textindent}
%    \end{macrocode}
% and we |\let| it to something accessible in normal documents, the
% command |\plainitem|.
%    \begin{macrocode}
\let\plainitem\@@item
%    \end{macrocode}
% The command |\itemitem| can be taken care of directly.
%    \begin{macrocode}
\def\itemitem{\par\indent \hangindent2\parindent \textindent}
%    \end{macrocode}
%
% Now a user will have to replace all occurrences of |\item{foo}| with
% either |\item[foo]| or |\plainitem{foo}| (I imagine the choice will
% depend upon one's editor's facilities with regexps\ldots).  It's not
% perfect, but it's the only way I can think of to provide maximum
% compatibility.  Of course, we will still give the option,
% |strictitem|,  of using
% just the original definition, but that will probably not be terribly
% convenient for anyone trying to add \LaTeX{} features on top of an
% existing \PlainTeX{} source.  Thus, we will also provide the
% (slightly longwinded) replacement |\latexitem|.
%    \begin{macrocode}
\if@strictitem
  \let\latexitem\item
  \let\item\@@item
\fi
%    \end{macrocode}
%
% \subsection{Miscellaneous}
%
% \subsubsection{Sectioning}
%
% I have personally never used the \PlainTeX{} |\beginsection| macro,
% but somebody might have\ldots
%    \begin{macrocode}
\outer\def\beginsection#1\par{\vskip\z@ plus.3\vsize\penalty-250
  \vskip\z@ plus-.3\vsize\bigskip\vskip\parskip
  \message{#1}\leftline{\bf#1}\nobreak\smallskip\noindent}
%    \end{macrocode}
%
% \subsubsection{Proclamations}
%
% Once again we will leave \LaTeX's NFSS based redefinition, this time
% for the |\proclaim| command, in place.
%    \begin{macrocode}
%\outer\def\proclaim #1. #2\par{\medbreak
%  \noindent{\bfseries#1.\enspace}{\slshape#2\par}%
%  \ifdim\lastskip<\medskipamount \removelastskip\penalty55\medskip\fi}
%    \end{macrocode}
%
% \subsubsection{Paragraph Formatting}
%
% I have done some simple tests of \LaTeX's |\raggedright| macro, and
% it seems to me that it mimics the functionality of the \PlainTeX{}
% macro of the same name.  Therefore I see no reason to redefine it as
% part of this package.
%    \begin{macrocode}
%\def\raggedright{%
%  \rightskip\z@ plus2em \spaceskip.3333em \xspaceskip.5em\relax}
%    \end{macrocode}
% Another \LaTeX{} font change will also be left as is.
%    \begin{macrocode}
%\def\ttraggedright{\reset@font\ttfamily\rightskip\z@ plus2em\relax}
%    \end{macrocode}
%
% \subsubsection{Accents and Miscellaneous}
%
% These should work as is for \PlainTeX{} documents.
%    \begin{macrocode}
%\def\_{\leavevmode \kern.06em \vbox{\hrule \@width.3em}}
%\def\AA{\leavevmode\setbox0\hbox{h}\dimen@\ht0\advance\dimen@-1ex%
%  \rlap{\raise.67\dimen@\hbox{\char'27}}A}
%    \end{macrocode}
% Nor do I see a reason to change these back to \PlainTeX{}
% definitions.
%    \begin{macrocode}
%\def\pd#1{\oalign{#1\crcr\hidewidth\sh@ft{08}.\hidewidth}}
%\def\d{\protect\pd}
%
%\def\pb#1{\oalign{#1\crcr\hidewidth\sh@ft{29}%
%\vbox to.2ex{\hbox{\char22}\vss}\hidewidth}}
%\def\b{\protect\pb}
%
%\def\pc#1{\setbox\z@\hbox{#1}\ifdim\ht\z@=1ex\accent24 #1%
%  \else{\ooalign{\unhbox\z@\crcr\hidewidth\char24\hidewidth}}\fi}
%\def\c{\protect\pc}
%
%\def\pt#1{{\edef\next{\the\font}\the\textfont1\accent127\next#1}}
%\def\t{\protect\pt}
%    \end{macrocode}
%
% The \LaTeX{} definition of |\ldots| is more or less identical to the
% \PlainTeX{} macro |\dots|.  So we will leave this alone, too.
%    \begin{macrocode}
%\def\dots{\ldots}
%    \end{macrocode}
%
% These changes, as others before, only add functionality without
% seeming to limit \PlainTeX{} usage, so no change will be made.
%    \begin{macrocode}
%\def\hrulefill{\leavevmode\leaders\hrule\hfill\kern\z@}
%\def\dotfill{\leavevmode\cleaders
%     \hbox{$\m@th \mkern1.5mu.\mkern1.5mu$}\hfill\kern\z@}
%
%\def\longrightarrow{\protect\@lra}
%  \def\@lra{\relbar\joinrel\rightarrow}
%\def\longleftarrow{\protect\@lla}
%   \def\@lla{\leftarrow\joinrel\relbar}
%    \end{macrocode}
%
% \subsubsection{Ending the Document}
%
% We simply add the |\bye| macro back in, though the |\end| should be
% changed to the \LaTeX{} |\end{document}|.
%    \begin{macrocode}
\outer\def\bye{\end{document}}
%    \end{macrocode}
%
%
% \subsubsection{Math Commands}
%
% Operators and other math-mode font-related changes will be ignored
% with as other NFSS alterations already mentioned.
%    \begin{macrocode}
%\def\log{\mathop{\rm log}\nolimits}
%\def\lg{\mathop{\rm lg}\nolimits}
%\def\deg{\mathop{\rm deg}\nolimits}
%    \end{macrocode}
%\qquad$\vdots$
%    \begin{macrocode}
%\def\bmod{\mskip-\medmuskip\mkern5mu
%  \mathbin{\rm mod}\penalty900\mkern5mu\mskip-\medmuskip}
%\def\pmod#1{\allowbreak\mkern18mu({\rm mod}\,\,#1)}
%    \end{macrocode}
% Various |\matrix| type command, including |\bordermatrix| and
% |\cases| have similarly been rewritten for NFSS commands under
% \LaTeX. 
%
% \subsection{Math Alignment: \env{eqalign}}
%
%\DescribeMacro{\eqalign}
%\DescribeMacro{\eqalignno}
%\DescribeMacro{\leqalignno}
% If the |eqalign| option has been selected, we add |\eqalign| back
% in, as well as related macros.  Notice that we use the |\@centering|
% macro provided by \LaTeX, because \LaTeX{} itself reserves
% |\centering|.  We also supply a user macro |\plaincentering| in case
% such is needed. 
%    \begin{macrocode}
\let\plaincentering\@centering

\if@eqalign

\def\eqalign#1{\null\,\vcenter{\openup\jot\m@th
  \ialign{\strut\hfil$\displaystyle{##}$&$\displaystyle{{}##}$\hfil
      \crcr#1\crcr}}\,}

\def\eqalignno#1{\displ@y \tabskip\@centering
  \halign to\displaywidth{\hfil$\@lign\displaystyle{##}$\tabskip\z@skip
    &$\@lign\displaystyle{{}##}$\hfil\tabskip\@centering
    &\llap{$\@lign##$}\tabskip\z@skip\crcr
    #1\crcr}}
\def\leqalignno#1{\displ@y \tabskip\@centering
  \halign to\displaywidth{\hfil$\@lign\displaystyle{##}$\tabskip\z@skip
    &$\@lign\displaystyle{{}##}$\hfil\tabskip\@centering
    &\kern-\displaywidth\rlap{$\@lign##$}\tabskip\displaywidth\crcr
    #1\crcr}}

\else
%    \end{macrocode}
%\DescribeEnv{eqnarray*}
% If the user does not choose this option, we will instead define an
% |eqnarray*| environment which does not number equations.
%    \begin{macrocode}
\@namedef{eqnarray*}{%
  \let \\ \cr $$\null\,\vcenter{\openup\jot\m@th
  \ialign{\strut\hfil$\displaystyle{##}$&$\displaystyle{{}##}$\hfil\crcr}}}
\@namedef{endeqnarray*}{\crcr}

\fi
%    \end{macrocode}
%
% \subsection{Output Routine: \env{plainoutput}}
%
% The output routines also involve |\newif| commands, and are
% therefore also relegated to a separate package.
% \changes{v0.5}{1995/06/04}{Use \cseq{InputIfFileExists} instead of
%   \cseq{RequirePackage} to input \pkg{cjwplout.clo}; otherwise a
%   warning (error?) is produced, since the latter expects a
%   \pkg{.sty} file.}
%    \begin{macrocode}
\if@plainoutput
  \InputIfFileExists{cjwplout.clo}{}{%
    \PackageWarning{cjwplain}{Option `cjwplout.clo' not found.}
    \@tabbingfalse}
\fi
%</package>
%<*output>
%    \end{macrocode}
%
%\DescribeMacro{\headline}
%\DescribeMacro{\footline}
%\DescribeMacro{\pageno}
%\DescribeMacro{\folio}
% If the user wishes to use the entire \PlainTeX{} output routine, we
% first redefine the normal versions of |headline|, |footline| and
% |pageno|, as well as related macros.  We will use NFSS definitions
% in place of |\tenrm|.
%    \begin{macrocode}
\countdef\pageno=0 \pageno=1 % first page is number 1
\newtoks\headline \headline={\hfil} % headline is normally blank
\newtoks\footline \footline={\hss\reset@font\folio\hss}
  % footline is normally a centered page number in font \tenrm
\def\nopagenumbers{\footline{\hfil}} % blank out the footline
\def\folio{%
  \ifnum\pageno<\z@ \romannumeral-\pageno \else\number\pageno \fi}
\def\advancepageno{\ifnum\pageno<\z@ \global\advance\pageno\m@ne
  \else\global\advance\pageno\@ne \fi} % increase |pageno|
%    \end{macrocode}
%\DescribeMacro{\raggedbottom}
%\DescribeMacro{\normalbottom}
% We also supply the |\raggedbottom| macro and its counterpart,
% |\normalbottom|.
%    \begin{macrocode}
\newif\ifr@ggedbottom
\def\raggedbottom{\topskip 10\p@ plus60\p@ \r@ggedbottomtrue}
\def\normalbottom{\topskip 10\p@ \r@ggedbottomfalse}
                                       % undoes \raggedbottom
%    \end{macrocode}
%
%\DescribeMacro{\topinsert}
%\DescribeMacro{\midinsert}
%\DescribeMacro{\pageinsert}
% If the entire output routine is being used, we define the
% \PlainTeX{} insertion macros as normal.
%    \begin{macrocode}
\newinsert\topins
\newif\ifp@ge \newif\if@mid
\def\topinsert{\@midfalse\p@gefalse\@ins}
\def\midinsert{\@midtrue\@ins}
\def\pageinsert{\@midfalse\p@getrue\@ins}
\skip\topins=\z@skip % no space added when a topinsert is present
\count\topins=1000 % magnification factor (1 to 1)
\dimen\topins=\maxdimen % no limit per page
\def\@ins{\par\begingroup\setbox\z@\vbox\bgroup} % start a \vbox
\def\endinsert{\egroup % finish the \vbox
    \if@mid \dimen@\ht\z@ \advance\dimen@\dp\z@ \advance\dimen@12\p@
  \advance\dimen@\pagetotal \advance\dimen@-\pageshrink
  \ifdim\dimen@>\pagegoal\@midfalse\p@gefalse\fi\fi
    \if@mid \bigskip\box\z@\bigbreak
    \else\insert\topins{\penalty100 % floating insertion
  \splittopskip\z@skip
  \splitmaxdepth\maxdimen \floatingpenalty\z@
  \ifp@ge \dimen@\dp\z@
  \vbox to\vsize{\unvbox\z@\kern-\dimen@}% depth is zero
  \else \box\z@\nobreak\bigskip\fi}\fi\endgroup}
%    \end{macrocode}
%
%\DescribeMacro{\plainoutput}
% Now we define the main part of the output routine.  We use |\@@line|
% instead of |\line|, since |\@@line| is guaranteed to have the
% definition we want.
%    \begin{macrocode}
\def\plainoutput{\shipout\vbox{\makeheadline\pagebody\makefootline}%
  \advancepageno
  \ifnum\outputpenalty>-\@MM \else\dosupereject\fi}
\def\pagebody{\vbox to\vsize{\boxmaxdepth\maxdepth \pagecontents}}
\def\makeheadline{\vbox to\z@{\vskip-22.5\p@
  \@@line{\vbox to8.5\p@{}\the\headline}\vss}\nointerlineskip}
\def\makefootline{\baselineskip24\p@\@@line{\the\footline}}
\def\dosupereject{\ifnum\insertpenalties>\z@
                 % something is being held over
  \@@line{}\kern-\topskip\nobreak\vfill\supereject\fi}

\def\pagecontents{\ifvoid\topins\else\unvbox\topins\fi
  \dimen@=\dp\@cclv \unvbox\@cclv % open up \box255
  \ifvoid\footins\else % footnote info is present
    \vskip\skip\footins
    \footnoterule
    \unvbox\footins\fi
  \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
%    \end{macrocode}
% Finally, we make the \PlainTeX{} output routines active again.
%    \begin{macrocode}
  \output{\plainoutput}
%</output>
%<*package>
%    \end{macrocode}
%
% \subsubsection{Page Numbering, Running Heads and Miscellaneous}
%
% We can make the \PlainTeX{} head and foot commands accessible (after
% a fashion), even if the entire output routine is not being used.
% \LaTeXe{} provides the commands |\@oddhead| and |\@evenhead|, as
% well as their footline equivalents.  Therefore we can give the
% following versions.
%    \begin{macrocode}
\if@plainoutput\else

\def\footline{\@ifnextchar ={\@@footline}{\@@footline=}}
\def\@@footline=#1{\gdef\@oddfoot{#1} \gdef\@evenfoot{#1}}

\def\headline{\@ifnextchar ={\@@headline}{\@@headline=}}
\def\@@headline=#1{\gdef\@oddhead{#1} \gdef\@evenhead{#1}}

\def\nopagenumbers{\let\@oddfoot\relax \let\@evenfoot\relax}
%    \end{macrocode}
% Since the \PlainTeX{} |\headline| and |\footline| macros are
% actually tokens, we have to allow that the assignments to them can
% be made with an optional $=$.  The use of |\@ifnextchar =| nicely
% takes care of that.  This will alas be a slightly inefficient use of
% the macros, as many \PlainTeX{} heads and feet already test for odd
% and even pages---but not all of them.  So, we compromise.
%
% Now we can simply make |\pageno| an equivalent for the \LaTeX{}
% counter |\c@page|.
%    \begin{macrocode}
\let\pageno\c@page
%    \end{macrocode}
% This means that assignments can either be made in primitive fashion
% directly to |\pageno| or in \LaTeX fashion to the |page| counter.
% We would also like to have the \PlainTeX{} |\folio| macro.  We are
% going to expand upon this slightly, though.  I find |\folio|
% generally to be a useful command, so we will write it in such a way
% as to make it useful with \LaTeX{} counters (as with, say, the
% |\arabic| macro) as well as with counts.
%    \begin{macrocode}
\newcommand{\folio}[1][\pageno]{\@folio{#1}}
\def\@folio#1{%
  \edef\@tempa{\string#1}%
  \expandafter\@ifundefined{c@\@tempa}% % Does the counter exist?
    {%					%   No such counter.
      \ifnum #1 <\z@ \romannumeral-#1
        \else \number #1
      \fi
    }%
    {%					%   It is a counter.
      \ifnum\value{#1}<\z@ \roman{#1} \else \arabic{#1} \fi}
  }
%    \end{macrocode}
% This is not, unfortunately, perfect, in that it must be used with an
% optional argument (|\folio[section]|) as opposed to the normal style
% (|\arabic{section}|).  On the other hand, I can't think of many
% applications for |\folio| \emph{other} than page numbering.  At any
% rate, we finish page numbering with the incrementation command.
%    \begin{macrocode}
\def\advancepageno{\ifnum\pageno<\z@ \global\advance\pageno\m@ne
  \else\global\advance\pageno\@ne \fi}
%    \end{macrocode}
%
% One more bit from the \PlainTeX{} output routine needs to be dealt
% with.  Although \LaTeX's |\raggedbottom| macro will suffice to
% simulate \PlainTeX's command of the same name, we need to add a
% |\let| command to enable \PlainTeX's counterpart, |\normalbottom|.
%    \begin{macrocode}
\let\normalbottom\flushbottom
%    \end{macrocode}
%
% \subsubsection{Insertions}
%
% If the \PlainTeX{} output routine is not being used, we simulate the
% insertions using \LaTeX's |figure| environment.  
%    \begin{macrocode}
\def\topinsert{\begin{figure}[t]}
\def\pageinsert{\begin{figure}[p]}
\def\midinsert{\begin{figure}[htpb]}
\def\endinsert{\end{figure}}

\fi
%    \end{macrocode}
%
% \subsubsection{Footnotes: \env{srictfootnotes},
%   \env{altfootnotes}} 
%
% We define |\@@footnote| as \PlainTeX's footnoting macro.
%    \begin{macrocode}
%\newinsert\footins

\let\latex@footnote\footnote

\def\@@footnote#1{\let\@sf\empty % parameter #2 (the text) is read later
  \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi
  #1\@sf\vfootnote{#1}}
\def\vfootnote#1{\insert\footins\bgroup
  \interlinepenalty\interfootnotelinepenalty
  \splittopskip\ht\strutbox % top baseline for broken footnotes
  \splitmaxdepth\dp\strutbox \floatingpenalty\@MM
  \leftskip\z@skip \rightskip\z@skip \spaceskip\z@skip
  \xspaceskip\z@skip
  \textindent{#1}\footstrut\futurelet\next\fo@t}
\def\fo@t{\ifcat\bgroup\noexpand\next \let\next\f@@t
  \else\let\next\f@t\fi \next}
\def\f@@t{\bgroup\aftergroup\@foot\let\next}
\def\f@t#1{#1\@foot}
\def\@foot{\strut\egroup}
\def\footstrut{\vbox to\splittopskip{}}
%    \end{macrocode}
% \LaTeX{} leaves these initializations for the |\footins| insert.
%    \begin{macrocode}
%\skip\footins=\bigskipamount % space added when footnote is present
%\count\footins=1000 % footnote magnification factor (1 to 1)
%\dimen\footins=8in % maximum footnotes per page
%    \end{macrocode}
%
% Now we have several options for how to really deal with footnotes.
% The easy answer is to do them entirely according to \PlainTeX.
%    \begin{macrocode}
\if@strictfootnotes
  \let\footnote\@@footnote
\fi
%    \end{macrocode}
% The second option is to just use the \LaTeX{} |\footnote| command.
% This needs no rewriting, of course.  The last option is to rewrite
% \LaTeX's |\footnote| macro to use the \PlainTeX{} format instead of
% the \LaTeX{} format, which uses an optional argument.
%    \begin{macrocode}
\if@altfootnotes
  \def\footnote#1{\latex@footnote[#1]}
\fi
%    \end{macrocode}
% \LaTeX{} keeps \PlainTeX's |\footnoterule| as the default.
%    \begin{macrocode}
%\def\footnoterule{\kern-3\p@
%  \hrule \@width 2in \kern 2.6\p@} % the \hrule is .4pt high
%    \end{macrocode}
%
% \subsubsection{Magnification: \env{magnification}}
%
% The last part of \PlainTeX{} for which we need to account is
% magnification. 
% The magnification macros are easily reinstated, either as part of
% the overall \PlainTeX{} output routine or standalone.  Since the
% |\mag| primitive is not disabled, it \emph{could} still be used in
% \LaTeX.  However, \LaTeX{} does not itself work with |true| units
% any usage of |\magnification| could do some strange things to your
% page layouts.
%    \begin{macrocode}
\if@magnification
  \def\magnification{\afterassignment\m@g\count@}
  \def\m@g{\mag\count@
    \hsize6.5truein\vsize8.9truein\dimen\footins8truein}
\fi
%    \end{macrocode}
%
% This brings us to the end of the main package.
%    \begin{macrocode}
%</package>
%    \end{macrocode}
%\Finale