Re: [NTG-context] background over two page

2010-10-18 Thread Otared Kavian

On 16 oct. 2010, at 17:30, Emanuele Sacco wrote:

 A solution by Luigi:
 […]

Hi Emmanuele, Hi Luigi,

Please excuse me if I get involved in the thread of your discussions…
I was interested both by the question ad the solutions, since I had a similar 
problem some time ago, but I gave up.

Now that you give a solution with \definetextbackground (the solution below), I 
would like to point out that with this definition the beginning of the 
highlighted text does not have the upper frame turned on, while at the end the 
bottom frame is turned on (of course this is what we want).
So my question is: can one have both the upper frame turned on at the begining 
of the highlighted text (and only there) and also the bottom frame turned on at 
the end (and only there).
In other words, a highlighted framed text spanning over two (or more) pages, 
would be like a big rectangle of which the upper and the bottom frame, as well 
as the left and right frames, are shown.

Thanks in advance for you attention: OK

 An alternative solution with the command \definetextbackground:
 
 %%
 \setupcolors[state=start]
 \enableregime[utf]
 \def\Linea{\startMPcode
 draw (0,0) -- (\the\textwidth-1,0) withpen pencircle scaled 1bp withcolor red;
 \stopMPcode
 }
 \definetextbackground
 [Prova]
 [
 mp=background:mp,
 location=paragraph,
 rulethickness=1pt,
 width=broad,
 leftoffset=1em,
 rightoffset=1em,
 after={\Linea}
 ]
 \startuseMPgraphic{background:mp}
 path p;
 for i = 1 upto nofmultipars :
 p = (multipars[i]
 topenlarged 5pt
 bottomenlarged 10pt);
 fill p withcolor lightgray ;
 draw leftboundary p withpen pencircle scaled 1bp withcolor red ;
 draw rightboundary p withpen pencircle scaled 1bp withcolor red ;
 endfor;
 \stopuseMPgraphic
 
 
 \starttext
 
 \startProva
 \input knuth
 \input knuth
 \input knuth
 \input knuth
 \input knuth
 \stopProva
 
 \stoptext
 %%
 
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] background over two page

2010-10-18 Thread luigi scarso
On Mon, Oct 18, 2010 at 9:32 AM, Otared Kavian ota...@gmail.com wrote:

 On 16 oct. 2010, at 17:30, Emanuele Sacco wrote:

 A solution by Luigi:
 […]

 Hi Emmanuele, Hi Luigi,

 Please excuse me if I get involved in the thread of your discussions…
 I was interested both by the question ad the solutions, since I had a similar 
 problem some time ago, but I gave up.

 Now that you give a solution with \definetextbackground (the solution below), 
 I would like to point out that with this definition the beginning of the 
 highlighted text does not have the upper frame turned on, while at the end 
 the bottom frame is turned on (of course this is what we want).
 So my question is: can one have both the upper frame turned on at the 
 begining of the highlighted text (and only there) and also the bottom frame 
 turned on at the end (and only there).
 In other words, a highlighted framed text spanning over two (or more) pages, 
 would be like a big rectangle of which the upper and the bottom frame, as 
 well as the left and right frames, are shown.

 Thanks in advance for you attention: OK
With my solution it's a matter of changing few lines
bottomframe=off,topframe=on,


bottomframe=on,topframe=off,


-- 
luigi
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] background over two page

2010-10-18 Thread Otared Kavian
On 18 oct. 2010, at 09:43, luigi scarso wrote:

 On Mon, Oct 18, 2010 at 9:32 AM, Otared Kavian ota...@gmail.com wrote:
 […]
 With my solution it's a matter of changing few lines
 bottomframe=off,topframe=on,
 
 bottomframe=on,topframe=off,


Thanks Luigi!
Your solution works as intended when the framed, highlighted text with 
background spans over two pages (though it doesn't when it spans over three 
pages or more, but this is not a real issue, since it is a bad idea to have 
such long highlighted texts…).

Best regards: OK

I copy below your modfied solution:

% A solution by Luigi Scarso, slightly modified by him

%%
\newdimen\SpaceLeft

\def\CheckSpace{%
\ifdim\pagetotal=0pt\SpaceLeft=\vsize\else\SpaceLeft=\pagegoal\advance\SpaceLeft
by -\pagetotal\advance\SpaceLeft by -2\lineheight\fi}%

\setupcolors[state=start]

