%D \module %D [ file=page-app, % from meta-fig %D version=1998.01.15, %D title=\CONTEXT\ Page Macros, %D subtitle=Independent page building, %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 / Applications} %D This needs an update with a proper define and inheritance. \unprotect \definepapersize [\??fp\s!dummy] [\c!width=\fittingwd, \c!height=\fittinght] \definelayout [\??fp\s!dummy] [\c!width=\fittingwd,\c!height=\fittinght,\c!location=\v!middle, \c!topspace=\!!zeropoint,\c!backspace=\!!zeropoint, \c!cutspace=\!!zeropoint,\c!bottomspace=\!!zeropoint, \c!textdistance=\!!zeropoint,\c!lines=0,\c!grid=\v!no, \c!top=\!!zeropoint,\c!bottom=\!!zeropoint, \c!margin=\!!zeropoint,\c!edge=\!!zeropoint, \c!leftmargin=\!!zeropoint,\c!leftedge=\!!zeropoint, \c!rightmargin=\!!zeropoint,\c!rightedge=\!!zeropoint, \c!header=\!!zeropoint,\c!footer=\!!zeropoint] \def\dostartfittingpage[#1][#2]% {\page % this is kind of tricky! there can be preceding page refs \autostarttext \bgroup % resulting in a zero height page; test fig-make ! \def\currentfittingpage{#1}% \dontcomplain % runs under current page regime, i.e. page variables passed to mp \getparameters[\currentfittingpage][\c!paper=,#2]% auto or size or nothing \setbox\scratchbox\hbox \bgroup % needed later \getparameters[\currentfittingpage][\c!paper=,#2]% auto or size or nothing \doifvalue{\currentfittingpage\c!margin}\v!page % undocumented {\offsetbox [\c!leftoffset=\backspace, \c!rightoffset=\cutspace, \c!topoffset=\topspace, \c!bottomoffset=\bottomspace]\hbox}% \bgroup \scale[\c!scale=\getvalue{\currentfittingpage\c!scale}]% \bgroup\localframed[\currentfittingpage]% \bgroup} \def\dostopfittingpage {\egroup % localframed \egroup % scale \egroup % offsetbox \egroup % scratchbox \edef\fittingwd{\the\wd\scratchbox}% \edef\fittinght{\the\ht\scratchbox}% \startlocallayout \ifdim\fittinght<\lineheight % write status : too small \setbox\scratchbox\vbox to \lineheight{\vss\box\scratchbox\vss}% \edef\fittinght{\the\lineheight}% \fi \let\checkcurrentlayout\relax % else interference with odd/even layout \processaction [\getvalue{\currentfittingpage\c!paper}] [ \v!auto=>\def\fittingpapersize{\printpapersize}, \s!unknown=>\let\fittingpapersize\commalistelement, \s!default=>\def\fittingpapersize{\??fp\s!dummy}]% \expanded{\setuppapersize[\??fp\s!dummy][\fittingpapersize]}% \definelayout [\v!page]% [\c!location=\v!middle, \c!width=\fittingwd, \c!height=\fittinght]% \setuplayout [\v!page]% \startmakeup[\v!standard][\c!textstate=\v!empty,\c!doublesided=\v!no,\c!pagestate=\getvalue{\currentfittingpage\c!pagestate}]% \centerbox{\box\scratchbox}% \stopmakeup \stoplocallayout \egroup \autostoptext} %D \TEX\ pages (for \METAPOST\ pages, see \type {meta-fig}): \presetlocalframed[\??tg] \unexpanded\def\setupTEXpage {\dodoubleargument\getparameters[\??tg]} \unexpanded\def\startTEXpage {\dosingleempty\dostartTEXpage} \def\dostartTEXpage[#1]% {\dostartfittingpage[\??tg][#1]\gobblespacetokens} \unexpanded\def\stopTEXpage {\removelastspace \dostopfittingpage} \setupTEXpage [\c!scale=1000, \c!pagestate=, \c!strut=\v!no, \c!align=\v!normal, % needed, else problems ! \c!offset=\v!overlay, \c!width=\v!fit, \c!height=\v!fit, \c!frame=\v!off] %D For Mojca: %D %D \starttyping %D \startTEXstream \chapter{Bla} Hello world!\crlf Hello world! \stopTEXstream %D \startTEXpage \chapter{Bla} Hello world!\crlf Hello world! \stopTEXpage %D \stoptyping %D %D maybe I should support stream=yes in framed. \unexpanded\def\startTEXstream {\dosingleempty\dostartTEXstream} \def\dostartTEXstream[#1]% old code, to be redone {\page \defineoutputstream[tex]% \enableoutputstream[tex]% \unexpanded\def\stopTEXstream {\disableoutputstream \startTEXpage \outputstreamunvbox[tex]% \stopTEXpage}} %D Application pages, a quick \MKIV\ hack: \definetypesetting[TEXapplication] \definebuffer[TEXapplication] % we could use a counter and saves runs on numbering them. \def\TEXapplicationfilename{\jobname-texapplication.tex} \def\stopTEXapplication {\savebuffer[\thedefinedbuffer{TEXapplication}][\TEXapplicationfilename]% \typesetfile[TEXapplication][\TEXapplicationfilename]\relax} %D \macros %D {startpagefigure} %D %D \starttyping %D \starttext \pagefigure[two.1] \stoptext %D \stoptyping \unexpanded\def\startpagefigure {\dodoubleempty\dostartpagefigure} \def\dostartpagefigure[#1][#2]% {\bgroup \getparameters[\??ex][\c!offset=\v!overlay,#2]% \startTEXpage[\c!offset=\@@exoffset]% \externalfigure[#1][#2]\ignorespaces} % so we can put some text below the graphic \unexpanded\def\stoppagefigure {\stopTEXpage \egroup} \def\pagefigure {\dodoubleempty\dopagefigure} \def\dopagefigure[#1][#2]% {\dostartpagefigure[#1][#2]\stoppagefigure} \protect \endinput