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:



this results in:

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

l.7 \Blinddocument

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

  • 6
    At the very least, this is highly non-trivial because of the asynchronous manner in which TeX works. Page breaking happens separately from paragraph building, and feeding information from the latter into the former will require some very advanced TeX hackery indeed. I am not saying it can't be done, however … Maybe I should say so, to provoke someone into proving me wrong. Feb 20 '13 at 15:32
  • 12
    It is massively complicated to do this in TeX, you need to save the entire paragraph (for each paragraph) then you need to detect how far into the paragraph the page break happens and then re-set the paragraph with a parshape that uses wide lines for n-lines and short lines for the rest. It gets more complicated still if you allow paragraphs longer than a page as then you need a \parshape that chages the length at each break. Feb 20 '13 at 15:40
  • 2
    I've asked that kind of question many times myself, in reply to people asking if x is possible in *TeX: »why do you want that in the first place? You might as well stop wanting it and be a happier wo/man«. But then again, if DE Knuth had been given that answer in the 70s when he asked if x is possible in phototypesetting, and if he had followed that advice and kept the things he wanted within the constraints of what's possible, we'd probably still be using Linotrons. As for my angst: it isn't that bad. It's a fictitious scenario, fortunately. I'd like know if it were possible and at what cost.
    – Nils L
    Feb 20 '13 at 16:35
  • 1
    That's so true... Feb 20 '13 at 20:11
  • 10

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

enter image description here


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

\edef\pshape{\pshape 0pt #1 }


  • It seems like the number of pages and lines per page are hardwired. Is this correct? Could you use something like the lastpage package to automate the number of pages and the lineno package to get the lines per page?
    – StrongBad
    May 24 '13 at 8:07
  • @DanielE.Shub lines per page is hardwired to 46 that could be set in the preamble by dividing \textheight by \baselineskip as written it only allows 6 pages before you have to have a real paragraph break and new page then start again. You could add as many \shp commands as you need but depending on the page size you can not have more than 20 or so as otherwise you will exceed the capacity of TeX's paragraph builder. Really each paragraph should be set as a new TeX primitive paragraph with a parshape depending on the position on the current page, but that can be hard to do May 24 '13 at 8:13
  • Small suggestion: If you load the lipsum package, you could change your \e\e to \lipsum[1-26]. May 24 '13 at 8:43
  • @JohnWickerson I'm having a one man crusade against the lipsum package:-) May 24 '13 at 8:44
  • Lorem ipsum.... May 27 '13 at 6:47

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.