\long\def\StartBg#1\StopBg{%
\bgroup
\setbox8000=\vbox{\hsize=\dimexpr\textwidth-1em\relax#1}
\CheckSpace% \the\SpaceLeft\the\ht8000 \the\dp8000
\ifdim\dimexpr(\ht8000+\dp8000)\SpaceLeft\relax
%
\setbox8001=\vsplit8000 to \SpaceLeft%
\setbox8001=\vbox{\unvbox8001}%
%
\setupbackground
[bottomframe=off,
topframe=on, % suggested by Luigi, in his answer
rulethickness=1pt,
rightframe=on,
width=\textwidth,
leftframe=on]
\startbackground\unvbox8001\stopbackground%

\setupbackground
[bottomframe=on,
topframe=off, % suggested by Luigi, in his answer
rulethickness=1pt,
rightframe=on,
width=\textwidth,
leftframe=on]
\startbackground\unvbox8000\stopbackground%
\else
\setupbackground
[bottomframe=on,
topframe=on,
rulethickness=1pt,
rightframe=on,
leftframe=on]
\startbackground #1\stopbackground%
\fi
\egroup
}

\setupbackground
[bottomframe=on,
rulethickness=1pt,
rightframe=on,
leftframe=on]

\starttext

\input ward
\blank

\StartBg
\dorecurse{2}{\input knuth\par}
\StopBg

\blank
\input ward
\blank
\StartBg
\dorecurse{4}{\input knuth\par}
\StopBg

\blank
\input ward

\stoptext
%%

On 18 oct. 2010, at 09:43, luigi scarso wrote:

 On Mon, Oct 18, 2010 at 9:32 AM, Otared Kavian ota...@gmail.com wrote:
 
 On 16 oct. 2010, at 17:30, Emanuele Sacco wrote:
 
 A solution by Luigi:
 […]
 
 Hi Emmanuele, Hi Luigi,
 
 Please excuse me if I get involved in the thread of your discussions…
 I was interested both by the question ad the solutions, since I had a 
 similar problem some time ago, but I gave up.
 
 Now that you give a solution with \definetextbackground (the solution 
 below), I would like to point out that with this definition the beginning of 
 the highlighted text does not have the upper frame turned on, while at the 
 end the bottom frame is turned on (of course this is what we want).
 So my question is: can one have both the upper frame turned on at the 
 begining of the highlighted text (and only there) and also the bottom frame 
 turned on at the end (and only there).
 In other words, a highlighted framed text spanning over two (or more) pages, 
 would be like a big rectangle of which the upper and the bottom frame, as 
 well as the left and right frames, are shown.
 
 Thanks in advance for you attention: OK
 With my solution it's a matter of changing few lines
 bottomframe=off,topframe=on,
 
 
 bottomframe=on,topframe=off,
 
 
 -- 
 luigi
 ___
 If your question is of interest to others as well, please add an entry to the 
 Wiki!
 
 maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
 webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
 archive  : http://foundry.supelec.fr/projects/contextrev/
 wiki : http://contextgarden.net
 ___


___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] background over two page

2010-10-18 Thread Wolfgang Schuster

Am 18.10.2010 um 14:18 schrieb Otared Kavian:

 Your solution works as intended when the framed, highlighted text with 
 background spans over two pages (though it doesn't when it spans over three 
 pages or more, but this is not a real issue, since it is a bad idea to have 
 such long highlighted texts…).


I guess this is also possible with textbackground:

\newcounter\CurrentBackground

\def\StartBackground
  {\doglobal\increment\CurrentBackground
   \setposition{Background:b:\CurrentBackground}%
   \startbackground}

\def\StopBackground
  {\stopbackground
   \setposition{Background:e:\CurrentBackground}}

\def\DrawBackground
  
{\ifnum\MPp{Background:b:\CurrentBackground}=\MPp{Background:e:\CurrentBackground}
 \startMPcode
 draw topboundaryOverlayBox withcolor red ;
 draw bottomboundary OverlayBox withcolor red ;
 draw leftboundary   OverlayBox withcolor red ;
 draw rightboundary  OverlayBox withcolor red ;
 \stopMPcode
   \else\ifnum\realpageno=\MPp{Background:b:\CurrentBackground}
 \startMPcode
 draw topboundaryOverlayBox withcolor red ;
 draw leftboundary   OverlayBox withcolor red ;
 draw rightboundary  OverlayBox withcolor red ;
 \stopMPcode
   \else\ifnum\realpageno=\MPp{Background:e:\CurrentBackground}
 \startMPcode
 draw bottomboundary OverlayBox withcolor red ;
 draw leftboundary   OverlayBox withcolor red ;
 draw rightboundary  OverlayBox withcolor red ;
 \stopMPcode
   \else
 \startMPcode
 draw leftboundary   OverlayBox withcolor red ;
 draw rightboundary  OverlayBox withcolor red ;
 \stopMPcode
   \fi\fi\fi}

