6

In TeX, changing the \hsize and the \vsize changes the main text size and the page size of the dvi output. When I compile a document with pdftex or xetex, the page size remains at A4. How can I change the page margins?

Minimal example:

\hsize=5cm \vsize=4cm
\footline{\hfil The page ends here!\hfil\the\pageno}
This document leaves much white space when {\tt pdftex\/}ed or {\tt xetex\/}ed.

\bye
lvaneesbeeck
  • 3,095
  • 1
    Don't use TeX primitives --- you have to access the pdf-specific information/options (see the manuals for pdftex and xetex). I provide an example of how to do this using XeLaTeX in this answer: http://tex.stackexchange.com/questions/19497/how-do-you-setup-a-tex-document-to-self-publish-a-book-online/130843#130843 – WillAdams Dec 30 '13 at 15:41
  • 2
    Actually changing hsize/vsize does not change the page size in dvi either, unlike pdf, dvi has no concept of the page size. \hsize \vsize just affects the size of the text block in tex and pdftex. pdftex has a \pdfpagewidth primitive that has no analogue in classic tex. – David Carlisle Dec 30 '13 at 18:33
  • 2
    @WillAdams that's not tex primitives, it's plain TeX, so a latex/memoir solution isn't applicable – David Carlisle Dec 30 '13 at 18:35
  • @DavidCarlisle that means that TeX can't, e.g., center the text on the true page margins? If I want, say, 2 times more space on the left margin than on the right one, I have to compute manually the \hoffset and \voffset needed? – lvaneesbeeck Dec 30 '13 at 20:55
  • 1
    classic TeX has no idea of the page, it just sets the text block at a position offset from the top left corner. Classically the dvi driver needed to be told the paper size. essentially pdftex is its own driver so needs the page size. – David Carlisle Dec 30 '13 at 21:51

1 Answers1

3

Solution for {Lua-,pdf-,Xe-}TeX

\hsize=2in \vsize=3in
\pdfpagewidth=4in
\pdfpageheight=5in
\footline{\hfil The page ends here!\hfil\the\pageno}
This document is by far better! Notice that \TeX{} starts every page
one inch away from the upper and left margin.
This example doesn't compile with {\tt tex} anymore.

\bye
lvaneesbeeck
  • 3,095
  • 1
    There are still \voffset and \hoffset to keep into account, because the origin is always at 1in from the top and left page margins; pdftex and LuaTeX have \pdfhorigin and \pdfvorigin, but XeTeX doesn't know them (while it has \pdfpagewidth and \pdfpageheight). – egreg Dec 30 '13 at 21:26