4
Two-sided documents (self.tex_typesetting)
submitted 1 year ago by estee to c/tex_typesetting

In a two-sided document, the margins are mirrored. This is good if the document is intended to be read as a book, where the combination of a verso and recto page is seen as a whole. Traditionally the inner margin is smaller, so that the white space in the middle (the combined inner margins) is in harmony with the outer margins.

If we first set the recto (odd) page with some margins, then we can figure out how much the type area on a verso (even) page needs to move.

Then, the idea is to insert an \hoffset-adjusting macro in the output routine before it does anything else.

In plain LuaTeX we could have this document:

% Undo 1 inch origin (personal preference)
\pdfvariable horigin 0pt
\pdfvariable vorigin 0pt

% A5 paper
\pagewidth=148.5mm
\pageheight=210mm

% Inner margin
\hoffset=0.111\pagewidth

% Top margin
\voffset=0.111\pageheight

% Type area width
\hsize=0.666\pagewidth

%Type area height
\vsize=\topskip
\advance\vsize by 32\baselineskip

\tolerance=9999 % Not important for testing

Then a spread would look like this:

Ok, so then we figure out how much a verso should move and insert that into the output routine:

% How much verso pages should move
\newdimen\shiftoffset
\shiftoffset = \pagewidth
\advance \shiftoffset by -\hsize
\advance \shiftoffset by -2\hoffset

% \hoffset-adjusting macro...
\def\beforeoutput{%
	\ifodd\pageno
	\else
		\advance \hoffset by \shiftoffset
	\fi
}

% ...inserted before the regular output routine
\output{\beforeoutput \plainoutput}

And then we get:

Caveat: if you have your coordinate origin somewhere else, like 1 inch in from the left and top, or some other setup, you may have to account for that in the macros.

all 2 comments
sorted by: hot top controversial new old
this post was submitted on 21 Jun 2023
4 points (100.0% liked)

TeX typesetting

150 readers
1 users here now

A place to share ideas, resources, tips, and hacks for Donald Knuths typesetting software TeX. All variants and formats like OpTeX, LaTeX and ConTeXt are welcome.

founded 1 year ago
MODERATORS