\defineoverlay[DrawBackground][\DrawBackground]

\starttext

\setupbackground[background=DrawBackground]

\input knuth

\StartBackground
\dorecurse{12}{\input knuth\par}
\StopBackground

\input knuth

\StartBackground
\input knuth\par
\StopBackground

\input knuth

\stoptext

Wolfgang

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] background over two page

2010-10-18 Thread Otared Kavian
Hi Wolfgang, 

Indeed your solution works without any flaw…
Looking at your code, I learned that Overlaybox is an object which can be 
filled with a background color, as in:
fill OverlayBox withcolor lightgray ;
so that the background can be in color.

Should we add this kind of problems and solutions to the wiki?
If yes, I am willing to do so.

Best regards: OK

On 18 oct. 2010, at 17:22, Wolfgang Schuster wrote:

 
 Am 18.10.2010 um 14:18 schrieb Otared Kavian:
 
 Your solution works as intended when the framed, highlighted text with 
 background spans over two pages (though it doesn't when it spans over three 
 pages or more, but this is not a real issue, since it is a bad idea to have 
 such long highlighted texts…).
 
 
 I guess this is also possible with textbackground:
 
 \newcounter\CurrentBackground
 
 \def\StartBackground
  {\doglobal\increment\CurrentBackground
   \setposition{Background:b:\CurrentBackground}%
   \startbackground}
 
 \def\StopBackground
  {\stopbackground
   \setposition{Background:e:\CurrentBackground}}
 
 \def\DrawBackground
  
 {\ifnum\MPp{Background:b:\CurrentBackground}=\MPp{Background:e:\CurrentBackground}
 \startMPcode
 draw topboundaryOverlayBox withcolor red ;
 draw bottomboundary OverlayBox withcolor red ;
 draw leftboundary   OverlayBox withcolor red ;
 draw rightboundary  OverlayBox withcolor red ;
 \stopMPcode
   \else\ifnum\realpageno=\MPp{Background:b:\CurrentBackground}
 \startMPcode
 draw topboundaryOverlayBox withcolor red ;
 draw leftboundary   OverlayBox withcolor red ;
 draw rightboundary  OverlayBox withcolor red ;
 \stopMPcode
   \else\ifnum\realpageno=\MPp{Background:e:\CurrentBackground}
 \startMPcode
 draw bottomboundary OverlayBox withcolor red ;
 draw leftboundary   OverlayBox withcolor red ;
 draw rightboundary  OverlayBox withcolor red ;
 \stopMPcode
   \else
 \startMPcode
 draw leftboundary   OverlayBox withcolor red ;
 draw rightboundary  OverlayBox withcolor red ;
 \stopMPcode
   \fi\fi\fi}
 
 \defineoverlay[DrawBackground][\DrawBackground]
 
 \starttext
 
 \setupbackground[background=DrawBackground]
 
 \input knuth
 
 \StartBackground
 \dorecurse{12}{\input knuth\par}
 \StopBackground
 
 \input knuth
 
 \StartBackground
 \input knuth\par
 \StopBackground
 
 \input knuth
 
 \stoptext
 
 Wolfgang
 
 ___
 If your question is of interest to others as well, please add an entry to the 
 Wiki!
 
 maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
 webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
 archive  : http://foundry.supelec.fr/projects/contextrev/
 wiki : http://contextgarden.net
 ___


___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] background over two page

2010-10-16 Thread Emanuele Sacco
A solution by Luigi:

%%
\newdimen\SpaceLeft
\def\CheckSpace{%
\ifdim\pagetotal=0pt\SpaceLeft=\vsize\else\SpaceLeft=\pagegoal\advance\SpaceLeft
 by -\pagetotal\advance\SpaceLeft by -2\lineheight\fi}%


\setupcolors[state=start]


