Custom background color for \framed inside lmt_text

I want my custom color rose_color to be applied for background color for \framed inside lmt_text. For fill fullcircle, it works. With predefined colors as green, it works. \starttext \startMPcode color rose_color; rose_color = 1/256(255,204,255); %not working draw lmt_text [text ="\framed[background=color,backgroundcolor=rose_color,frame=on, location=low]{a rose box}",]; %working draw lmt_text [text ="\framed[background=color,backgroundcolor=green,frame=on, location=low]{a green box}",] shifted (1cm,1cm); %working fill fullcircle scaled 2cm shifted (0,3cm) withcolor rose_color; \stopMPcode \stoptext

Does somebody has a solution for this? Thank you!
2025/06/30 12:39、Emanuel Han via ntg-context
のメール: I want my custom color rose_color to be applied for background color for \framed inside lmt_text. For fill fullcircle, it works. With predefined colors as green, it works.
\starttext
\startMPcode
color rose_color; rose_color = 1/256(255,204,255);
%not working draw lmt_text [text ="\framed[background=color,backgroundcolor=rose_color,frame=on, location=low]{a rose box}",];
%working draw lmt_text [text ="\framed[background=color,backgroundcolor=green,frame=on, location=low]{a green box}",] shifted (1cm,1cm);
%working fill fullcircle scaled 2cm shifted (0,3cm) withcolor rose_color;
\stopMPcode
\stoptext
___________________________________________________________________________________ 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 ___________________________________________________________________________________

