I made tables of unit conversions to explain ConTeXt’s units.

Conversion works like this:

\define[2]\Conv{\scratchdimen #1 \the\nodimen #2 \scratchdimen}

\Conv{1dk}{mm}

That gives me "2.263348mm", while I’d like "2,263348 mm".

I tried to use \unit within the definition above or like \unit{\Conv{1dk}{mm}}, but the result is empty – probably an expansion problem?

Complete not-working example:

"""
\mainlanguage[de]
\setupunit[method=3,space=small,]
\define[2]\Conv{\unit{\dimexpr\scratchdimen #1 \the\nodimen #2 \scratchdimen\relax}}

\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
"""

(Yes, I should have used a loop…)

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

Reply via email to