%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 \installframedcommandhandler \??fp {fittingpage} \??fp \newdimen\fitting_page_width \newdimen\fitting_page_height \newbox \fitting_page_box \definepapersize [fittingpage] [\c!width=\fitting_page_width, \c!height=\fitting_page_height] \definemakeup [fittingpage] [\c!textstate=\v!empty, \c!doublesided=\v!no, \c!pagestate=\fittingpageparameter\c!pagestate]% \definelayout [fittingpage] [\v!page] \setuplayout [fittingpage] [\c!width=\fitting_page_width, \c!height=\fitting_page_height, \c!location=\v!middle] \appendtoks \setuevalue{\e!start\currentfittingpage}{\startfittingpage[\currentfittingpage]}% \setuevalue{\e!stop \currentfittingpage}{\stopfittingpage}% \to \everydefinefittingpage \unexpanded\def\startfittingpage {\dodoubleempty\start_fitting_page} \def\start_fitting_page[#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 \doifelsenothing{\fittingpageparameter\c!command} \start_fitting_page_normal \start_fitting_page_command} \def\start_fitting_page_command {\grabuntil{\e!stop\currentfittingpage}\stop_fitting_page_command} \def\stop_fitting_page_command#1% {\start_fitting_page_normal \fittingpageparameter\c!command{#1}% \stop_fitting_page_normal} \def\start_fitting_page_normal {\setbox\fitting_page_box\hbox \bgroup \inheritedfittingpageframed \bgroup \gobblespacetokens} \unexpanded\def\stop_fitting_page_normal {\removeunwantedspaces \egroup \egroup % finalize \doif{\fittingpageparameter\c!margin}\v!page {\setbox\fitting_page_box\hbox\bgroup \offsetbox [\c!leftoffset=\backspace, \c!rightoffset=\cutspace, \c!topoffset=\topspace, \c!bottomoffset=\bottomspace] {\box\fitting_page_box}% \egroup}% \doifsomething{\fittingpageparameter\c!scale} {\setbox\fitting_page_box\hbox\bgroup \scale[\c!scale=\fittingpageparameter\c!scale]{\box\fitting_page_box}% \egroup}% \ifdim\ht\fitting_page_box<\lineheight % write status : too small \setbox\scratchbox\vbox to \lineheight{\vss\box\scratchbox\vss}% \fi \fitting_page_width \wd\fitting_page_box \fitting_page_height\ht\fitting_page_box \startlocallayout % still valid? \let\checkcurrentlayout\relax % else interference with odd/even layout \processaction [\fittingpageparameter\c!paper] [ \v!auto=>\def\fittingpapersize{\printpapersize}, \s!unknown=>\let\fittingpapersize\commalistelement, \s!default=>\def\fittingpapersize{fittingpage}]% \expanded{\setuppapersize[fittingpage][\fittingpapersize]}% \startmakeup[fittingpage]% \box\fitting_page_box \stopmakeup \stoplocallayout % still valid? \egroup \autostoptext} \let\stopfittingpage\stop_fitting_page_normal \setupfittingpage [%\c!scale=1000, %\c!pagestate=, \c!strut=\v!no, \c!align=\v!normal, \c!offset=\v!overlay, \c!width=\v!fit, \c!height=\v!fit, \c!frame=\v!off] %D \TEX\ pages (for \METAPOST\ pages, see \type {meta-fig}): \definefittingpage [TEXpage] [\c!align=\v!normal] % needed, else problems ! %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