ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] Use headcommand in \definedescription together with \definehighlight
@ 2024-06-24 17:19 Gerion Entrup
  2024-06-24 19:20 ` [NTG-context] " Aditya Mahajan
  0 siblings, 1 reply; 9+ messages in thread
From: Gerion Entrup @ 2024-06-24 17:19 UTC (permalink / raw)
  To: ntg-context


[-- Attachment #1.1: Type: text/plain, Size: 1174 bytes --]

Hi,

I was in the process to convert an itemize part to a description and wanted to simplify the code in the same move.
I discovered headcommand for that, but struggled to set the text in an highlight _and_ make a colon at the end.
Do you know, if this is possible?

Here is a MWE:
```
\definehighlight[hl][style={\m{>}\,\switchtobodyfont[tt]}]

\definedescription[category][
	alternative=top,
	headstyle=bold,
	width=broad,
]

\definedescription[desc][
	width=broad,
	distance={\widthofstring{~}},
	headcommand={\groupedcommand{\hl}{:}},
	% headcommand={\groupedcommand{}{:}}, % this compiles but the highlight is lost
	% headcommand={\groupedcommand{\starthl}{\stophl :}}, % this does not compile
	headstyle=,
	before={\startpacked},
	after={\stoppacked},
	alternative=hanging,
]

\starttext

This is a \hl{highlight}.

Some listings

\startcategory{Itemize}
	\startitemize[packed]
		\item \hl{first}: one
		\item \hl{second}: two
	\stopitemize
\stopcategory

Now the same as desc:
\startcategory{Desc}
	\startdesc{first} one \stopdesc
	\startdesc{second} two \stopdesc
\stopcategory

\stoptext
```
The itemize looks like it should look (except of the dots).

Best,
Gerion

[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

[-- Attachment #2: Type: text/plain, Size: 511 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-07-01 18:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-24 17:19 [NTG-context] Use headcommand in \definedescription together with \definehighlight Gerion Entrup
2024-06-24 19:20 ` [NTG-context] " Aditya Mahajan
2024-06-24 21:57   ` Gerion Entrup
2024-06-24 22:09     ` Wolfgang Schuster
2024-06-25  6:41       ` [NTG-context] Re: Use headcommand in \definedescription together with \definehighlight (now: \definestartstop) Gerion Entrup
2024-06-27 20:19         ` Wolfgang Schuster
2024-06-28  9:40           ` Gerion Entrup
2024-06-28  9:59             ` Wolfgang Schuster
2024-07-01 18:11               ` Gerion Entrup

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).