Changes
Jump to navigation
Jump to search
← Older edit
Dimensions
(view source)
Revision as of 15:05, 6 February 2021
1,437 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
! unit !! TeX name
! in sp !! in pt !! in pc !! in dd !! in cc
! in bp !! in in !! in
cm
mm
!! in
mm
cm
|-
| scaled point || {{code|sp}}
* {{cmd|measure}}
[[Category:Programming
and Databases
]][[Category:
Dimensions
Tools
]]
Jano Kula
138
edits
Navigation menu
Personal tools
Create account
Log in
Namespaces
Page
Discussion
Variants
Views
Read
View source
View history
More
Search
Main
Main Page
Download and Install
Documentation
Mailing lists
Web resources
3rd party modules
Navigation
Basics
Bibliography
Color
Development
Fonts
Graphics
Interaction
Languages
Layout
Programming & DB
Sciences
Tables
Text Editors
Tools
XML
Indexes
ConTeXt commands
ConTeXt categories
Interaction
Recent changes
Random page
About this wiki
Help wiki editing
Source browser
ConTeXt Online
FAQ
Tools
Special pages
Printable version