ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Otared Kavian <otared@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: background over two page
Date: Mon, 18 Oct 2010 14:18:01 +0200	[thread overview]
Message-ID: <5EC1C613-30AD-448A-8048-455DE97762D8@gmail.com> (raw)
In-Reply-To: <AANLkTimg4B1vu3LgHm=4=-kUQcSWMQcki1y0QAHBaYuM@mail.gmail.com>

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

> On Mon, Oct 18, 2010 at 9:32 AM, Otared Kavian <otared@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 <otared@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
___________________________________________________________________________________


  reply	other threads:[~2010-10-18 12:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-14  9:05 Emanuele Sacco
2010-10-14  9:37 ` luigi scarso
2010-10-16 15:30   ` Emanuele Sacco
2010-10-18  7:32     ` Otared Kavian
2010-10-18  7:43       ` luigi scarso
2010-10-18 12:18         ` Otared Kavian [this message]
2010-10-18 15:22           ` Wolfgang Schuster
2010-10-18 20:20             ` Otared Kavian
2011-08-03 15:08             ` Aditya Mahajan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5EC1C613-30AD-448A-8048-455DE97762D8@gmail.com \
    --to=otared@gmail.com \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).