4

I am looking into plain luatex (no latex). The following definitions change the size of the paper, but don't change the physical paper size. What am I missing

\newdimen\pagewidth
\newdimen\pageheight
\pagewidth=3.5in % the width of each page
\pageheight=3.7in % the height of each page
\def\setpage{\hsize\pagewidth\vsize\pageheight}
\setpage

Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.


Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    \eject




Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
\eject
\end
  • 1
    You want to reduce the \vsize by \maxdepth, so descenders in the last line will appear. Also the \baselineskip should be adjusted in order to fit an exact number of lines: \vsize=\dimexpr\pageheight-\maxdepth\relax and \baselineskip=\dimexpr(\vsize-\topskip)/21\relax will fit 22 lines on a baselineskip of 12.06661pt. – egreg Oct 22 '18 at 22:05
  • @egreg yes setting sensible margins was second level comment, but I decided to just stick to page size.. – David Carlisle Oct 22 '18 at 22:08
5

Short answer: remove your top two lines that declare \pagewidth and \pageheight, because those are actually the LuaTeX dimensions that you want to control.


In more detail:

  • \hsize and \vsize are (roughly speaking) the dimensions within which TeX tries to typeset the content. In plain (Knuth) TeX, which produces only DVI, there is no further notion of physical paper size. But by default when printed the contents will appear at an offset of (1 inch + \hoffset) from the left edge of the paper, and (1 inch + \voffset) from the top edge.

  • In pdfTeX (and XeTeX), \pdfpagewidth and \pdfpageheight are the primitives that control the dimensions of the actual page in PDF. In LuaTeX, they are called simply \pagewidth and \pageheight.

When you use \newdimen\pagewidth you're clobbering the primitive so that it's no longer usable. So simply remove the top two lines in your question. Also, to account for the 1-inch margins, you should either make \hoffset and \voffset negative, or make the paper size bigger.

output

\pagewidth=5.5in % the width of each page
\pageheight=5.7in % the height of each page
\hsize=\dimexpr (\pagewidth - 2in) \relax
\vsize=\dimexpr (\pageheight - 2in) \relax

Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.


Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    \eject




Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
\eject
\end

(Also: using \eject without \vfill causes underfull vbox warnings.)

  • Oops, didn't notice answer was already posted while I was typing this. – ShreevatsaR Oct 22 '18 at 21:43
5

you need to remove

\newdimen\pagewidth
\newdimen\pageheight

as they mask the primitives which if set will affect the size of the media box in the pdf. Also take account of the default 1in origin (currently you have \hsize equal to \pagewidth but offset by 1in.)

\pagewidth=3.5in % the width of each page
\pageheight=3.7in % the height of each page
\hoffset=-1in
\voffset=-1in
\def\setpage{\hsize\pagewidth\vsize\pageheight}
\setpage


Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.


Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    \eject

enter image description here

  • Or \pdfvariable horigin=0pt and \pdfvariable vorigin=0pt – egreg Oct 22 '18 at 21:55
  • @egreg yes but unless you have existing page layout macros using \hoffset setting \hoffset=-10in or horigin=0pt comes to the same thing, I think. – David Carlisle Oct 22 '18 at 22:00
  • No. One can then use \hoffset and \voffset for independent corrections if the printer driver has personal ideas. – egreg Oct 22 '18 at 22:03
  • @egreg shrug, if you are using plain and no other macros are in use, you could use horigin for independent corrections if your main code is using \hoffset or vice versa, the resulting pdf is the same whichever you set isn't it? – David Carlisle Oct 22 '18 at 22:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.