ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen via ntg-context <ntg-context@ntg.nl>
To: ntg-context@ntg.nl
Cc: Hans Hagen <j.hagen@freedom.nl>
Subject: [NTG-context] Re: Breakable tcolorbox in ConTeXt
Date: Sun, 11 Aug 2024 13:16:12 +0200	[thread overview]
Message-ID: <be6ee0c7-c1ef-45a7-815d-e9703a03b063@freedom.nl> (raw)
In-Reply-To: <CALOhoe+MN0AE50q5c=uNCwrwjwDpjQxd54vTbLDQJXs4ES3iEA@mail.gmail.com>

On 8/11/2024 11:24 AM, Florent Michel wrote:
> Hi,
> 
> I am trying to reproduce the behaviour of the tcolorbox LaTeX package, 
> more specifically breakable boxes (as illustrated here: 
> https://tex.stackexchange.com/a/676607/123770 
> <https://tex.stackexchange.com/a/676607/123770>). It works nicely out of 
> the box (pun intended) using `\definetextbackground` and drawing the 
> frame with MetaPost, using counters to keep track of whether the current 
> text is at the top, middle, or bottom of the box. However, I'm having 
> issues when one box ends and another starts on the same page (see more 
> details below). From what I understand, the issue is that counters seem 
> to be updated on a page-wide basis, so each MPgraphic ‘sees’ the values 
> of counters at the end of the current page, which may not be right if 
> another box modifies them. Would anyone know how to resolve this?
> 
> Based on two answer on TeX StackExchange 
> (https://tex.stackexchange.com/a/486124/123770 
> <https://tex.stackexchange.com/a/486124/123770> , 
> https://tex.stackexchange.com/questions/377234/context-frame-problems/377261#377261 <https://tex.stackexchange.com/questions/377234/context-frame-problems/377261#377261>), the following code works well if there is no more than one box per page:
> 
> ```

You're missing a feature:

this is the original trick:

if     multilocs[i] == 1 :  % begin
elseif multilocs[i] == 2 :  % between
elseif multilocs[i] == 3 :  % end
fi ;

and in lmtx we have

if      multikind[i] = "single" :
elseif  multikind[i] = "first"  :
elseif  multikind[i] = "middle" :
elseif  multikind[i] = "last"   :

Also:

      path p;
       p := ( llcorner multipars[i]
              -- lrcorner multipars[i]
              -- urcorner multipars[i]
              -- ulcorner multipars[i]
              -- cycle )
              enlarged (EmWidth,EmWidth) ;
       fill p withcolor boxfillcolor ;

can be

fill multipars[i] enlarged (EmWidth,EmWidth) ...

Hans


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------

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

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

  reply	other threads:[~2024-08-11 11:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-11  9:24 [NTG-context] " Florent Michel
2024-08-11 11:16 ` Hans Hagen via ntg-context [this message]
2024-08-11 12:35   ` [NTG-context] " Florent Michel

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=be6ee0c7-c1ef-45a7-815d-e9703a03b063@freedom.nl \
    --to=ntg-context@ntg.nl \
    --cc=j.hagen@freedom.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).