Hi all,
I would like to place a coloured background around some text that may
potentially be broken across multiple lines, and I would like for this
background to have rounded corners. I tried using "textbackground"s with
"location=text" and "corner=round", but this doesn't give the results
that I would expect when the highlighted text is shorter than a single
line.
With "backgroundoffset=0pt", the bottom-left corner of the first line
and the top-right corner aren't properly rounded; with
"backgroundoffset!=0pt", the two separate backgrounds are connected
between the lines of the unhighlighted text.
I'm using the latest version (2026.01.08 23:30), and I get the same
results with MkIV and LMTX. Demonstration:
%% Define the text background
\definecolor[transparent][s=1, t=0, a=1]
\definetextbackground[bg][
location=text,
backgroundoffset=0.5ex, %% Optional
corner=round,
radius=1.8ex,
%% "corner=round" doesn't work with "frame=off", so use an
%% invisible frame instead
rulethickness=1sp,
framecolor=transparent,
]
\define[1]\bg{\starttextbackground[bg]#1\stoptextbackground}
%% Demonstration
\define[1]\filler{\dorecurse{#1}{ filler }}
\setuppapersize[A8, landscape]
\setupheadertexts[]
\setupwhitespace[big]
\starttext
\filler{1} \bg{Looks okay} \filler{2}
\filler{2} \bg{Looks \filler{5} okay} \filler{1}
\filler{3} \bg{Looks \filler{2} bad} \filler{3}
\stoptext
Is there a different mechanism that I can use to avoid this?
Thanks,
-- Max
___________________________________________________________________________________
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
___________________________________________________________________________________