Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
5  
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. –  Harald Hanche-Olsen Feb 20 '13 at 15:32
11  
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. –  David Carlisle 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... –  Brent.Longborough Feb 20 '13 at 20:11
10  
show 9 more comments

1 Answer 1

up vote 11 down vote accepted
+500

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}
share|improve this answer
    
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 –  David Carlisle May 24 '13 at 8:13
    
Small suggestion: If you load the lipsum package, you could change your \e\e to \lipsum[1-26]. –  John Wickerson May 24 '13 at 8:43
    
@JohnWickerson I'm having a one man crusade against the lipsum package:-) –  David Carlisle May 24 '13 at 8:44
    
Lorem ipsum.... –  Nicholas Hamilton May 27 '13 at 6:47
show 5 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.