\long\def\StartBg#1\StopBg{%
\bgroup
\setbox8000=\vbox{\hsize=\dimexpr\textwidth-1em\relax#1}
\CheckSpace% \the\SpaceLeft\the\ht8000 \the\dp8000
\ifdim\dimexpr(\ht8000+\dp8000)\SpaceLeft\relax
%
\setbox8001=\vsplit8000 to \SpaceLeft%
\setbox8001=\vbox{\unvbox8001}%
%
\setupbackground
[bottomframe=off,
rulethickness=1pt,
rightframe=on,width=\textwidth,
leftframe=on]
\startbackground\unvbox8001\stopbackground%

\setupbackground
[bottomframe=on,
rulethickness=1pt,
rightframe=on,width=\textwidth,
leftframe=on]
\startbackground\unvbox8000\stopbackground%
\else
\setupbackground
[bottomframe=on,
rulethickness=1pt,
rightframe=on,
leftframe=on]
\startbackground #1\stopbackground%
\fi
\egroup
}

\setupbackground
[bottomframe=on,
rulethickness=1pt,
rightframe=on,
leftframe=on]

\starttext

\startbackground
\input knuth
\stopbackground

e poi

\StartBg
\input knuth
\input knuth
\input knuth
\StopBg

\stoptext
%%



An alternative solution with the command \definetextbackground:

%%
\setupcolors[state=start]
\enableregime[utf]
\def\Linea{\startMPcode
 draw (0,0) -- (\the\textwidth-1,0) withpen pencircle scaled 1bp withcolor red;
\stopMPcode
}
\definetextbackground
[Prova]
[
mp=background:mp,
location=paragraph,
rulethickness=1pt,
width=broad,
leftoffset=1em,
rightoffset=1em,
after={\Linea}
]
\startuseMPgraphic{background:mp}
path p;
for i = 1 upto nofmultipars :
p = (multipars[i]
topenlarged 5pt
bottomenlarged 10pt);
fill p withcolor lightgray ;
draw leftboundary p withpen pencircle scaled 1bp withcolor red ;
draw rightboundary p withpen pencircle scaled 1bp withcolor red ;
endfor;
\stopuseMPgraphic


\starttext

\startProva
\input knuth
\input knuth
\input knuth
\input knuth
\input knuth
\stopProva

\stoptext
%%

bye

ES

2010/10/14 luigi scarso luigi.sca...@gmail.com:
 On Thu, Oct 14, 2010 at 11:05 AM, Emanuele Sacco
 emanuelesa...@gmail.com wrote:
 Hi all,

 I'm using context MkII.
 My code is


 \setupcolors[state=start]
 \setupbackground
 [bottomframe=on,
 rulethickness=1pt,
 rightframe=on,
 leftframe=on]

 \starttext
 Good:
 \startbackground
 \input knuth
 \stopbackground

 Not good:

 \startbackground
 \input knuth
 \input knuth
 \input knuth
 \stopbackground
 \stoptext



 The second backgrounded text is on two pages. Is there a way to not
 show the bottomframe at the end of the first page?
 thanks

 ES
 --
 Al mondo ci sono 10 tipi di persone: quelli che conoscono il sistema
 binario e quelli che non lo conoscono.
 ___
 If your question is of interest to others as well, please add an entry to 
 the Wiki!

 maillist : ntg-context@ntg.nl / 
 http://www.ntg.nl/mailman/listinfo/ntg-context
 webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
 archive  : http://foundry.supelec.fr/projects/contextrev/
 wiki     : http://contextgarden.net
 ___


 As always  my pov: a wrapper macro.

 \showframe
 \newdimen\SpaceLeft
 \def\CheckSpace{%
 \ifdim\pagetotal=0pt\SpaceLeft=\vsize\else\SpaceLeft=\pagegoal\advance\SpaceLeft
  by -\pagetotal\advance\SpaceLeft by -2\lineheight\fi}%


 \setupcolors[state=start]


 \long\def\StartBg#1\StopBg{%
 \bgroup
 \setbox8000=\vbox{#1}
 \CheckSpace% \the\SpaceLeft\the\ht8000 \the\dp8000
 \ifdim\dimexpr(\ht8000+\dp8000)\SpaceLeft\relax
 %
 \setbox8001=\vsplit8000 to \SpaceLeft%
 \setbox8001=\vbox{\unvbox8001}%
 %
 \setupbackground
 [bottomframe=off,
 rulethickness=1pt,
 rightframe=on,
 leftframe=on]
 \startbackground\unvbox8001\stopbackground%

 \setupbackground
 [bottomframe=on,
 rulethickness=1pt,
 rightframe=on,
 leftframe=on]
 \startbackground\unvbox8000\stopbackground%
 \else
 \setupbackground
 [bottomframe=on,
 rulethickness=1pt,
 rightframe=on,
 leftframe=on]
 \startbackground #1\stopbackground%
 \fi
 \egroup
 }

 \setupbackground
 [bottomframe=on,
 rulethickness=1pt,
 rightframe=on,
 leftframe=on]

 \starttext
 Good:
 \startbackground
 \input knuth
 \stopbackground

 Not good:

 \StartBg
 \input knuth
 \input knuth
 \input knuth
 \StopBg

 \stoptext



 --
 luigi
 ___
 If your question is of interest to others as well, please add an entry to the 
 Wiki!

 maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
 webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
 archive  : http://foundry.supelec.fr/projects/contextrev/
 wiki     : http://contextgarden.net
 

