Changes

Jump to navigation Jump to search
1,461 bytes added ,  15:05, 6 February 2021
m
expamples from the list
{{note|This article is about the data type. For the names of a page's many dimensions, see [[Layout]].}}
 
A dimension, in TeX, is a variable storing a length. The length is entered
as a number immediately followed by two letters that indicate the unit, e.g.
* 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
<context mode=mkiv source=yes>
\newdimen\AAA \AAA=100mm100pt
\newdimen\BBB \BBB=\AAA
! unit !! TeX name
! in sp !! in pt !! in pc !! in dd !! in cc
! in bp !! in in !! in cm mm !! in mmcm
|-
| scaled point || {{code|sp}}
* {{cmd|measure}}
[[Category:Programmingand Databases]][[Category:Tools]]
138

edits

Navigation menu