# [NTG-context] formula block with align and pagebreak

Tue Jul 18 18:06:32 CEST 2006

On Tue, 18 Jul 2006, Tobias Burnus wrote:

> Hello,
>
> I have often longer equations of the type
>
> \startformula\startalign
>  A = b c
>  B = c d
>  E = g h
> \intertext{Some intermediate text}
>  F = h j
>  G = k l
> \stopformula\stopalign
>
> I would like to keep the alignment (per page), however I also would like
> to have automatic page breaks inbetween. I can split it manually into
> two \startformula\startalign ... \stopformula\stopalign blocks, but this
> I would have to adapt any time I change something, which changes the
> text length, before that block.
>
> Any idea?
>
> Additional question: Does anyone know why in the example the "Gauss'
> law" starts not at the top of the page but roughly two line further down?
>
> Tobias

Page break with math is a bit tricky at the moment. Before I come to

\definetypeface [zapf] [cg] [calligraphy] [chancery]
\switchtotypeface [zapf] [12pt,cg]

Zapf Chancery

\input tufte.tex

Shouldn't that be surrounded by a start/stop (or bgroup/egroup) to
prevent font changes in the entire document?

Tobias, startintertext/stopintertext are already in the core, so you
do not need to redefine those in your document.

Now coming back to the main problem of equations not breaking across
pages. Taco had provided a fix for making this work. There are a few
issues with math equations breaking across pages, and this is the
reason that the fix is not in the core. I am attaching Taco's fix,
keep in mind that this is not final.

-------------- next part --------------
\unprotect

\def\dostartmathcases[#1][#2]%
{\begingroup
\edef\currentmathcases{#1}%
\doifassignmentelse{#2}{\setupmathcases[#1][#2]}\donothing
\mathcasesparameter\c!left
\vcenter\bgroup
\pushmacro\docasesNC
\let\endmath\relax
\def\NC{\docasesNC}%
\def\MC{\docasesNC\ifmmode\else$\def\endmath{$}\fi}%
\global\let\docasesNC\dodocasesNC
\def\NR{\unskip\endmath&\global\let\docasesNC\dodocasesNC\doxxdoubleempty\docasesNR}%
\normalbaselines
\mathsurround\zeropoint
\everycr\emptytoks
\tabskip\zeropoint
\global\eqaligncolumn\plusone
\halign\bgroup
$\mathcasesparameter\c!style##$\hfil
&\hskip\mathcasesparameter\c!distance\relax
\popmacro\docasesNC##\hfil
&\hskip\mathcasesparameter\c!numberdistance\relax
\span\textineqalign{##}%
\crcr} % todo: number

\def\preparemathmatrix
{\!!toksa{\strut
\firstineqalign\leftofeqalign \span
\textineqalign{\mathmatrixparameter\c!style ##}\rightofeqalign}%
\!!toksb{&\hskip\mathmatrixparameter\c!distance
\nextineqalign\leftofeqalign \span
\textineqalign{\mathmatrixparameter\c!style ##}\rightofeqalign}%
\!!toksc{&&\hskip\mathmatrixparameter\c!distance
\leftofeqalign \span
\textineqalign{\mathmatrixparameter\c!style ##}\rightofeqalign}%
\buildmathmatrix
\halign \@EA \bgroup\the\scratchtoks \crcr}

\def\dostartmathmatrix[#1][#2]%
{\begingroup
\edef\currentmathmatrix{#1}%
\doifassignmentelse{#2}{\setupmathmatrix[#1][#2]}\donothing
\null
\mathmatrixparameter\c!left
\processaction
[\mathmatrixparameter\c!location]
[\s!default=>\let\vchbox\vcenter,
\s!unknown=>\let\vchbox\vcenter,
\v!top=>\let\vchbox\vtop,
\v!bottom=>\let\vchbox\vbox]%
\vchbox\bgroup
\pushmacro\domatrixNC
\let\endmath\relax
\def\NC{\domatrixNC}%
\def\MC{\domatrixNC\ifmmode\else$\def\endmath{$}\fi}%
\global\let\domatrixNC\dodomatrixNC
\def\NR{\endmath\global\let\domatrixNC\dodomatrixNC\crcr}%
\normalbaselines
\mathsurround\zeropoint
\everycr\emptytoks
\tabskip\zeropoint
\eqaligncolumn\zerocount % could be \scratchcounter
\scratchcounter=\ifnum\eqaligncolumn>\scratchcounter \eqaligncolumn \else \plusone \fi
\global\eqaligncolumn\plusone
\preparemathmatrix } % uses scratchcounter

\def\dobothaligneqalignno#1%
{\ifmmode
\displ at y
\global\chardef\mathnumberstatus\plusone
\ifcase\mathraggedstatus
\def\finishalignno{\crcr\egroup}%
\else
% we're in a mathbox
\vcenter\bgroup
\def\finishalignno{\crcr\egroup\egroup}%
\fi
\fi
#1%
\halign \ifcase\eqalignmode \or to \displaywidth \fi \@EA \bgroup\the\scratchtoks\crcr}

\protect