Changes

Jump to navigation Jump to search
1,315 bytes added ,  15:05, 6 February 2021
m
expamples from the list
* didot ('''dd''') and cicero ('''cc'''). The didot is a continental counterpart of the point; 12 didot = 1 cicero.
* big points ('''bp'''), defined by Adobe as 1/72 of an inch.
* millimeters ('''mm'''), centimeters ('''cm'''), and, unavoidably, inches ('''in''').
The various conversions between the units are laid out in the [[#Conversion table|conversion table]] at the end of this article.
\blackrule[width=\columnA]
</context>
 
== Defining and accesing dimensions in Lua ==
 
How to rewrite TeX code
 
<texcode>
\the\dimexpr\availablehsize\relax %say, 426pt
</texcode>
 
Mostly LMTX:
 
<context mode="mkxl" source="yes">
 
1: \number\dimexpr\availablehsize\relax
 
2: \startluacode
 
token.set_macro(tex.ctxcatcodes,"temp","\\scratchdimen\\availablehsize")
token.expand_macro("temp")
context(tex.getdimen("scratchdimen"))
\stopluacode
 
3: \startluacode
 
token.set_macro(tex.ctxcatcodes,"temp","\\scratchdimen\\availablehsize")
tex.runlocal("temp")
context(tex.getdimen("scratchdimen"))
\stopluacode
 
4: \startluacode
tex.print("\\scratchdimen\\availablehsize")
tex.pushlocal()
tex.poplocal()
context(tex.getdimen("scratchdimen"))
\stopluacode
 
5: \startluacode
tex.print("\\dimensiondef\\temp\\availablehsize")
tex.pushlocal()
tex.poplocal()
context(tex.getdimensionvalue("temp"))
\stopluacode
 
\def\calculateavailablehsize{\dimensiondef\temp\availablehsize}
 
6: \startluacode
token.expand_macro("calculateavailablehsize")
context(tex.getdimensionvalue("temp"))
\stopluacode
 
\newtoks\tcalculateavailablehsize
\tcalculateavailablehsize{\dimensiondef\temp\availablehsize}
 
7: \startluacode -- mkiv
tex.runtoks("tcalculateavailablehsize")
context(tex.getdimensionvalue("temp"))
\stopluacode
</context>
* If you want to calculate, the conversion factors from standard points are stored in {{code|number.dimenfactors}}. For example, {{code|65536 * number.dimenfactors["pt"]}} returns {{code|1}}.
<context source=yes mode=mkiv>
\newdimen\columnA % initialise variable
\columnA=10mm % set variable
[[Category:Programming and Databases]]
[[Category:Dimensions|!Tools]]
138

edits

Navigation menu