[Tex/LaTex] different type areas on even/odd pages

double-sidedmarginstypearea

in some (very rare) cases, it might be desirable to have the type area, particularly the text width, be different on even and odd pages. Let's say we're typesetting a textbook that's supposed to have small illustrations or annotations in the margin of the odd pages — so we'd need a narrower type area on these. Like this:

different type areas even/odd
Here's an attempt at a solution I came up with. It isn't as smart as I thought it was. I thought we might just combine everyshi and an \ifthispageodd test to change the typearea at every shipout. Obviously, that's not how it works:

\documentclass[paper=a5,pagesize,10pt,DIV=12,twoside=true]{scrreprt}
\usepackage{everyshi,blindtext}
\EveryShipout{%
\ifthispageodd{\areaset{6cm}{12cm}}{\areaset{9cm}{12cm}}}

\begin{document}
\Blinddocument
\end{document}

this results in:

! Bad space factor (0).
<recently read> \@savsf 

l.7 \Blinddocument

Is there a way to improve this? Or something entirely different?

Best Answer

This only works for simple cases, but could be extended and generalised a bit.

enter image description here

\documentclass{article}
\makeatletter

\def\a{Cat dog goat sheep pig rabbit cow kangeroo. }
\def\b{One two three four five six. }
\def\c{\a\a\b\a\b\b\a\a\a\a\b\b\a\b}
\def\d{\c\par\a\b\c\par\b\b\b\b\b\b\par}
\def\e{\par\d\d\b\b\b\b\b\d\a\a\a\a\a\a\a\d}


\def\shp#1{%
\@tempcnta\z@
\loop
\advance\@tempcnta\@ne
\edef\pshape{\pshape 0pt #1 }
\ifnum\@tempcnta<46
\repeat
\advance\@tempcntb46
}
\begin{document}

{
\@tempcntb\z@
\def\pshape{}
\shp{5in}\shp{3in}
\shp{5in}\shp{3in}
\shp{5in}\shp{3in}
\def\par{\ifhmode\\\fi\hspace*{\parindent}\ignorespaces}
\show\pshape
\parshape\@tempcntb\pshape
\e\e
\endgraf
}

\end{document}