Hi Hraban,
On Tue, 2025-11-25 at 18:09 +0100, Henning Hraban Ramm wrote:
> \define[2]\Conv{\scratchdimen #1 \the\nodimen #2 \scratchdimen}
> I tried to use \unit within the definition above or like
> \unit{\Conv{1dk}{mm}}, but the result is empty – probably an expansion
> problem?
> \define[2]\Conv{\unit{\dimexpr\scratchdimen #1 \the\nodimen #2
> \scratchdimen\relax}}
1. Setting a dimension isn't expandable, so you need to do that before
using \unit.
2. You need to make sure that the argument to \unit is expanded before
\unit itself is.
The following should work as expected:
\mainlanguage[de]
\setupunit[method=3,space=small,]
\define[2]\Conv{%
\scratchdimen=#1
\normalexpanded{\noexpand\unit{\the\nodimen #2 \scratchdimen}}
}
\starttext
\bTABLE
\bTR\bTH Einheit \eTH\bTH mm \eTH\bTH pt \eTH\eTR
\bTR\bTD 1 dk \eTD\bTD \Conv{1dk}{mm} \eTD\bTD \Conv{1dk}{pt} \eTD\eTR
\bTR\bTD 1 es \eTD\bTD \Conv{1es}{mm} \eTD\bTD \Conv{1es}{pt} \eTD\eTR
\bTR\bTD 1 ts \eTD\bTD \Conv{1ts}{mm} \eTD\bTD \Conv{1ts}{pt} \eTD\eTR
\eTABLE
\stoptext
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
___________________________________________________________________________________