Changes

Jump to navigation Jump to search
892 bytes added ,  18:47, 25 August 2022
CLD ('''ConTeXt Lua Documents''' (CLD) are way to access TeX from inside Lua scripts; they provide means to typeset documents using little to no TeX code at all.
This makes them especially helpful for automated content generation and scripting.
Internally, the Lua commands are mapped onto their ConTeXt and TeX counterparts.
If you ever dreamed of proper typesetting without backslashes galore, here is where to start at.
== Basic reading ==* [http://www.pragma-ade.comnl/general/manuals/cld-mkiv.pdf The CLD manual] by Hans Hagen.* [[source:mult{{src|cldf-cldini.lua| The source code}}: the entry point for the '''cldf-*''' files that contain the CLD implementation.]]
== An Example ==
Writing CLDs is straightforward although there are some pitfalls.
Suppose we want to typeset the following minimal example:
Mandatory (grouped) arguments are given either as strings or as functions.
=== Nesting 1: Functions ===
The following example shows two ways of rewriting the above TeX code: the first one closely resembles its structure while the second calls the function <code>test</code> from inside the <code>placefigure</code> macro.
</pre>
=== Nesting 2: Delayed ===
An alternative to the function encapsulation is provided by
</pre>
= Setting up Header Texts =
[[CategoryAs already shown in the section about Nesting 1:Functions also context.setupheadertexts needs to be called with functions. On top of this we need to know, that once context.setupheadertexts is executed it is not frozen. This makes it necessary, that we need to add "return true" inside each used function() call. This makes sure that the called function stays around until the run is finished. A complete setup of header texts in a double-sided ConTeXt Lua]]Document could look then like this <pre>context.setupheadertexts( {function() context.getmarking({"chapter"}) return true end }, {function() context.pagenumber() return true end }, {function() context.getmarking({"section"}) return true end }, {function() context.pagenumber() return true end })</pre> [[Category:LuaTeX]][[Category:Programmingand Databases]]
48

edits

Navigation menu