Plain-TeX – How to Get Started with Plain TeX

plain-texpstricks

I am using TeX Live 2010 on Windows 7. I have no experience to compile a plain TeX input file.

  1. Is my input file below correct?

    % gettingstarted.tex
    \input pstricks
    \topmargin=-72.27pt
    \oddsidemargin=-72.27pt
    \paperwidth=72.27pt
    \paperheight=72.27pt
    \parindent=0pt
    \special{papersize=\the\paperwidth,\the\paperheight}
    
    \pspicture(\paperwidth,\paperheight)
    \psframe(\paperwidth,\paperheight)
    \endpspicture
    
    \bye
    
  2. What is the plain TeX compiler I must execute to get DVI output? And what is the syntax?


I have tried using tex gettingstarted.tex and I got the following errors:

enter image description here

Best Answer

You can use pdftex, if you want to profit from e-TeX extensions; on TeX Live it's available for DVI output as etex or, from the command line,

pdftex --output-format=dvi

Plain TeX has not many page format parameters: the upper left corner of the type block is 1in from the left edge and 1in from the upper edge of the paper.

In order to shift the text block it's necessary to either modify the output routine or to set \hoffset and \voffset. So

\hoffset=-72.27truept
\voffset=-72.27truept
\special{papersize=72.27pt,72.27pt}
\hsize=72.27truept
\vsize=72.27truept

\parindent=0pt
\nopagenumbers

\input pstricks

\pspicture(72.27pt,72.27pt)
\psframe(72.27pt,72.27pt)
\endpspicture

\bye

Without \nopagenumbers you'd have the number "printed" outside the page area.

A modified output routine that makes unnecessary to act on \hoffset and \voffset is

\catcode`@=11
\def\xportoutput#1#2{%
  \shipout\vbox{\vglue#1\relax
    \moveright#2\vbox{\makeheadline\pagebody\makefootline}}%
  \advancepageno
  \ifnum\outputpenalty>-\@MM \else\dosupereject\fi}
\catcode`@=12
\output{\xportoutput{-72.27truept}{-72.27truept}}

One can change the two parameters to \xportoutput, for example to adapt the position of the text block to A4 paper. The arguments are respectively the horizontal and the vertical displacements with respect to the default reference point. It's better to use truept in order not to apply the \mag factor.

Related Question