]> mj.ucw.cz Git - ucwmac.git/commitdiff
The first bits
authorMartin Mares <mj@ucw.cz>
Fri, 24 Sep 2010 20:55:20 +0000 (22:55 +0200)
committerMartin Mares <mj@ucw.cz>
Sat, 9 Oct 2010 11:05:45 +0000 (13:05 +0200)
ucwmac.tex [new file with mode: 0644]

diff --git a/ucwmac.tex b/ucwmac.tex
new file mode 100644 (file)
index 0000000..4943c80
--- /dev/null
@@ -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