diff options
author | Karl Berry <karl@freefriends.org> | 2015-04-18 22:52:45 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2015-04-18 22:52:45 +0000 |
commit | 16aa5a7c87f18a2483d0d61795899f886781b51c (patch) | |
tree | 1d72f00b2a4185425393598402fe055c61d1de58 /Master/texmf-dist/tex/context/base/page-bck.mkiv | |
parent | e68dc4d5506d46bf72823234f902bc76d1f70352 (diff) |
context, from www.pragma-ade.com/context/beta/cont-tmf.zip (18apr15)
git-svn-id: svn://tug.org/texlive/trunk@36923 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/page-bck.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/page-bck.mkiv | 56 |
1 files changed, 50 insertions, 6 deletions
diff --git a/Master/texmf-dist/tex/context/base/page-bck.mkiv b/Master/texmf-dist/tex/context/base/page-bck.mkiv index 0246e8eb61b..01de48e8cda 100644 --- a/Master/texmf-dist/tex/context/base/page-bck.mkiv +++ b/Master/texmf-dist/tex/context/base/page-bck.mkiv @@ -55,7 +55,7 @@ %D This is the only spot where we hav ea low level dependency on the way %D parent chains are defined but we want the speed. -\def\page_backgrounds_check_background +\unexpanded\def\page_backgrounds_check_background {\ifcsname\??framed\currentotrbackground:\c!background\endcsname \edef\page_background_temp{\csname\??framed\currentotrbackground:\c!background\endcsname}% \ifx\page_background_temp\empty @@ -140,13 +140,15 @@ {\edef\currentotrbackground{\??layoutbackgrounds#1}% \page_backgrounds_check_background} -\def\doifsomebackgroundelse#1% +\def\doifelsesomebackground#1% {\ifcsname\??layoutbackgrounds#1\endcsname \expandafter\firstoftwoarguments \else \expandafter\secondoftwoarguments \fi} +\let\doifsomebackgroundelse\doifelsesomebackground + \def\doifsomebackground#1% {\ifcsname\??layoutbackgrounds#1\endcsname \expandafter\firstofoneargument @@ -277,7 +279,7 @@ \page_backgrounds_set_boxes \setbox#1\vbox {\offinterlineskip - \doifmarginswapelse{\copy\leftbackground}{\copy\rightbackground}% + \doifelsemarginswap{\copy\leftbackground}{\copy\rightbackground}% \box#1}% \fi} @@ -343,7 +345,7 @@ {\dontcomplain \swapmargins \ifconditional\swapbackgroundmargins - \doifmarginswapelse \donothing + \doifelsemarginswap \donothing {\swapmacros\v!rightmargin\v!leftmargin \swapmacros\v!rightedge \v!leftedge}% \fi @@ -501,7 +503,7 @@ \unexpanded\def\page_backgrounds_setup_double[#1][#2][#3]% if needed we can speed this up {\global\settrue\c_page_backgrounds_some \def\page_backgrounds_setup_step##1% - {\doifinsetelse{##1}\v_page_backgrounds_double_set + {\doifelseinset{##1}\v_page_backgrounds_double_set {\page_backgrounds_setup_and_check{##1}{#3}} {\def\page_backgrounds_setup_step_nested####1{\page_backgrounds_setup_and_check{##1####1}{#3}}% \processcommacommand[#2]\page_backgrounds_setup_step_nested}}% @@ -510,7 +512,7 @@ \unexpanded\def\page_backgrounds_setup_single[#1][#2][#3]% {\global\settrue\c_page_backgrounds_some - \doifcommonelse{#1}\v_page_backgrounds_single_set + \doifelsecommon{#1}\v_page_backgrounds_single_set {\def\page_backgrounds_setup_step##1{\page_backgrounds_setup_and_check{##1}{#2}}% \processcommacommand[#1]\page_backgrounds_setup_step \the\everybackgroundssetup}% @@ -607,6 +609,48 @@ \setfalse\c_page_backgrounds_some +%D Sometimes you have a document wide (page) background but need to overload it +%D locally. In such case (at least in my experience) the only values that get set +%D are the background and backgroundcolor (if set at all). A full inheritance chain +%D would complicate things because then we need to use named backgrounds which in +%D turn will make this mechanism slower. I considered independent local backgrounds +%D but that also complicates the code (not that much) but isolation means that we +%D need to set more parameters each time. The following simple approach proabbly +%D suits most usage. +%D +%D \starttyping +%D \starttext +%D \setupbackgrounds[page][background=color,backgroundcolor=red] +%D \input tufte \page +%D \setupbackgrounds[page][background=,backgroundcolor=] +%D \input tufte \page +%D \setupbackgrounds[page][background=color,backgroundcolor=red] +%D \input tufte \page +%D \pushbackground[page] +%D \setupbackgrounds[page][background=color,backgroundcolor=green] +%D \input tufte \page +%D \popbackground +%D \input tufte \page +%D \stoptext +%D \stoptyping + +\unexpanded\def\pushbackground[#1]% + {\pushmacro\popbackground + \edef\currentotrbackground{\??layoutbackgrounds#1}% + \unexpanded\edef\popbackground + {\setupframed + [\currentotrbackground] + [\c!background=\namedframedparameter{\currentotrbackground}\c!background, + \c!backgroundcolor=\namedframedparameter{\currentotrbackground}\c!backgroundcolor]% + \page_backgrounds_check_background + \popmacro\popbackground}% + \setupframed + [\currentotrbackground] + [\c!background=,\c!backgroundcolor=]% + \page_backgrounds_check_background} + +\let\popbackground\relax + \protect \endinput % %D The next series is used in local (for instance floating) backgrounds. |