summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/page-lay.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/page-lay.mkiv')
-rw-r--r--Master/texmf-dist/tex/context/base/page-lay.mkiv69
1 files changed, 44 insertions, 25 deletions
diff --git a/Master/texmf-dist/tex/context/base/page-lay.mkiv b/Master/texmf-dist/tex/context/base/page-lay.mkiv
index 18972c3502e..28f9be594dc 100644
--- a/Master/texmf-dist/tex/context/base/page-lay.mkiv
+++ b/Master/texmf-dist/tex/context/base/page-lay.mkiv
@@ -202,10 +202,10 @@
%D
%D \showsetup{definepapersize}
-\def\definepapersize
+\unexpanded\def\definepapersize
{\dodoubleempty\dodefinepapersize}
-\def\definepapersize
+\unexpanded\def\definepapersize
{\dotripleempty\dodefinepapersize}
\def\dodefinepapersize[#1][#2][#3]%
@@ -275,7 +275,7 @@
\def\paperscale{1} \newif\ifnegateprintbox
-\def\setuppaper[#1]%
+\unexpanded\def\setuppaper[#1]%
{\getparameters[\??pp][\c!paper=,\c!page=,#1]%
\edef\@@ppxy{\the\numexpr\@@ppnx*\@@ppny\relax}%
\doifelsenothing\@@pppage
@@ -286,7 +286,7 @@
{\dodosetuppapersize[\@@pppage][\printpapersize]}
{\dodosetuppapersize[\@@pppage][\@@pppaper]}}}
-\def\setuppapersize
+\unexpanded\def\setuppapersize
{\dodoubleempty\dosetuppapersize}
\def\dosetuppapersize[#1][#2]%
@@ -424,7 +424,7 @@
% \def\checkforems[#1]%
% {\processcommalist[#1]\docheckforems}
-\ifx\setups\undefined \def\setups[#1]{\setdefaultpenalties} \fi
+\ifx\setups\undefined \unexpanded\def\setups[#1]{\setdefaultpenalties} \fi
% \newtoks \everybeforelayout \relax
% \newtoks \everyafterlayout \relax
@@ -434,6 +434,8 @@
{\expanded{\dododosetuppapersize[\layoutparameter\c!page][\layoutparameter\c!paper]}}%
\dorecalculatelayout}
+\ifdefined\docheckgridsnapping \else \let\docheckgridsnapping\relax \fi
+
\def\dorecalculatelayout
{%\the\everybeforelayout
\setups[\layoutparameter\c!preset]%
@@ -448,15 +450,11 @@
\global\backspace \layoutparameter\c!backspace
\global\topspace \layoutparameter\c!topspace
\setlayoutdimensions % the rest of the `dimensions'
- \doifelse\@@lygrid\v!yes\gridsnappingtrue\gridsnappingfalse
- \ifgridsnapping
- \setsystemmode\v!grid
- \else
- \resetsystemmode\v!grid
- \fi
- \setups[\layoutparameter\c!setups]% depends on gridsnapping !
+ \docheckgridsnapping
+ \doprocesslocalsetups{\layoutparameter\c!setups}% depends on gridsnapping !
\simplesetupwhitespace
\simplesetupblank
+ \setupinterlinespace[\v!reset]% \synchronizegloballinespecs
\global\cutspace\layoutparameter\c!cutspace
\relax
\doifelse{\layoutparameter\c!width}\v!middle
@@ -535,7 +533,6 @@
\calculatehsizes
\calculatevsizes
\calculatepseudocolumns
- \checkgridsnapping
\recalculatebackgrounds}
\def\calculatepseudocolumns
@@ -656,7 +653,7 @@
\v!doublesided=>\doublesidedprinttrue,
\v!singlesided=>\doublesidedprintfalse]}
-\def\definelayout
+\unexpanded\def\definelayout
{\dodoubleargument\dodefinelayout}
\def\dodefinelayout[#1][#2]%
@@ -685,7 +682,7 @@
\checkcurrentlayout % here ?
\presetcenterpagebox}
-\def\setuplayout
+\unexpanded\def\setuplayout
{\dodoubleempty\dosetuplayout}
\let\@@zaheight\!!zeropoint
@@ -718,7 +715,7 @@
\fi}
\def\adaptpagedimensionsindeed
- {\rawdoifinsetelse\realfolio\adaptedpages
+ {\rawdoifinset\realfolio\adaptedpages
{\removefromcommalist\realfolio\adaptedpages
\getvalue{\??za\realfolio}%
\letbeundefined{\??za\realfolio}}}
@@ -996,14 +993,12 @@
%D it is used in cross referencing. The next switch is set
%D when we start at an even page.
-\newif\ifshiftedrealpageno
-
-% We could use nested if here plu ssone \@EAEAEA's but but the
+% We could use nested if here plus some \@EAEAEA's but but the
% next variant has less expansion which is nicer in tracing.
-\def\doifoddpageelse {\ifshiftedrealpageno\expandafter\doifoddpageelseyes\else\expandafter\doifoddpageelsenop\fi}
-\def\doifoddpageelseyes{\ifodd\realpageno\expandafter\secondoftwoarguments\else\expandafter\firstoftwoarguments\fi}
-\def\doifoddpageelsenop{\ifodd\realpageno\expandafter\firstoftwoarguments\else\expandafter\secondoftwoarguments\fi}
+\def\doifoddpageelse {\ifodd\pagenoshift\expandafter\doifoddpageelseyes \else\expandafter\doifoddpageelsenop \fi}
+\def\doifoddpageelseyes{\ifodd\realpageno \expandafter\secondoftwoarguments\else\expandafter\firstoftwoarguments \fi}
+\def\doifoddpageelsenop{\ifodd\realpageno \expandafter\firstoftwoarguments \else\expandafter\secondoftwoarguments\fi}
\let\doifonevenpaginaelse\doifoddpageelse
@@ -1035,6 +1030,30 @@
\def\settexthoffset
{\texthoffset\doifbothsides\backspace\backspace{\dimexpr\paperwidth-\backspace-\makeupwidth\relax}}
+% The next hack is too tricky as we may shipout more pages:
+%
+% \def\freezepagestatechecks
+% {\the\everyfreezepagestatechecks}
+%
+% \newtoks \everyfreezepagestatechecks
+%
+% \appendtoks
+% \doifbothsides
+% {\let\doifbothsides\firstofthreearguments}%
+% {\let\doifbothsides\secondofthreearguments}%
+% {\let\doifbothsides\thirdofthreearguments}%
+% \rightorleftpageaction
+% {\let\rightorleftpageaction\firstoftwoarguments}%
+% {\let\rightorleftpageaction\secondoftwoarguments}%
+% \doifmarginswapelse
+% {\let\doifmarginswapelse\firstoftwoarguments}%
+% {\let\doifmarginswapelse\secondoftwoarguments}%
+% \to \everyfreezepagestatechecks
+%
+% \prependtoks
+% \freezepagestatechecks
+% \to \everybeforeshipout
+
\def\goleftonpage
{\hskip-\dimexpr\leftmargindistance+\leftmarginwidth+\leftedgedistance+\leftedgewidth\relax}
@@ -1106,11 +1125,11 @@
%D {\definelayout}, so this hack will disappear in future
%D versions.
-\def\startlocallayout
+\unexpanded\def\startlocallayout
{\globalpushmacro\restorepapersize
\globalpushmacro\currentlayout}
-\def\stoplocallayout
+\unexpanded\def\stoplocallayout
{\globalpopmacro\currentlayout
\globalpopmacro\restorepapersize
\restorepapersize
@@ -1167,7 +1186,7 @@
\c!leftedgedistance=\layoutparameter\c!edgedistance,
\c!leftmargin=\layoutparameter\c!margin,
\c!leftmargindistance=\layoutparameter\c!margindistance,
- \c!width=.71428571429\paperwidth, % 15.0cm
+ \c!width=.71428571429\paperwidth, % 15.0cm \dimexpr\
\c!rightmargindistance=\layoutparameter\c!margindistance,
\c!rightmargin=\layoutparameter\c!margin,
\c!rightedgedistance=\layoutparameter\c!edgedistance,