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
5
  • 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: tex.stackexchange.com/questions/19497/…
    – WillAdams
    Dec 30, 2013 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. Dec 30, 2013 at 18:33
  • 2
    @WillAdams that's not tex primitives, it's plain TeX, so a latex/memoir solution isn't applicable Dec 30, 2013 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? Dec 30, 2013 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. Dec 30, 2013 at 21:51

1 Answer 1

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
1
  • 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, 2013 at 21:26

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.