]> mj.ucw.cz Git - ucwmac.git/commitdiff
Replaced compatibility levels by ucwmac/ucwmac2 split
authorMartin Mares <mj@ucw.cz>
Wed, 27 Jun 2018 08:45:38 +0000 (10:45 +0200)
committerMartin Mares <mj@ucw.cz>
Wed, 27 Jun 2018 09:39:06 +0000 (11:39 +0200)
In the long run, I want to place as small a burden as I can
on the users of the most recent version.

test-labels.tex
test-ref.tex
test.tex
ucw-luacsplain.ini
ucwmac.tex
ucwmac2.tex [new file with mode: 0644]

index 918f4578f64d5e9ef4fdb3925b6255e8bd17abbc..903569a63d056fc07f49d776b475e6fe7fa741c0 100644 (file)
@@ -1,4 +1,4 @@
-\input ucwmac.tex
+\input ucwmac2.tex
 \ucwmodule{labels}
 
 \setuplabels{3}{7}
index 4c05c66d275d576e67ecdbf8edfa3b992e45231f..a503c76166da4696b0abc668261fab973bdd7412 100644 (file)
@@ -1,5 +1,4 @@
-\input ucwmac.tex
-\ucwcompat\ucwmaxcompat
+\input ucwmac2.tex
 \ucwmodule{ofs}
 \ucwmodule{ref}
 \ucwmodule{pdfmeta}
index 23ea6f34f9904ef1637cf106c93d77912aac5f53..db93c0c87e3a35b1d3a0521ac36309a1f82dee42 100644 (file)
--- a/test.tex
+++ b/test.tex
@@ -1,5 +1,4 @@
-\input ucwmac.tex
-\ucwcompat\ucwmaxcompat
+\input ucwmac2.tex
 \ucwmodule{ofs}
 \ucwmodule{verb}
 \ucwmodule{algo}
index 8e7215580b41cda99997c3c71bda1d1faca7a43a..a06af6d4197bf70cc616949a684620d352b382b7 100644 (file)
@@ -57,7 +57,7 @@
    \message{Loaded ucw-luacsplain 2018-06}%
    % These packages do not survive dumping, defer loading to \everyjob
    \input ltluatex.tex
-   \input ucwmac.tex
+   \input ucwmac2.tex
    \input ucw-luaofs.tex
 }
 
index a42fe489bbbd48d3da377c57ca003553532c6484..0d2c9061071c31b735af8156c9489ec30bf791de 100644 (file)
@@ -1,410 +1,6 @@
-% The UCW Macro Collection (a successor of mjmac.tex)
-% Written by Martin Mares <mj@ucw.cz> in 2010--2018 and placed into public domain
-% -------------------------------------------------------------------------------
+% Emulate behavior of historic ucwmac
 
-\ifx\ucwmodule\undefined\else\endinput\fi
+\input ucwmac2.tex
 
