summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/page-fac.mkiv
blob: fef1cd5ac35acac529a63f0af606fb42e921c7af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
%D \module
%D   [       file=page-fac,   % moved from page-ini
%D        version=2011.12.07, % 2000.10.20,
%D          title=\CONTEXT\ Page Macros,
%D       subtitle=Facing Pages,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

\writestatus{loading}{ConTeXt Page Macros / Facing Pages}

\unprotect

%D \macros
%D   {setupoppositeplacing,startopposite}
%D
%D \starttyping
%D \starttext
%D test \startopposite \blackrule[width=3cm,height=4cm] \stopopposite test
%D test \startopposite \blackrule[width=3cm,height=4cm] \stopopposite test
%D \stoptext
%D \stoptyping

\newbox\b_page_facings_content

\unexpanded\def\setupoppositeplacing
  {\dodoubleargument\getparameters[\??np]}

\unexpanded\def\startopposite
  {\dowithnextboxcontent
     {\hsize\makeupwidth}%
     {\global\setbox\b_page_facings_content\vbox
        {\ifvoid\b_page_facings_content
           \@@npbefore
         \else
           \@@npinbetween
           \unvbox\b_page_facings_content
         \fi
         \box\nextbox}}%
     \vbox\bgroup}

\unexpanded\def\stopopposite
  {\egroup}

\def\page_facings_finish
  {\ifvoid\b_page_facings_content\else
     \global\setbox\b_page_facings_content\vbox to \makeupheight
       {\unvbox\b_page_facings_content
        \@@npafter
        \vss}%
   \fi}

\def\page_facings_flush
  {\doif\@@npstate\v!start
     {\ifvoid\b_page_facings_content\else
        \ifnum\realpageno>\plusone
          \begingroup
          \pageornamentstate\plusone % tricky
          \page_facings_finish
          \page_boxes_shipout{\page_boxes_constructed_page\box\b_page_facings_content}%
          \endgroup
        \else
          \global\setbox\b_page_facings_content\emptybox
        \fi
      \fi}}

\setupoppositeplacing
  [\c!state=\v!start,
   \c!before=,
   \c!inbetween=\blank,
   \c!after=]

\protect \endinput