[NTG-context] background over two page

2010-10-14 Thread Emanuele Sacco
Hi all,

I'm using context MkII.
My code is


\setupcolors[state=start]
\setupbackground
[bottomframe=on,
rulethickness=1pt,
rightframe=on,
leftframe=on]

\starttext
Good:
\startbackground
\input knuth
\stopbackground

Not good:

\startbackground
\input knuth
\input knuth
\input knuth
\stopbackground
\stoptext



The second backgrounded text is on two pages. Is there a way to not
show the bottomframe at the end of the first page?
thanks

ES
-- 
Al mondo ci sono 10 tipi di persone: quelli che conoscono il sistema
binario e quelli che non lo conoscono.
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] background over two page

2010-10-14 Thread luigi scarso
On Thu, Oct 14, 2010 at 11:05 AM, Emanuele Sacco
emanuelesa...@gmail.com wrote:
 Hi all,

 I'm using context MkII.
 My code is


 \setupcolors[state=start]
 \setupbackground
 [bottomframe=on,
 rulethickness=1pt,
 rightframe=on,
 leftframe=on]

 \starttext
 Good:
 \startbackground
 \input knuth
 \stopbackground

 Not good:

 \startbackground
 \input knuth
 \input knuth
 \input knuth
 \stopbackground
 \stoptext



 The second backgrounded text is on two pages. Is there a way to not
 show the bottomframe at the end of the first page?
 thanks

 ES
 --
 Al mondo ci sono 10 tipi di persone: quelli che conoscono il sistema
 binario e quelli che non lo conoscono.
 ___
 If your question is of interest to others as well, please add an entry to the 
 Wiki!

 maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
 webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
 archive  : http://foundry.supelec.fr/projects/contextrev/
 wiki     : http://contextgarden.net
 ___


As always  my pov: a wrapper macro.

\showframe
\newdimen\SpaceLeft
\def\CheckSpace{%
\ifdim\pagetotal=0pt\SpaceLeft=\vsize\else\SpaceLeft=\pagegoal\advance\SpaceLeft
 by -\pagetotal\advance\SpaceLeft by -2\lineheight\fi}%


\setupcolors[state=start]


\long\def\StartBg#1\StopBg{%
\bgroup
\setbox8000=\vbox{#1}
\CheckSpace% \the\SpaceLeft\the\ht8000 \the\dp8000
\ifdim\dimexpr(\ht8000+\dp8000)\SpaceLeft\relax
%
\setbox8001=\vsplit8000 to \SpaceLeft%
\setbox8001=\vbox{\unvbox8001}%
%
\setupbackground
[bottomframe=off,
rulethickness=1pt,
rightframe=on,
leftframe=on]
\startbackground\unvbox8001\stopbackground%

\setupbackground
[bottomframe=on,
rulethickness=1pt,
rightframe=on,
leftframe=on]
\startbackground\unvbox8000\stopbackground%
\else
\setupbackground
[bottomframe=on,
rulethickness=1pt,
rightframe=on,
leftframe=on]
\startbackground #1\stopbackground%
\fi
\egroup
}

\setupbackground
[bottomframe=on,
rulethickness=1pt,
rightframe=on,
leftframe=on]

\starttext
Good:
\startbackground
\input knuth
\stopbackground

Not good:

\StartBg
\input knuth
\input knuth
\input knuth
\StopBg

\stoptext



-- 
luigi
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___