-%%% Prolog %%%
-
-% We'll use internal macros of plain TeX
-\catcode`@=11
-
-\ifx\eTeXversion\undefined
-\errmessage{ucwmac requires the e-TeX engine or its successor}
-\fi
-
-%%% PDF output detection %%%
-
-\newif\ifpdf
-\pdffalse
-
-\ifx\pdfoutput\undefined
-\else\ifnum\pdfoutput>0
-       \pdftrue
-       \pdfpkresolution=600    % Provide a reasonable default
-\fi\fi
-
-\ifx\directlua\undefined\else
-       % In LuaTeX \pdfpkresolution is not enough
-       \directlua{kpse.init_prog("luatex", 600, "ljfour")}
-\fi
-
-%%% Temporary registers %%%
-
-\newcount\tmpcount
-\newdimen\tmpdimen
-
-%%% Auxiliary macros %%%
-
-% Prepend/append #2 to the definition of #1
-\long\def\prependef#1#2{\expandafter\def\expandafter#1\expandafter{#2#1}}
-\long\def\appendef#1#2{\expandafter\def\expandafter#1\expandafter{#1#2}}
-
-% Variants of \def and \let, where the control sequence name is given as a string
-\def\sdef#1{\expandafter\def\csname#1\endcsname}
-\def\slet#1#2{\expandafter\let\csname#1\expandafter\endcsname\csname#2\endcsname}
-
-% Add \protected to an existing macro
-\def\addprotected#1{\protected\edef#1{\expandafter\unexpanded\expandafter{#1}}}
-
-% Protect ~
-\addprotected~
-
-\def\ucwwarn#1{\immediate\write16{*** UCWmac warning: #1 ***}}
-
-%%% Page size and margins %%%
-
-% If you modify these registers, call \setuppage afterwards
-\ifx\luatexversion\undefined
-       % In LuaTeX, \pagewidth and \pageheight are primitive
-       \newdimen\pagewidth
-       \newdimen\pageheight
-\fi
-\newdimen\leftmargin
-\newdimen\rightmargin
-\newdimen\topmargin
-\newdimen\bottommargin
-\newdimen\evenpageshift
-
-\def\setuppage{%
-       \hsize=\pagewidth
-       \advance\hsize by -\leftmargin
-       \advance\hsize by -\rightmargin
-       \vsize=\pageheight
-       \advance\vsize by -\topmargin
-       \advance\vsize by -\bottommargin
-       \hoffset=\leftmargin
-       \advance\hoffset by -1truein
-       \voffset=\topmargin
-       \advance\voffset by -1truein
-       \ifpdf
-               \pdfhorigin=1truein
-               \pdfvorigin=1truein
-               \ifx\luatexversion\undefined
-                       \pdfpagewidth=\pagewidth
-                       \pdfpageheight=\pageheight
-               \fi
-       \fi
-}
-
-% Set multiple margins to the same value
-\def\sethmargins#1{\leftmargin=#1\relax\rightmargin=#1\relax\evenpageshift=0pt\relax}
-\def\setvmargins#1{\topmargin=#1\relax\bottommargin=#1\relax}
-\def\setmargins#1{\sethmargins{#1}\setvmargins{#1}}
-
-% Define inner/outer margin instead of left/right
-\def\setinneroutermargin#1#2{\leftmargin#1\relax\rightmargin#2\relax\evenpageshift=\rightmargin\advance\evenpageshift by -\leftmargin}
-
-% Use a predefined paper format, calls \setuppage automagically
-\def\setpaper#1{%
-       \expandafter\let\expandafter\currentpaper\csname paper-#1\endcsname
-       \ifx\currentpaper\relax
-               \errmessage{Undefined paper format #1}
-       \fi
-       \currentpaper
-}
-
-% Switch to landscape orientation, calls \setuppage automagically
-\def\landscape{%
-       \dimen0=\pageheight
-       \pageheight=\pagewidth
-       \pagewidth=\dimen0
-       \setuppage
-}
-
-% Common paper sizes
-\def\defpaper#1#2#3{\expandafter\def\csname paper-#1\endcsname{\pagewidth=#2\pageheight=#3\setuppage}}
-\defpaper{a3}{297truemm}{420truemm}
-\defpaper{a4}{210truemm}{297truemm}
-\defpaper{a5}{148truemm}{210truemm}
-\defpaper{letter}{8.5truein}{11truein}
-\defpaper{legal}{8.5truein}{14truein}
-
-% Default page parameters
-\setmargins{1truein}
-\setpaper{a4}
-
-%%% Macros with optional arguments %%%
-
-% After \def\a{\withoptarg\b}, the macro \a behaves in this way:
-%      \a[arg]         does \def\optarg{arg} and then it expands \b
-%      \a              does \let\optarg=\relax and then it expands \b
-\def\withoptarg#1{\let\xoptcall=#1\futurelet\next\xopt}
-\def\xopt{\ifx\next[\expandafter\xoptwith\else\let\optarg=\relax\expandafter\xoptcall\fi}
-\def\xoptwith[#1]{\def\optarg{#1}\xoptcall}
-
-% A shortcut for defining macros with optional arguments:
-% \optdef\macro behaves as \def\domacro, while \macro itself is defined
-% as a wrapper calling \domacro using \withoptarg.
-\def\optdef#1{%
-       \edef\xoptname{\expandafter\eatbackslash\string#1}%
-       \edef#1{\noexpand\withoptarg\csname do\xoptname\endcsname}%
-       \expandafter\def\csname do\xoptname\endcsname
-}
-
-% Trick: \eatbackslash eats the next backslash of category 12
-\begingroup\lccode`\+=`\\
-\lowercase{\endgroup\def\eatbackslash+{}}
-
-% Expand to the optional argument if it exists
-\def\optargorempty{\ifx\optarg\relax\else\optarg\fi}
-
-%%% Placing material at specified coordinates %%%
-
-% Set all dimensions of a given box register to zero
-\def\smashbox#1{\ht#1=0pt \dp#1=0pt \wd#1=0pt}
-\long\def\smashedhbox#1{{\setbox0=\hbox{#1}\smashbox0\box0}}
-\long\def\smashedvbox#1{{\setbox0=\vbox{#1}\smashbox0\box0}}
-
-% Variants of \llap and \rlap working equally on both sides and/or vertically
-\def\hlap#1{\hbox to 0pt{\hss #1\hss}}
-\def\vlap#1{\vbox to 0pt{\vss #1\vss}}
-\def\clap#1{\vlap{\hlap{#1}}}
-
-% \placeat{right}{down}{hmaterial} places <hmaterial>, so that its
-% reference point lies at the given position wrt. the current ref point
-\long\def\placeat#1#2#3{\smashedhbox{\hskip #1\lower #2\hbox{#3}}}
-
-% Like \vbox, but with reference point in the upper left corner
-\long\def\vhang#1{\vtop{\hrule height 0pt\relax #1}}
-
-% Like \vhang, but respecting interline skips
-\long\def\vhanglines#1{\vtop{\hbox to 0pt{}#1}}
-
-% Crosshair with reference point in its center
-\def\crosshair#1{\clap{\vrule height 0.2pt width #1}\clap{\vrule height #1 width 0.2pt}}
-
-%%% Output routine %%%
-
-\newbox\pageunderlays
-\newbox\pageoverlays
-\newbox\commonunderlays
-\newbox\commonoverlays
-
-% In addition to the normal page contents, you can define page overlays
-% and underlays, which are zero-size vboxes positioned absolutely in the
-% front / in the back of the normal material. Also, there are global
-% versions of both which are not reset after every page.
-\def\addlay#1#2{\setbox#1=\vbox{\ifvbox#1\box#1\fi\nointerlineskip\smashedvbox{#2}}}
-\def\pageunderlay{\addlay\pageunderlays}
-\def\pageoverlay{\addlay\pageoverlays}
-\def\commonunderlay{\addlay\commonoverlays}
-\def\commonoverlay{\addlay\commonoverlays}
-
-% Our variation on \plainoutput, which manages inner/outer margins and overlays
-\output{\ucwoutput}
-\newdimen\pagebodydepth
-\def\ucwoutput{\wigglepage\shipout\vbox{%
-       \makeheadline
-       \ifvbox\commonunderlays\copy\commonunderlays\nointerlineskip\fi
-       \ifvbox\pageunderlays\box\pageunderlays\nointerlineskip\fi
-       \pagebody
-       \pagebodydepth=\prevdepth
-       \nointerlineskip
-       \ifvbox\commonoverlays\vbox to 0pt{\vskip -\vsize\copy\commonoverlays\vss}\nointerlineskip\fi
-       \ifvbox\pageoverlays\vbox to 0pt{\vskip -\vsize\box\pageoverlays\vss}\nointerlineskip\fi
-       \prevdepth=\pagebodydepth
-       \makefootline
-}\advancepageno
-\ifnum\outputpenalty>-\@MM \else\dosupereject\fi}
-
-\def\wigglepage{\ifodd\pageno\else\advance\hoffset by \evenpageshift\fi}
-
-% Make it easier to redefine footline font (also, fix it so that OFS won't change it unless asked)
-\let\footfont=\tenrm
-\footline={\hss\footfont\folio\hss}
-
-%%% Itemization %%%
-
-% Usage:
-%
-% \itemize\ibull       % or other marker
-% \:first item
-% \:second item
-% \endlist
-%
-% \numlist\ndotted     % or other numbering style
-% \:first
-% \:second
-% \endlist
-
-% Default dimensions of itemized lists
-\newdimen\itemindent           \itemindent=0.5in
-\newdimen\itemnarrow           \itemnarrow=0.5in                       % make lines narrower by this amount
-\newskip\itemmarkerskip                \itemmarkerskip=0.4em                   % between marker and the item
-\newskip\preitemizeskip                \preitemizeskip=3pt plus 2pt minus 1pt  % before the list
-\newskip\postitemizeskip       \postitemizeskip=3pt plus 2pt minus 1pt % after the list
-\newskip\interitemskip         \interitemskip=2pt plus 1pt minus 0.5pt % between two items
-
-% Analogues for nested lists
-\newdimen\nesteditemindent     \nesteditemindent=0.25in
-\newdimen\nesteditemnarrow     \nesteditemnarrow=0.25in
-\newskip\prenesteditemizeskip  \prenesteditemizeskip=0pt
-\newskip\postnesteditemizeskip \postnesteditemizeskip=0pt
-
-\newif\ifitems\itemsfalse
-\newbox\itembox
-\newcount\itemcount
-
-% Penalties (changed at compatibility level 1)
-\newcount\preitemizepenalty    \preitemizepenalty=0
-\newcount\postitemizepenalty   \postitemizepenalty=0
-
-\def\preitemize{
-       \ifitems
-               \vskip\prenesteditemizeskip
-               \advance\leftskip by \nesteditemindent
-               \advance\rightskip by \nesteditemnarrow
-       \else
-               \ifnum\preitemizepenalty=0\else\penalty\preitemizepenalty\fi
-               \vskip\preitemizeskip
-               \advance\leftskip by \itemindent
-               \advance\rightskip by \itemnarrow
-       \fi
-       \parskip=\interitemskip
-}
-
-\def\postitemize{
-       \ifitems
-               \vskip\postnesteditemizeskip
-       \else
-               \ifnum\postitemizepenalty=0\else\penalty\postitemizepenalty\fi
-               \vskip\postitemizeskip
-       \fi
-}
-
-\def\inititemize{\begingroup\preitemize\itemstrue\parindent=0pt}
-
-\def\itemize#1{\inititemize\setbox\itembox\llap{#1\hskip\itemmarkerskip}%
-\let\:=\singleitem}
-
-\def\singleitem{\par\leavevmode\copy\itembox\ignorespaces}
-
-\def\endlist{\par\endgroup\postitemize}
-
-% Markers for \itemize
-\def\ibull{\raise0.2ex\hbox{$\bullet$}}
-\def\idot{\raise0.2ex\hbox{$\cdot$}}
-\def\istar{\raise0.2ex\hbox{$\ast$}}
-
-\def\numlist#1{\inititemize\itemcount=0\let\:=\numbereditem
-\let\itemnumbering=#1}
-
-\def\numbereditem{\par\leavevmode\advance\itemcount by 1
-\llap{\itemnumbering\hskip\itemmarkerskip}\ignorespaces}
-
-% Numbering styles for \numlist
-\def\nnorm{\the\itemcount}
-\def\ndotted{\nnorm.}
-\def\nparen{\nnorm)}
-\def\nparenp{(\nnorm)}
-\def\nroman{\romannumeral\itemcount}
-\def\nromanp{\nroman)}
-\def\nalpha{\count@=96\advance\count@ by\itemcount\char\count@)}
-\def\nAlpha{\count@=64\advance\count@ by\itemcount\char\count@)}
-\def\ngreek{$\ifcase\itemcount\or\alpha\or\beta\or\gamma\or\delta\or\epsilon\or
-\zeta\or\eta\or\theta\or\iota\or\kappa\or\lambda\or\mu\or\nu\or\xi\or\pi\or\rho
-\or\sigma\or\tau\or\upsilon\or\phi\or\chi\or\psi\or\omega\fi$)}
-
-%%% Miscellanea %%%
-
-% {\I italic} with automatic italic correction
-\def\I{\it\aftergroup\/}
-
-% A breakable dash, to be repeated on the next line
-\def\={\discretionary{-}{-}{-}}
-
-% Non-breakable identifiers
-\def\<#1>{\leavevmode\hbox{\I #1}}
-
-% Handy shortcuts
-\let\>=\noindent
-\def\\{\hfil\break}
-
-% Variants of \centerline, \leftline and \rightline, which are compatible with
-% verbatim environments and other catcode hacks
-\def\cline{\bgroup\def\linet@mp{\aftergroup\box\aftergroup0\aftergroup\egroup\hss\bgroup\aftergroup\hss\aftergroup\egroup}\afterassignment\linet@mp\setbox0\hbox to \hsize}
-\def\lline{\bgroup\def\linet@mp{\aftergroup\box\aftergroup0\aftergroup\egroup\bgroup\aftergroup\hss\aftergroup\egroup}\afterassignment\linet@mp\setbox0\hbox to \hsize}
-\def\rline{\bgroup\def\linet@mp{\aftergroup\box\aftergroup0\aftergroup\egroup\hss\bgroup\aftergroup\egroup}\afterassignment\linet@mp\setbox0\hbox to \hsize}
-
-% Insert a PDF picture
-% \putimage{width specification}{file}
-\def\putimage#1#2{\hbox{\pdfximage #1{#2}\pdfrefximage\pdflastximage}}
-
-%%% Colors %%%
-
-% Use of pdfTeX color stack:
-% \colorpush\rgb{1 0 0} puts a new color on the stack
-% \colorset\rgb{1 0 0} replaces the top color on the stack
-% \colorpop pops the top color
-% \colorlocal\rgb{1 0 0} set a color locally until the end of the current group
-\chardef\colorstk=\pdfcolorstackinit page direct{0 g 0 G}
-\def\colorset#1{\pdfcolorstack\colorstk set #1}
-\def\colorpush#1{\pdfcolorstack\colorstk push #1}
-\def\colorpop{\pdfcolorstack\colorstk pop}
-\def\colorlocal{\aftergroup\colorpop\colorpush}
-
-% Different ways of describing colors: \rgb{R G B}, \gray{G}, \cmyk{C M Y K}
-% (all components are real numbers between 0 and 1)
-\def\rgb#1{{#1 rg #1 RG}}
-\def\gray#1{{#1 g #1 G}}
-\def\cmyk#1{{#1 k #1 K}}
-
-%%% Localization %%%
-
-% Define a new localized string: \localedef{language}{identifier}{message}
-% (we use \language codes to identify languages)
-\def\localedef#1#2{\tmpcount=#1\expandafter\def\csname loc:\the\tmpcount:#2\endcsname}
-
-% Expand a localized string in the current language: \localemsg{identifier}
-\def\localestr#1{%
-       \ifcsname loc:\the\language:#1\endcsname
-               \csname loc:\the\language:#1\endcsname
-       \else
-               \ucwwarn{Localized string #1 not defined in language \the\language}%
-               ???%
-       \fi
-}
-
-%%% Modules %%%
-
-% Require a module: load it if it is not already loaded
-\def\ucwmodule#1{
-       \ifcsname ucwmod:#1\endcsname
-       \else
-               \input ucw-#1.tex
-       \fi
-}
-
-% Definition of a new module (to be placed at the beginning of its file)
-% (Also guards against repeated loading if somebody uses \input instead of \ucwmodule.)
-\def\ucwdefmodule#1{
-       \ifcsname ucwmod:#1\endcsname\endinput\fi
-       \expandafter\let\csname ucwmod:#1\endcsname=\relax
-}
-
-% Compatibility levels
-% We try to be backwards compatible as much as we can, so all changes in behavior
-% (except for addition of new control sequences) are versioned. By default, ucwmac
-% starts in compatibility level 0, which should produce the same results as historic
-% versions of ucwmac. Use \ucwcompat{level} to upgrade to a given level, or if you
-% do not care about compatibility, \ucwcompat\ucwmaxcompat.
-
-\chardef\ucwcurrentcompat=0    % Currently active compatibility level
-\chardef\ucwmaxcompat=1                % Maximum supported compatibility level
-
-\def\ucwcompat#1{
-       \ucwcurrentcompat=#1
-       \ifcase #1
-               % Level 0 (default): old ucwmac
-       \or     % Level 1
-               \preitemizepenalty=-500
-               \postitemizepenalty=-500
-       \else\errmessage{Unsupported compatibility level #1 requested.}
-       \fi
-}
-
-%%% Epilog %%%
-
-% Let's hide all internal macros
-\catcode`@=12
+\preitemizepenalty=0
+\postitemizepenalty=0
diff --git a/ucwmac2.tex b/ucwmac2.tex
new file mode 100644 (file)
index 0000000..90dd753
--- /dev/null
@@ -0,0 +1,389 @@
+% The UCW Macro Collection (a successor of mjmac.tex)
+% Written by Martin Mares <mj@ucw.cz> in 2010--2018 and placed into public domain
+% -------------------------------------------------------------------------------
+
+\ifx\ucwmodule\undefined\else\endinput\fi
+
+%%% Prolog %%%
+
+% We'll use internal macros of plain TeX
+\catcode`@=11
+
+\ifx\eTeXversion\undefined
+\errmessage{ucwmac requires the e-TeX engine or its successor}
+\fi
+
+%%% PDF output detection %%%
+
+\newif\ifpdf
+\pdffalse
+
+\ifx\pdfoutput\undefined
+\else\ifnum\pdfoutput>0
+       \pdftrue
+       \pdfpkresolution=600    % Provide a reasonable default
+\fi\fi
+
+\ifx\directlua\undefined\else
+       % In LuaTeX \pdfpkresolution is not enough
+       \directlua{kpse.init_prog("luatex", 600, "ljfour")}
+\fi
+
+%%% Temporary registers %%%
+
+\newcount\tmpcount
+\newdimen\tmpdimen
+
+%%% Auxiliary macros %%%
+
+% Prepend/append #2 to the definition of #1
+\long\def\prependef#1#2{\expandafter\def\expandafter#1\expandafter{#2#1}}
+\long\def\appendef#1#2{\expandafter\def\expandafter#1\expandafter{#1#2}}
+
+% Variants of \def and \let, where the control sequence name is given as a string
+\def\sdef#1{\expandafter\def\csname#1\endcsname}
+\def\slet#1#2{\expandafter\let\csname#1\expandafter\endcsname\csname#2\endcsname}
+
+% Add \protected to an existing macro
+\def\addprotected#1{\protected\edef#1{\expandafter\unexpanded\expandafter{#1}}}
+
+% Protect ~
+\addprotected~
+
+\def\ucwwarn#1{\immediate\write16{*** UCWmac warning: #1 ***}}
+
+%%% Page size and margins %%%
+
+% If you modify these registers, call \setuppage afterwards
+\ifx\luatexversion\undefined
+       % In LuaTeX, \pagewidth and \pageheight are primitive
+       \newdimen\pagewidth
+       \newdimen\pageheight
+\fi
+\newdimen\leftmargin
+\newdimen\rightmargin
+\newdimen\topmargin
+\newdimen\bottommargin
+\newdimen\evenpageshift
+
+\def\setuppage{%
+       \hsize=\pagewidth
+       \advance\hsize by -\leftmargin
+       \advance\hsize by -\rightmargin
+       \vsize=\pageheight
+       \advance\vsize by -\topmargin
+       \advance\vsize by -\bottommargin
+       \hoffset=\leftmargin
+       \advance\hoffset by -1truein
+       \voffset=\topmargin
+       \advance\voffset by -1truein
+       \ifpdf
+               \pdfhorigin=1truein
+               \pdfvorigin=1truein
+               \ifx\luatexversion\undefined
+                       \pdfpagewidth=\pagewidth
+                       \pdfpageheight=\pageheight
+               \fi
+       \fi
+}
+
+% Set multiple margins to the same value
+\def\sethmargins#1{\leftmargin=#1\relax\rightmargin=#1\relax\evenpageshift=0pt\relax}
+\def\setvmargins#1{\topmargin=#1\relax\bottommargin=#1\relax}
+\def\setmargins#1{\sethmargins{#1}\setvmargins{#1}}
+
+% Define inner/outer margin instead of left/right
+\def\setinneroutermargin#1#2{\leftmargin#1\relax\rightmargin#2\relax\evenpageshift=\rightmargin\advance\evenpageshift by -\leftmargin}
+
+% Use a predefined paper format, calls \setuppage automagically
+\def\setpaper#1{%
+       \expandafter\let\expandafter\currentpaper\csname paper-#1\endcsname
+       \ifx\currentpaper\relax
+               \errmessage{Undefined paper format #1}
+       \fi
+       \currentpaper
+}
+
+% Switch to landscape orientation, calls \setuppage automagically
+\def\landscape{%
+       \dimen0=\pageheight
+       \pageheight=\pagewidth
+       \pagewidth=\dimen0
+       \setuppage
+}
+
+% Common paper sizes
+\def\defpaper#1#2#3{\expandafter\def\csname paper-#1\endcsname{\pagewidth=#2\pageheight=#3\setuppage}}
+\defpaper{a3}{297truemm}{420truemm}
+\defpaper{a4}{210truemm}{297truemm}
+\defpaper{a5}{148truemm}{210truemm}
+\defpaper{letter}{8.5truein}{11truein}
+\defpaper{legal}{8.5truein}{14truein}
+
+% Default page parameters
+\setmargins{1truein}
+\setpaper{a4}
+
+%%% Macros with optional arguments %%%
+
+% After \def\a{\withoptarg\b}, the macro \a behaves in this way:
+%      \a[arg]         does \def\optarg{arg} and then it expands \b
+%      \a              does \let\optarg=\relax and then it expands \b
+\def\withoptarg#1{\let\xoptcall=#1\futurelet\next\xopt}
+\def\xopt{\ifx\next[\expandafter\xoptwith\else\let\optarg=\relax\expandafter\xoptcall\fi}
+\def\xoptwith[#1]{\def\optarg{#1}\xoptcall}
+
+% A shortcut for defining macros with optional arguments:
+% \optdef\macro behaves as \def\domacro, while \macro itself is defined
+% as a wrapper calling \domacro using \withoptarg.
+\def\optdef#1{%
+       \edef\xoptname{\expandafter\eatbackslash\string#1}%
+       \edef#1{\noexpand\withoptarg\csname do\xoptname\endcsname}%
+       \expandafter\def\csname do\xoptname\endcsname
+}
+
+% Trick: \eatbackslash eats the next backslash of category 12
+\begingroup\lccode`\+=`\\
+\lowercase{\endgroup\def\eatbackslash+{}}
+
+% Expand to the optional argument if it exists
+\def\optargorempty{\ifx\optarg\relax\else\optarg\fi}
+
+%%% Placing material at specified coordinates %%%
+
+% Set all dimensions of a given box register to zero
+\def\smashbox#1{\ht#1=0pt \dp#1=0pt \wd#1=0pt}
+\long\def\smashedhbox#1{{\setbox0=\hbox{#1}\smashbox0\box0}}
+\long\def\smashedvbox#1{{\setbox0=\vbox{#1}\smashbox0\box0}}
+
+% Variants of \llap and \rlap working equally on both sides and/or vertically
+\def\hlap#1{\hbox to 0pt{\hss #1\hss}}
+\def\vlap#1{\vbox to 0pt{\vss #1\vss}}
+\def\clap#1{\vlap{\hlap{#1}}}
+
+% \placeat{right}{down}{hmaterial} places <hmaterial>, so that its
+% reference point lies at the given position wrt. the current ref point
+\long\def\placeat#1#2#3{\smashedhbox{\hskip #1\lower #2\hbox{#3}}}
+
+% Like \vbox, but with reference point in the upper left corner
+\long\def\vhang#1{\vtop{\hrule height 0pt\relax #1}}
+
+% Like \vhang, but respecting interline skips
+\long\def\vhanglines#1{\vtop{\hbox to 0pt{}#1}}
+
+% Crosshair with reference point in its center
+\def\crosshair#1{\clap{\vrule height 0.2pt width #1}\clap{\vrule height #1 width 0.2pt}}
+
+%%% Output routine %%%
+
+\newbox\pageunderlays
+\newbox\pageoverlays
+\newbox\commonunderlays
+\newbox\commonoverlays
+
+% In addition to the normal page contents, you can define page overlays
+% and underlays, which are zero-size vboxes positioned absolutely in the
+% front / in the back of the normal material. Also, there are global
+% versions of both which are not reset after every page.
+\def\addlay#1#2{\setbox#1=\vbox{\ifvbox#1\box#1\fi\nointerlineskip\smashedvbox{#2}}}
+\def\pageunderlay{\addlay\pageunderlays}
+\def\pageoverlay{\addlay\pageoverlays}
+\def\commonunderlay{\addlay\commonoverlays}
+\def\commonoverlay{\addlay\commonoverlays}
+
+% Our variation on \plainoutput, which manages inner/outer margins and overlays
+\output{\ucwoutput}
+\newdimen\pagebodydepth
+\def\ucwoutput{\wigglepage\shipout\vbox{%
+       \makeheadline
+       \ifvbox\commonunderlays\copy\commonunderlays\nointerlineskip\fi
+       \ifvbox\pageunderlays\box\pageunderlays\nointerlineskip\fi
+       \pagebody
+       \pagebodydepth=\prevdepth
+       \nointerlineskip
+       \ifvbox\commonoverlays\vbox to 0pt{\vskip -\vsize\copy\commonoverlays\vss}\nointerlineskip\fi
+       \ifvbox\pageoverlays\vbox to 0pt{\vskip -\vsize\box\pageoverlays\vss}\nointerlineskip\fi
+       \prevdepth=\pagebodydepth
+       \makefootline
+}\advancepageno
+\ifnum\outputpenalty>-\@MM \else\dosupereject\fi}
+
+\def\wigglepage{\ifodd\pageno\else\advance\hoffset by \evenpageshift\fi}
+
+% Make it easier to redefine footline font (also, fix it so that OFS won't change it unless asked)
+\let\footfont=\tenrm
+\footline={\hss\footfont\folio\hss}
+
+%%% Itemization %%%
+
+% Usage:
+%
+% \itemize\ibull       % or other marker
+% \:first item
+% \:second item
+% \endlist
+%
+% \numlist\ndotted     % or other numbering style
+% \:first
+% \:second
+% \endlist
+
+% Default dimensions of itemized lists
+\newdimen\itemindent           \itemindent=0.5in
+\newdimen\itemnarrow           \itemnarrow=0.5in                       % make lines narrower by this amount
+\newskip\itemmarkerskip                \itemmarkerskip=0.4em                   % between marker and the item
+\newskip\preitemizeskip                \preitemizeskip=3pt plus 2pt minus 1pt  % before the list
+\newskip\postitemizeskip       \postitemizeskip=3pt plus 2pt minus 1pt % after the list
+\newskip\interitemskip         \interitemskip=2pt plus 1pt minus 0.5pt % between two items
+
+% Analogues for nested lists
+\newdimen\nesteditemindent     \nesteditemindent=0.25in
+\newdimen\nesteditemnarrow     \nesteditemnarrow=0.25in
+\newskip\prenesteditemizeskip  \prenesteditemizeskip=0pt
+\newskip\postnesteditemizeskip \postnesteditemizeskip=0pt
+
+\newif\ifitems\itemsfalse
+\newbox\itembox
+\newcount\itemcount
+
+% Penalties
+\newcount\preitemizepenalty    \preitemizepenalty=-500
+\newcount\postitemizepenalty   \postitemizepenalty=-500
+
+\def\preitemize{
+       \ifitems
+               \vskip\prenesteditemizeskip
+               \advance\leftskip by \nesteditemindent
+               \advance\rightskip by \nesteditemnarrow
+       \else
+               \ifnum\preitemizepenalty=0\else\penalty\preitemizepenalty\fi
+               \vskip\preitemizeskip
+               \advance\leftskip by \itemindent
+               \advance\rightskip by \itemnarrow
+       \fi
+       \parskip=\interitemskip
+}
+
+\def\postitemize{
+       \ifitems
+               \vskip\postnesteditemizeskip
+       \else
+               \ifnum\postitemizepenalty=0\else\penalty\postitemizepenalty\fi
+               \vskip\postitemizeskip
+       \fi
+}
+
+\def\inititemize{\begingroup\preitemize\itemstrue\parindent=0pt}
+
+\def\itemize#1{\inititemize\setbox\itembox\llap{#1\hskip\itemmarkerskip}%
+\let\:=\singleitem}
+
+\def\singleitem{\par\leavevmode\copy\itembox\ignorespaces}
+
+\def\endlist{\par\endgroup\postitemize}
+
+% Markers for \itemize
+\def\ibull{\raise0.2ex\hbox{$\bullet$}}
+\def\idot{\raise0.2ex\hbox{$\cdot$}}
+\def\istar{\raise0.2ex\hbox{$\ast$}}
+
+\def\numlist#1{\inititemize\itemcount=0\let\:=\numbereditem
+\let\itemnumbering=#1}
+
+\def\numbereditem{\par\leavevmode\advance\itemcount by 1
+\llap{\itemnumbering\hskip\itemmarkerskip}\ignorespaces}
+
+% Numbering styles for \numlist
+\def\nnorm{\the\itemcount}
+\def\ndotted{\nnorm.}
+\def\nparen{\nnorm)}
+\def\nparenp{(\nnorm)}
+\def\nroman{\romannumeral\itemcount}
+\def\nromanp{\nroman)}
+\def\nalpha{\count@=96\advance\count@ by\itemcount\char\count@)}
+\def\nAlpha{\count@=64\advance\count@ by\itemcount\char\count@)}
+\def\ngreek{$\ifcase\itemcount\or\alpha\or\beta\or\gamma\or\delta\or\epsilon\or
+\zeta\or\eta\or\theta\or\iota\or\kappa\or\lambda\or\mu\or\nu\or\xi\or\pi\or\rho
+\or\sigma\or\tau\or\upsilon\or\phi\or\chi\or\psi\or\omega\fi$)}
+
+%%% Miscellanea %%%
+
+% {\I italic} with automatic italic correction
+\def\I{\it\aftergroup\/}
+
+% A breakable dash, to be repeated on the next line
+\def\={\discretionary{-}{-}{-}}
+
+% Non-breakable identifiers
+\def\<#1>{\leavevmode\hbox{\I #1}}
+
+% Handy shortcuts
+\let\>=\noindent
+\def\\{\hfil\break}
+
+% Variants of \centerline, \leftline and \rightline, which are compatible with
+% verbatim environments and other catcode hacks
+\def\cline{\bgroup\def\linet@mp{\aftergroup\box\aftergroup0\aftergroup\egroup\hss\bgroup\aftergroup\hss\aftergroup\egroup}\afterassignment\linet@mp\setbox0\hbox to \hsize}
+\def\lline{\bgroup\def\linet@mp{\aftergroup\box\aftergroup0\aftergroup\egroup\bgroup\aftergroup\hss\aftergroup\egroup}\afterassignment\linet@mp\setbox0\hbox to \hsize}
+\def\rline{\bgroup\def\linet@mp{\aftergroup\box\aftergroup0\aftergroup\egroup\hss\bgroup\aftergroup\egroup}\afterassignment\linet@mp\setbox0\hbox to \hsize}
+
+% Insert a PDF picture
+% \putimage{width specification}{file}
+\def\putimage#1#2{\hbox{\pdfximage #1{#2}\pdfrefximage\pdflastximage}}
+
+%%% Colors %%%
+
+% Use of pdfTeX color stack:
+% \colorpush\rgb{1 0 0} puts a new color on the stack
+% \colorset\rgb{1 0 0} replaces the top color on the stack
+% \colorpop pops the top color
+% \colorlocal\rgb{1 0 0} set a color locally until the end of the current group
+\chardef\colorstk=\pdfcolorstackinit page direct{0 g 0 G}
+\def\colorset#1{\pdfcolorstack\colorstk set #1}
+\def\colorpush#1{\pdfcolorstack\colorstk push #1}
+\def\colorpop{\pdfcolorstack\colorstk pop}
+\def\colorlocal{\aftergroup\colorpop\colorpush}
+
+% Different ways of describing colors: \rgb{R G B}, \gray{G}, \cmyk{C M Y K}
+% (all components are real numbers between 0 and 1)
+\def\rgb#1{{#1 rg #1 RG}}
+\def\gray#1{{#1 g #1 G}}
+\def\cmyk#1{{#1 k #1 K}}
+
+%%% Localization %%%
+
+% Define a new localized string: \localedef{language}{identifier}{message}
+% (we use \language codes to identify languages)
+\def\localedef#1#2{\tmpcount=#1\expandafter\def\csname loc:\the\tmpcount:#2\endcsname}
+
+% Expand a localized string in the current language: \localemsg{identifier}
+\def\localestr#1{%
+       \ifcsname loc:\the\language:#1\endcsname
+               \csname loc:\the\language:#1\endcsname
+       \else
+               \ucwwarn{Localized string #1 not defined in language \the\language}%
+               ???%
+       \fi
+}
+
+%%% Modules %%%
+
+% Require a module: load it if it is not already loaded
+\def\ucwmodule#1{
+       \ifcsname ucwmod:#1\endcsname
+       \else
+               \input ucw-#1.tex
+       \fi
+}
+
+% Definition of a new module (to be placed at the beginning of its file)
+% (Also guards against repeated loading if somebody uses \input instead of \ucwmodule.)
+\def\ucwdefmodule#1{
+       \ifcsname ucwmod:#1\endcsname\endinput\fi
+       \expandafter\let\csname ucwmod:#1\endcsname=\relax
+}
+
+%%% Epilog %%%
+
+% Let's hide all internal macros
+\catcode`@=12