| 1 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2 |
% |
| 3 |
% plain.sty |
| 4 |
% %%%%%%%%% |
| 5 |
% |
| 6 |
% Copyright 1990 David Carlisle |
| 7 |
% |
| 8 |
% This file may be distributed under the terms of the LPPL. |
| 9 |
% See 00readme.txt for details. |
| 10 |
|
| 11 |
% Defines a new environment plain, in which plain TeX files should be |
| 12 |
% LaTeX'able. |
| 13 |
% Defines \magnification and \bye to be no-op. |
| 14 |
% Re-enables some plain commands (\line, \eqalign ...) |
| 15 |
% Fakes some other plain commands (\footnote, \topinsert, ... ) |
| 16 |
% Keeps LaTeX's font definitions, and output routine. |
| 17 |
% |
| 18 |
% Example use: |
| 19 |
% \begin{plain} |
| 20 |
% \input{Somebodys_nasty_plain_file.tex} |
| 21 |
% \end{plain} |
| 22 |
% |
| 23 |
% You do not have to \input the plain commands, they can be entered |
| 24 |
% directly inside the plain environment. |
| 25 |
% |
| 26 |
% \begin{plain} |
| 27 |
% $$ \eqalign{1+2&=2+1\cr&=3}$$ |
| 28 |
% \end{plain} |
| 29 |
|
| 30 |
% Note that this style file is designed to make plain TeX files do |
| 31 |
% something sensible inside LaTeX. The page breaks, widths of lines, |
| 32 |
% fonts used etc may not be the same as obtained from plain TeX. |
| 33 |
|
| 34 |
% If you want exactly the same result from LaTeX as plain TeX use: (!!) |
| 35 |
% latex \&plain Somebodys_nasty_plain_file.tex |
| 36 |
|
| 37 |
% David Carlisle |
| 38 |
% [email protected] |
| 39 |
% 1990/11/14 |
| 40 |
|
| 41 |
% All of the code is from (l)plain.tex except a few definitions |
| 42 |
% which are marked with the comment: |
| 43 |
%DPC |
| 44 |
% and one set of three commands marked with the comment |
| 45 |
%RF (at DPC's request) |
| 46 |
% |
| 47 |
% one place where extraneous \par token, and two places where |
| 48 |
% extraneous spaces appeared corrected RF 2001/09/14 |
| 49 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 50 |
% 1990/11/14 initial version |
| 51 |
% 1994-5 Robin Fairbairns kindly fixed up a few things |
| 52 |
% 1996/04/22 Add support for plain TeX commands and primitives hit |
| 53 |
% by AMS packages. |
| 54 |
|
| 55 |
%DPC |
| 56 |
% Just to get started... |
| 57 |
\NeedsTeXFormat{LaTeX2e} |
| 58 |
\ProvidesPackage{plain}[1996/04/22 Plain TeX emulation (DPC)] |
| 59 |
|
| 60 |
%DPC |
| 61 |
\let\latex@end=\end |
| 62 |
|
| 63 |
%DPC |
| 64 |
% First a few \new's |
| 65 |
\newif\ifus@@latex |
| 66 |
\newif\if@cr@latex |
| 67 |
\newbox\tabs@latex |
| 68 |
\newbox\tabsyet@latex |
| 69 |
\newbox\tabsdone@latex |
| 70 |
|
| 71 |
%DPC |
| 72 |
% AMS packages might squash these, so ... |
| 73 |
\ifx\@@over\@undefined |
| 74 |
\let\@@over\over |
| 75 |
\fi |
| 76 |
\ifx\@@atop\@undefined |
| 77 |
\let\@@atop\atop |
| 78 |
\fi |
| 79 |
\ifx\@@above\@undefined |
| 80 |
\let\@@above\above |
| 81 |
\fi |
| 82 |
\ifx\@@overwithdelims\@undefined |
| 83 |
\let\@@overwithdelims\overwithdelims |
| 84 |
\fi |
| 85 |
\ifx\@@atopwithdelims\@undefined |
| 86 |
\let\@@atopwithdelims\atopwithdelims |
| 87 |
\fi |
| 88 |
\ifx\@@abovewithdelims\@undefined |
| 89 |
\let\@@abovewithdelims\abovewithdelims |
| 90 |
\fi |
| 91 |
|
| 92 |
%DPC |
| 93 |
% The plain environment: |
| 94 |
\def\plain{% |
| 95 |
% |
| 96 |
%DPC |
| 97 |
% put the \ifs and registers back |
| 98 |
\let\ifus@\ifus@@latex |
| 99 |
\let\if@cr\if@cr@latex |
| 100 |
\let\tabs\tabs@latex |
| 101 |
\let\tabsyet\tabsyet@latex |
| 102 |
\let\tabsdone\tabsdone@latex |
| 103 |
% |
| 104 |
\let\centering=\@centering |
| 105 |
% |
| 106 |
% \line changed to \@@line because LaTeX redefines \line |
| 107 |
\let\line\@@line |
| 108 |
% <-- this comment marker inserted by RF 2001-09-14 |
| 109 |
% LaTeX has its own tabbing environment, so PLAIN's is disabled. |
| 110 |
\def\cleartabs{\global\setbox\tabsyet\null \setbox\tabs\null}% |
| 111 |
\def\settabs{\setbox\tabs\null \futurelet\next\sett@b}% |
| 112 |
\let\+=\relax % in case this file is being read in twice |
| 113 |
\def\sett@b{\ifx\next\+\let\next\relax |
| 114 |
\def\next{\afterassignment\s@tt@b\let\next}% |
| 115 |
\else\let\next\s@tcols\fi\next}% |
| 116 |
\def\s@tt@b{\let\next\relax\us@false\m@ketabbox}% |
| 117 |
\def\tabalign{\us@true\m@ketabbox}% non-\outer version of \+ |
| 118 |
\outer\def\+{\tabalign}% |
| 119 |
\def\s@tcols##1\columns{\count@##1 \dimen@\hsize |
| 120 |
\loop\ifnum\count@>\z@ \@nother \repeat}% |
| 121 |
\def\@nother{\dimen@ii\dimen@ \divide\dimen@ii\count@ |
| 122 |
\setbox\tabs\hbox{\hbox to\dimen@ii{}\unhbox\tabs}% |
| 123 |
\advance\dimen@-\dimen@ii \advance\count@\m@ne}% |
| 124 |
% |
| 125 |
\def\m@ketabbox{\begingroup |
| 126 |
\global\setbox\tabsyet\copy\tabs |
| 127 |
\global\setbox\tabsdone\null |
| 128 |
\def\cr{\@crtrue\crcr\egroup\egroup |
| 129 |
\ifus@\unvbox\z@\lastbox\fi\endgroup |
| 130 |
\setbox\tabs\hbox{\unhbox\tabsyet\unhbox\tabsdone}}% |
| 131 |
\setbox\z@\vbox\bgroup\@crfalse |
| 132 |
\ialign\bgroup&\t@bbox####\t@bb@x\crcr}% |
| 133 |
% |
| 134 |
\def\t@bbox{\setbox\z@\hbox\bgroup}% |
| 135 |
\def\t@bb@x{\if@cr\egroup % now \box\z@ holds the column |
| 136 |
\else\hss\egroup \global\setbox\tabsyet\hbox{\unhbox\tabsyet |
| 137 |
\global\setbox\@ne\lastbox}% now \box\@ne holds its size |
| 138 |
\ifvoid\@ne\global\setbox\@ne\hbox to\wd\z@{}% |
| 139 |
\else\setbox\z@\hbox to\wd\@ne{\unhbox\z@}\fi |
| 140 |
\global\setbox\tabsdone\hbox{\box\@ne\unhbox\tabsdone}\fi |
| 141 |
\box\z@}% |
| 142 |
% |
| 143 |
% LaTeX has its own sectioning macros |
| 144 |
\outer\def\beginsection##1\par{\filbreak\bigskip |
| 145 |
\message{##1}\leftline{\bf##1}\nobreak\smallskip\vskip-\parskip |
| 146 |
\noindent}% |
| 147 |
% |
| 148 |
% LaTeX change: \bye is eliminated. |
| 149 |
%DPC |
| 150 |
% \bye made a no-op |
| 151 |
\let\bye\relax |
| 152 |
% |
| 153 |
%DPC |
| 154 |
% fake \supereject |
| 155 |
\let\supereject\clearpage |
| 156 |
% |
| 157 |
%DPC |
| 158 |
% \end made no-op unless it is followed by { |
| 159 |
\def\end{\@ifnextchar \bgroup\latex@end\relax}% |
| 160 |
% |
| 161 |
% LaTeX change: \eqalign eliminated, since it is replaced by the |
| 162 |
% eqnarray environment. |
| 163 |
\def\eqalign##1{\null\,\vcenter{\openup\jot\m@th |
| 164 |
\ialign{\strut\hfil$\displaystyle{####}$&$\displaystyle{{}####}$\hfil |
| 165 |
\crcr##1\crcr}}\,}% |
| 166 |
% |
| 167 |
% LaTeX: The following \eqalign type macros are eliminated, since |
| 168 |
% they are replaced by the eqnarray environment. |
| 169 |
\def\eqalignno##1{\displ@y \tabskip\centering |
| 170 |
\halign to\displaywidth{% |
| 171 |
\hfil$\@lign\displaystyle{####}$\tabskip\z@skip |
| 172 |
&$\@lign\displaystyle{{}####}$\hfil\tabskip\centering |
| 173 |
&\llap{$\@lign####$}\tabskip\z@skip\crcr |
| 174 |
##1\crcr}}% |
| 175 |
\def\leqalignno##1{\displ@y \tabskip\centering |
| 176 |
\halign to\displaywidth{% |
| 177 |
\hfil$\@lign\displaystyle{####}$\tabskip\z@skip |
| 178 |
&$\@lign\displaystyle{{}####}$\hfil\tabskip\centering |
| 179 |
&\kern-\displaywidth\rlap{$\@lign####$}\tabskip\displaywidth\crcr |
| 180 |
##1\crcr}}% |
| 181 |
% |
| 182 |
%DPC |
| 183 |
% Fake plain's \nopagenumers |
| 184 |
\def\nopagenumbers{\pagestyle{empty}}% |
| 185 |
% |
| 186 |
\def\advancepageno{\ifnum\pageno<\z@ \global\advance\pageno\m@ne |
| 187 |
\else\global\advance\pageno\@ne \fi}% increase |pageno| |
| 188 |
% |
| 189 |
\countdef\pageno\z@ |
| 190 |
% |
| 191 |
%DPC |
| 192 |
% Fake plain's \footnote with internal LaTeX commands |
| 193 |
\def\footnote##1{\def\@thefnmark{##1}\@footnotemark\@footnotetext}% |
| 194 |
% |
| 195 |
%DPC |
| 196 |
% Re-instate the primitive \underline |
| 197 |
%(LaTeX's version generates errors in some valid (plain) contexts) |
| 198 |
\let\underline\@@underline |
| 199 |
% |
| 200 |
%DPC |
| 201 |
% Re-instate plain's \item |
| 202 |
\def\item{\par\hang\textindent}% |
| 203 |
\def\itemitem{\par\indent \hangindent2\parindent \textindent}% |
| 204 |
% |
| 205 |
%DPC |
| 206 |
% Fake plain's \[top|mid|page]insert with LaTeX's figure environment. |
| 207 |
\def\topinsert{\begin{figure}[!tp]}% |
| 208 |
\def\midinsert{\begin{figure}[!htp]}% |
| 209 |
\def\pageinsert{\begin{figure}[p]}% |
| 210 |
\def\endinsert{\end{figure}}% |
| 211 |
% |
| 212 |
% \magnification doesn't work in LaTeX |
| 213 |
% |
| 214 |
%DPC |
| 215 |
% Make \magnification just gobble the next <number> |
| 216 |
\def\magnification{\count@}% |
| 217 |
% |
| 218 |
%RF (at DPC's request) |
| 219 |
% \proclaim \hang and \textindent from plain.tex (since they're now no |
| 220 |
% longer part of 2e kernel, but only compatibility) |
| 221 |
\def\proclaim ##1. ##2\par{\medbreak |
| 222 |
\noindent{\bf##1.\enspace}{\sl##2\par}% |
| 223 |
\ifdim\lastskip<\medskipamount \removelastskip\penalty55\medskip\fi}% |
| 224 |
% |
| 225 |
\def\hang{\hangindent\parindent}% |
| 226 |
% |
| 227 |
\def\textindent##1{\indent\llap{##1\enspace}\ignorespaces}% |
| 228 |
% |
| 229 |
% |
| 230 |
%DPC |
| 231 |
% Repair AMS `damage' |
| 232 |
\let\over\@@over |
| 233 |
\let\atop\@@atop |
| 234 |
\let\above\@@above |
| 235 |
\let\overwithdelims\@@overwithdelims |
| 236 |
\let\atopwithdelims\@@atopwithdelims |
| 237 |
\let\abovewithdelims\@@abovewithdelims |
| 238 |
% |
| 239 |
\def\cases##1{\left\{\,\vcenter{\normalbaselines\m@th |
| 240 |
\ialign{$####\hfil$&\quad####\hfil\crcr##1\crcr}}\right.}% |
| 241 |
\def\matrix##1{\null\,\vcenter{\normalbaselines\m@th |
| 242 |
\ialign{\hfil$####$\hfil&&\quad\hfil$####$\hfil\crcr |
| 243 |
\mathstrut\crcr\noalign{\kern-\baselineskip}% |
| 244 |
##1\crcr\mathstrut\crcr\noalign{\kern-\baselineskip}}}\,}% |
| 245 |
\def\pmatrix##1{\left(\matrix{##1}\right)}% |
| 246 |
% |
| 247 |
%DPC |
| 248 |
%end of \def\plain |
| 249 |
} |
| 250 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 251 |
\endinput |