Phone mode, but maybe you can
\defineframed[Emanuel]
(and add it's setups there) and then do
\startframed[Emanuel] ... \stopframed
in your lmt.. Untested.
/Mikael
Den ons 2 juli 2025 14:24Emanuel Han via ntg-context
Does somebody has a solution for this? Thank you!
2025/06/30 12:39、Emanuel Han via ntg-context
のメール:
I want my custom color rose_color to be applied for background color for \framed inside lmt_text. For fill fullcircle, it works. With predefined colors as green, it works.
\starttext
\startMPcode
color rose_color; rose_color = 1/256(255,204,255);
%not working draw lmt_text [text ="\framed[background=color,backgroundcolor=rose_color,frame=on, location=low]{a rose box}",];
%working draw lmt_text [text ="\framed[background=color,backgroundcolor=green,frame=on, location=low]{a green box}",] shifted (1cm,1cm);
%working fill fullcircle scaled 2cm shifted (0,3cm) withcolor rose_color;
\stopMPcode
\stoptext
___________________________________________________________________________________ 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
___________________________________________________________________________________
___________________________________________________________________________________ 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
___________________________________________________________________________________

Hi, In addition to Mikael's solution, defining the color using the ConTeXt function \definecolor seems to work: \starttext \definecolor[rose_color_ctx][r=.99609375,g=.796875,b=.99609375] \startMPcode color rose_color; rose_color = 1/256(255,204,255); %now working draw lmt_text [text ="\framed[background=color,backgroundcolor=rose_color_ctx,frame=on, location=low]{a rose box}",]; %working draw lmt_text [text ="\framed[background=color,backgroundcolor=green,frame=on, location=low]{a green box}",] shifted (1cm,1cm); %working fill fullcircle scaled 2cm shifted (0,3cm) withcolor rose_color; \stopMPcode \stoptext Cheers, Florent Le mer. 2 juil. 2025 à 13:25, Emanuel Han via ntg-context < ntg-context@ntg.nl> a écrit :
Does somebody has a solution for this? Thank you!
2025/06/30 12:39、Emanuel Han via ntg-context
のメール:
I want my custom color rose_color to be applied for background color for \framed inside lmt_text. For fill fullcircle, it works. With predefined colors as green, it works.
\starttext
\startMPcode
color rose_color; rose_color = 1/256(255,204,255);
%not working draw lmt_text [text ="\framed[background=color,backgroundcolor=rose_color,frame=on, location=low]{a rose box}",];
%working draw lmt_text [text ="\framed[background=color,backgroundcolor=green,frame=on, location=low]{a green box}",] shifted (1cm,1cm);
%working fill fullcircle scaled 2cm shifted (0,3cm) withcolor rose_color;
\stopMPcode
\stoptext
___________________________________________________________________________________ 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
___________________________________________________________________________________
___________________________________________________________________________________ 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
___________________________________________________________________________________

Am 02.07.2025 um 14:50 schrieb Florent Michel:
Hi,
In addition to Mikael's solution, defining the color using the ConTeXt function \definecolor seems to work:
\starttext
\definecolor[rose_color_ctx][r=.99609375,g=.796875,b=.99609375]
You can also use hex numbers. \definecolor [rose_color] [x=FFCCFF] \starttext \color[rose_color]{rose_color} \stoptext Wolfgang

Ah, indeed that's much more practical than computing the ratios explicitly! Thank you Wolfgang! On Wed, 2 Jul 2025, 18:50 Wolfgang Schuster, < wolfgang.schuster.lists@gmail.com> wrote:
Am 02.07.2025 um 14:50 schrieb Florent Michel:
Hi,
In addition to Mikael's solution, defining the color using the ConTeXt function \definecolor seems to work:
\starttext
\definecolor[rose_color_ctx][r=.99609375,g=.796875,b=.99609375]
You can also use hex numbers.
\definecolor [rose_color] [x=FFCCFF]
\starttext \color[rose_color]{rose_color} \stoptext
Wolfgang
___________________________________________________________________________________ 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
___________________________________________________________________________________

Thank you everybody for your help. On 3 Jul 2025, at 2:57, Florent Michel wrote:
Ah, indeed that's much more practical than computing the ratios explicitly! Thank you Wolfgang!
On Wed, 2 Jul 2025, 18:50 Wolfgang Schuster, < wolfgang.schuster.lists@gmail.com> wrote:
Am 02.07.2025 um 14:50 schrieb Florent Michel:
Hi,
In addition to Mikael's solution, defining the color using the ConTeXt function \definecolor seems to work:
\starttext
\definecolor[rose_color_ctx][r=.99609375,g=.796875,b=.99609375]
You can also use hex numbers.
\definecolor [rose_color] [x=FFCCFF]
\starttext \color[rose_color]{rose_color} \stoptext
Wolfgang
___________________________________________________________________________________ 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
___________________________________________________________________________________
___________________________________________________________________________________ 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 ___________________________________________________________________________________

Am 30.06.2025 um 05:32 schrieb Emanuel Han via ntg-context:
I want my custom color rose_color to be applied for background color for \framed inside lmt_text. For fill fullcircle, it works. With predefined colors as green, it works.
\starttext
\startMPcode
color rose_color; rose_color = 1/256(255,204,255);
%not working draw lmt_text [text ="\framed[background=color,backgroundcolor=rose_color,frame=on, location=low]{a rose box}",];
%working draw lmt_text [text ="\framed[background=color,backgroundcolor=green,frame=on, location=low] {a green box}",] shifted (1cm,1cm);
%working fill fullcircle scaled 2cm shifted (0,3cm) withcolor rose_color;
\stopMPcode
\stoptext
The color modes in TeX and MetaPost are separate systems and while you can't use MetaPost defined colors in TeX the reverse is possible, to use TeX defined color use \MPcolor{...} or "...". %%%% begin example \starttext \startMPcode draw fullcircle scaled 1cm withcolor red ; % MetaPost color draw fullcircle scaled 2cm withcolor \MPcolor{green} ; % TeX color draw fullcircle scaled 3cm withcolor "blue" ; % TeX color \stopMPcode \stoptext %%%% end example A new feature in LMTX is to create TeX based colors in MetaPost with the definecolor function but you can only use it within MetaPost. %%%% begin example \definecolor [my_red] [r=1] \definecolor [my_blue] [b=1] %\definecolor [my_blue] [c=1] % possible \starttext \startMPcode definecolor [ name = "my_green", g = 1 ] ; %definecolor [ name = "my_blue", g = 1 ] ; % not possible \stopMPcode my_red \doifelsecolor{my_red} {does}{doesn’t} exist.\par my_green \doifelsecolor{my_green}{does}{doesn’t} exist.\par my_blue \doifelsecolor{my_blue} {does}{doesn’t} exist.\par \startMPcode draw fullcircle scaled 1cm withcolor "my_red" ; draw fullcircle scaled 2cm withcolor "my_green" ; draw fullcircle scaled 3cm withcolor "my_blue" ; \stopMPcode \stoptext %%%% end example Wolfgang
participants (4)
-
Emanuel Han
-
Florent Michel
-
Mikael Sundqvist
-
Wolfgang Schuster