Changes

Jump to navigation Jump to search
2,790 bytes added ,  13:41, 10 July 2008
no edit summary
== Introduction ==
Context [[Mark IV]] does not use the kpathsea library to find files and configuration settings. It follows that running [[mktexlsr]] or [[fmtutil]] has no effect. This page explains the details of installing setting up and maintaining [[Mark IV]].
The most important motivation for this page is that the [[TeX Live]] 2008 edition contains Mark IV, but it is only copied to the installed system, no post-install setup takes place at all. This year, the post-install setup has to be done manually.
== Quickstart ==
 
Just for the extremely impatient user that knows how to deal with a web2c-based TeX distribution and has a simple, private (single-user) installation, this is the only absolutely required extra knowledge:
luatools --generate
is the Mark IV replacement for [[mktexlsr]].
context --make
is the Mark IV replacement for [[fmtutil]].  context myfile.tex typesets a file. Everybody else should read on.
When you run
context myfile.tex
both the script 'context' and the Mark IV code inside the actual format file have to find various files. To make this happen as fast as possible, a file name database is used. There is also some configuration information needed and some generated font data is to be cached because extracting the OpenType information is a relatively lengthy and memory-consuming process.
All of this data stored inside the 'texmf cache'. To keep this cache up -to -date, you have to (re)run
luatools --generate
whenever you install or remove files from your tex installation that have to be found by Mark IV, like or when you make changes to a the configuration values. Examples of moments when you need to rerun luatools are * after updating the context itself, or package* after adjusting settings in any of the texmf.cnf files* after installing extra font packages from [[TeX Live]] or [[CTAN]]* after adding or removing third-party context modules. System-wide  Mark IV can also use the operating system's installed fonts when it is set up properly, but for fonts doninstalled or removed using the operating system't counts installation method you do need to rerun luatools, these such fonts are always re-discovered at runtimehandled by their own subsystem (which will be explained below). {{todo| check that}}
=== Cache location ===
When
luatools --generate
is runfor the first time, it creates the file name database. To prevent duplication of settings as much as possible, it parses [[texmf.cnf]] as the source for discovering at what directory trees need to be indexed in the database. This ensures that while Mark IV does not actually use kpathsea, it is still compatible with how kpathsea handles thingslater runs do updates.
To prevent unnecessary duplication of settings, luatools parses [[texmf.cnf]] as the source for discovering configuration values and which directory trees need to be indexed. This also ensures that even though Mark IV does not use kpathsea, it is still runtime-compatible with how kpathsea handles things. But there is a catch: luatools has to decide where on the harddisk the file name database should be stored(or updated). This needs extra care, because a runtime command like 'context myfile.tex' does not look at texmf.cnfat all. Therefore, the cache location is handled separately from all other configuration settings.
The internal logic used for finding the cache location is as follows:
* If there is an environment variable named TEXMFCACHE, this will point to the desired harddisk location
* Otherwise, if the web2c configuration directory contains a file named reading texmfcnf.luaresults in the variable TEXMFCACHE being set, this file is read and used to discover the desired location. '''this is the recommended approach, see below'''* If that doesn't work either, a list of 'likely' environment variables is tested, and the first environment variable that is set is assumed to point to the correct location.
* As a last resort, the local directory is used.
For completeness: the list of tested environment variables is currently: TMPDIR, TEMPDIR, TMP,
TEMP, HOME, HOMEPATH, but there have been quite some variations on this in the past.
For completeness: the list of tested environment variables is currently:=== texmfcnf.lua ===
TMPDIRFiles with the name texmfcnf.lua can appear anywhere on the search path where there can also be a [[texmf.cnf]] file, TEMPDIR, TMP, TEMP, HOME, HOMEPATHand multiple texmfcnf.lua files can be present.
but there have been quite some variations on this All possible locations are tried in order, and any found texmfcnf.lua files are read in order of discovery. All texmfcnf.lua files are read before all texmf.cnf files, and none of the pastvalues defined in texmfcnf.lua file(s) cannot be overruled by texmf.cnf files.
=== The format of texmfcnf.lua ===is pretty simple: it is a Lua script that has to return a single table with keys for the variables it wants to define. If there are multiple files with duplicate keys, the first appearance of a particular key 'wins' (this is the same behaviour as for [[texmf.cnf]] variables).
Files named texmfcnf.lua can appear anywhere on could be used to set up the search path where there can also be a [['normal' texmf.cnf]] present. Multiple files can be present. They are read sequentially using variables, but by far the same logic as for [[texmfmost important key is TEXMFCACHE.ncf]]: earlier files fix values that cannot be overruled by later ones. All Here is a simple one-line example texmfcnf.lua files are read before all to set up the texmf.cnf files, and values defined in texmfcnf.lua cannot cache to be overruled by texmf.cnf files.inside your private texlive 2008 directory:
The format of texmfcnf.lua is pretty simple: it is a Lua script that has to return a single table with keys for the variables it wants to define. Mark IV will interpret specific keys in the table and do something special (unknown keys are ignored){ TEXMFCACHE = '$HOME/. texlive2008/texmf-var' }
Besides the 'normal' texmfNote: Windows users should replace $HOME with $USERPROFILE.cnf keys[[TeX Live]] 2008 users and users of Mark IV versions from after Jul 10, the most important key is TEXMFCACHE. Here is 2008 can use a simple one-line example texmfcnftilde (~) instead of an explicit environment variable.lua to set up the texmf cache to be inside your private texlive 2008 directory:
return { TEXMFCACHE = '$HOME/.texlive2008/texmf-var' }
 
Note: Windows users should replace $HOME with $USERPROFILE. Both unix and windows users of [[TeX Live]] 2008 and users of Mark IV beta's released after Jul 10, 2008 can use ~ instead.
== Generating and updating formats ==
Nowadays, you only have to do the reload manually when you have installed updates to already installed fonts that cause the font and/or file names to change. This normally only happens for fonts that are still in development like [[TeX Gyre]] and [[Latin Modern]].
 
== Downloaded files ==
 
If you have the program 'curl' installed, then your input file can contain e.g.
 
\externalfigure
[h t t p://www.pragma-ade.com/show-gra.pdf]
 
and the referenced file will be downloaded automatically and placed in the 'texmf cache' if is not found in the cache already. (the code example has extra spaces because the wiki parser interferes)
 
== Cache internals ==
 
(this paragraph is for developers and power-users only)
 
If you look at the folder that TEXMFCACHE points to, you will see a folder named luatex-cache. Inside that, there is the folder context. Inside the context folder, there usually is a single subfolder with a hexadecimal name. This is the md5sum of the name of the 'tex root' folder (aka SELFAUTOPARENT). Below this, there are currently four folders:
 
* '''curl''' contains downloaded files. The url is converted to something that can be represented on disk by replacing problematic characters by dashes
* '''fonts''' contains the file data/names.tma, this is the 'font name database' (and the derived names.tmc, tmc files are byte-compiled lua code for faster loading). There are also subdirectories containing the preprocessed metrics for non-tex fonts, one folder for each font type.
* '''formats''' contains the Mark iV format file
* '''trees''' has a small set of files with hexadecimal names, one for each of the top-level constituents of TEXMF (containing the filename database for that tree), and one for each of the found texmf.cnf files (containing in preprocessed form all the variables defined by that file).
The filenames are md5sums of the contained directory or filename.

Navigation menu