% 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
\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
+
+%%% 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
%%% 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
\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
\ifitems
\vskip\postnesteditemizeskip
\else
+ \ifnum\postitemizepenalty=0\else\penalty\postitemizepenalty\fi
\vskip\postitemizeskip
\fi
}
\def\endlist{\par\endgroup\postitemize}
-\def\ibull{\raise0.2ex\hbox{$\bullet$}} % Signs frequently used for \itemize
+% Markers for \itemize
+\def\ibull{\raise0.2ex\hbox{$\bullet$}}
\def\idot{\raise0.2ex\hbox{$\cdot$}}
\def\istar{\raise0.2ex\hbox{$\ast$}}
\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)}
% \putimage{width specification}{file}
\def\putimage#1#2{\hbox{\pdfximage #1{#2}\pdfrefximage\pdflastximage}}
-% Let ~ be protected
-\let\plaintilde=~
-\protected\def~{\plaintilde}
+%%% 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 %%%
+
+% Current language
+\def\localelang{en}
+
+% Define a new localized string: \localedef{language}{identifier}{message}
+\def\localedef#1#2{\expandafter\def\csname loc:#1:#2\endcsname}
+
+% Expand a localized string in the current language: \localemsg{identifier}
+\def\localestr#1{%
+ \ifcsname loc:\localelang:#1\endcsname
+ \csname loc:\localelang:#1\endcsname
+ \else
+ \ucwwarn{Localized string #1 not defined in language \localelang}%
+ ???%
+ \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 %%%