# Odd, even , first page not working

One is able to use different page layouts for the first, even and odd pages, but when it comes to varying text widths, ConTeXt doesn't adapt the paragraph width at a page boundary:

 % setup layout for first page
\definelayout[1][
leftmargin=25mm,
rightmargin=30mm,
cutspace=50mm,
backspace=40mm,
height=fit,
width=fit,
]

\definelayout[even][
leftmargin=30mm,
rightmargin=25mm,
cutspace=50mm,
backspace=40mm,
height=fit,
width=fit,
]

\definelayout[odd][
leftmargin=25mm,
rightmargin=30mm,
cutspace=50mm,
backspace=40mm,
height=fit,
width=fit,
]

\setuplayout


This code sets up different sizes for each page. However, the text does not flow from one page to the next. For example, if the even pages is very wide, and the odd page is narrow, then a paragraph starting on the even page and continuing on the odd page will run over.

Hans presented [a workaround] on the mailing list, with the caveat that it's "for novels only", meaning, no display math or floats. Consider yourself warned if you expect this to work beyond what's specified:

\startsetups [grid] [*default]
\nopenalties
\stopsetups

\setuppagenumbering
[alternative=doublesided]

\setuplayout
[grid=yes]

\definelayout
[odd]
[width=10cm,
lines=40]

\definelayout
[even]
[width=8cm,
lines=40]

\setuplayout
[odd]

\setuptolerance
[verytolerant]

\showframe

\def\SetLineWidths
{\scratchtoks \emptytoks
\ifdim\pagegoal=\maxdimen
\scratchdimen\textheight
\ifodd\realpageno
\noflines\namedlayoutparameter{odd}{lines}%
\else
\noflines\namedlayoutparameter{even}{lines}%
\fi
\else
\scratchdimen\dimexpr\pagegoal-\pagetotal\relax
\getnoflines\scratchdimen
\fi
\ifdim\scratchdimen<\lineheight
\page
\else
\scratchcounter\noflines\relax
\ifodd\realpageno
\doSetLineWidths{odd}{even}%
\else
\doSetLineWidths{even}{odd}%
\fi
\parshape \scratchcounter \the\scratchtoks \relax \ignorespaces
\fi}

\def\doSetLineWidths#1#2%
{\dorecurse\noflines
{\appendetoks 0cm \namedlayoutparameter{#1}{width} \to\scratchtoks}%
\dorecurse{2}
\dorecurse{\namedlayoutparameter{#2}{lines}}
{\appendetoks 0cm \namedlayoutparameter{#2}{width} \to\scratchtoks}%