Re: Decorative frame for enumeration

Jethro Djan <[email protected]> Mon, 15 Jun 2026 10:22:35 +0000
Newsgroups gmane.comp.tex.context
Message-ID <CAHgnkf-H=Qh35Y2Rjnt=uTUz96V6Q-5TQGi-kSGci7T_CCruDQ@mail.gmail.com>
Yes, this had the desired effect. For others who may want to do something
similar in the future:

\startuseMPgraphic{WEFrame}
    fill OverlayBox withcolor (.93, .96, 1.0) ;
    setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic

\startuseMPgraphic{WETitleFrame}
    fill OverlayBox withcolor (.2, .4, .75) ;
    setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic

\defineoverlay[WEFrame][\useMPgraphic{WEFrame}]
\defineoverlay[WETitleFrame][\useMPgraphic{WETitleFrame}]

\defineenumeration[WorkedEx]
\setupenumeration[WorkedEx][%
    alternative=top,
    text={Worked Example},
    inbetween={\blank[small]},
    before={\startframed[
        frame=off,
        background=WEFrame,
        rulethickness=0pt,
        align=normal,
        offset=overlay,
        loffset=8pt,
        boffset=4pt,
        width=broad,
    ]},
    after={\stopframed},
    headcommand=\WETitleCommand,
]

\define[1]\WETitleCommand{%
    \hskip-8pt
    \framed[frame=off,%
        width=broad,
        width=\dimexpr\textwidth-24.8pt\relax,%
        frame=off,%
        rulethickness=0pt,
        offset=4pt,%
        strut=no,
        background=WETitleFrame,%
        foregroundcolor=white,
        align=flushleft,%
    ]{#1}
}

\starttext

\startWorkedEx
Take the sequence
    \startformula
        2, 8, 14, 20, 26, \ldots
    \stopformula
\stopWorkedEx

\stoptext

My only minor nit would be a way to allow a framed box in another framed
box to ignore offset parameters of the parent framed box.

On Mon, Jun 15, 2026 at 7:36 AM Mikael Sundqvist <[email protected]> wrote:

> Hi,
>
>
> On Mon, 15 Jun 2026 at 09:21, Jethro Djan <[email protected]> wrote:
> >
> > Dear all,
> >
> > Thanks for all the help. Wolfgang’s solution didn’t help. Willi’s manual
> offset solution did the trick, although I was hoping for a solution that
> seems ‘less hacky’.
>
> You could also try (I did not)
>
> \startframed \stopframed instead of \startframedtext \stopframedtext.
> Maybe add align=normal. And maybe offset=overlay instead of
> offset=0pt.
>
> /Mikael
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to
> the Wiki!
>
> maillist : [email protected] /
> 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
>
> ___________________________________________________________________________________
>

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

maillist : [email protected] / 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
___________________________________________________________________________________