From 27401cc1f932adc852b736e46e85d9c0d8a9cb50 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Fri, 24 Sep 2010 22:55:20 +0200 Subject: [PATCH] The first bits --- ucwmac.tex | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 ucwmac.tex diff --git a/ucwmac.tex b/ucwmac.tex new file mode 100644 index 0000000..4943c80 --- /dev/null +++ b/ucwmac.tex @@ -0,0 +1,57 @@ +%%% Page size and margins %%% + +\newdimen\pagewidth +\newdimen\pageheight +\newdimen\leftmargin +\newdimen\rightmargin +\newdimen\topmargin +\newdimen\bottommargin + +\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 + \ifx\pdfpagewidth\undefined\else + \pdfpagewidth=\pagewidth + \pdfpageheight=\pageheight + \fi +} + +\def\sethmargins#1{\leftmargin=#1\relax\rightmargin=#1\relax} +\def\setvmargins#1{\topmargin=#1\relax\bottommargin=#1\relax} +\def\setmargins#1{\sethmargins{#1}\setvmargins{#1}} + +\def\defpaper#1#2#3{\expandafter\def\csname paper-#1\endcsname{\pagewidth=#2\pageheight=#3\setuppage}} +\def\setpaper#1{% + \expandafter\let\expandafter\currentpaper\csname paper-#1\endcsname + \ifx\currentpaper\relax + \errmessage{Undefined paper format #1} + \fi + \currentpaper +} + +\def\landscape{% + \dimen0=\pageheight + \pageheight=\pagewidth + \pagewidth=\dimen0 + \setuppage +} + +\defpaper{a3}{297truemm}{420truemm} +\defpaper{a4}{210truemm}{297truemm} +\defpaper{a5}{148truemm}{210truemm} +\defpaper{a6}{105truemm}{148truemm} +\defpaper{letter}{8.5truein}{11truein} +\defpaper{legal}{8.5truein}{14truein} + +\setmargins{1truein} +\setpaper{a4} + +\bye -- 2.39.5