[Tex/LaTex] Learning Plain TeX via ConTeXt’s LuaTeX-plain Format


Succinctly as I can:

Want to learn Plain TeX (but with modern conveniences such as UTF-8, mplib, TiKz, etc.)

Have much respect for the ConTeXt group of people. Liked the idea, when I stumbled upon it, of a LuaTeX with OTF support & mplib, provided via their luatex-plain.fmt. Want to later use ConTeXt, so proceeded with installing ConTeXt and making the mentioned format.

Spreading wings, also installed TeX Live 2013 (MacTeX & Windows), and learned to use that version of plain LuaTeX (plain.fmt), together with luaotfload.sty and luamplib.sty.

Happy to proceed with either, but have problems:

  • TeXLive2013 LuaTeX plain: Cannot setup the math fonts (but did get it to work with ConTeXt's LuaTeX-plain with this). It finds personal files in $HOME/texmf.
  • ConTeXt LuaTeX-plain: Cannot get it to find non-system-installed fonts, or input files, in $HOME/texmf, or $TEXMF/tex/texmf-local, $TEXMF/tex/texmf-projects, or $TEXMF/tex/texmf-fonts, even though these directories are referenced in the config file at $TEXMF/tex/texmf/web2c/texmf.cnf, which I assumed filename resolving use. Must be missing something fundamental.

Which would be the easiest to fix? The math fonts in TL's LuaTeX plain, or resolving files and fonts in ConTeXt's LuaTeX-plain?

Before you jump to conclusions, these commands were run with every retry and moving of files (some of which may be redundant, but no way to know):

mtxrun --script base --generate 
luatools --generate 
context --generate
luatools --self-update
context --self-update
mtxrun --script fonts --update --force 
mtxrun --script fonts --udpate --simple

Furthermore, luatools --find-file and mtxrun --locate, find the files/fonts in question. kpsewhich/where only finds it if they are in $HOME/texmf. But using \input <filename>, or \font\x = name:xxxx, or \font\x = file:xxxx, does not work when running luatex --fmt luatex-plain <filename>.tex.

Any ideas? Tired / embarrassed spamming ConTeXt mailing list with fundamental newbie questions. Don't just want to hack it, also want to produce quality, albeit manually typeset, documents in the meantime, learning "from the ground up" in the process.

Best Answer

Part answer to my own question, from Aditya Mahajan on ConTeXt mailing list (verbatim, but with formatting and links):

Read about TDS (TeX Directory Structure).

You need to put files in $TEXMF/tex/plain/ subdirectory for Plain format to find it, or in $TEXMF/tex/generic/ subdirectory for all macro packages (plain, latex, context) to find it.

As experiment, placed eplain's source files in $HOME/texmf/tex/generic/eplain/. No other copies visible. For a file testdox.tex, containing \input eplain, the command

luatex --fmt luatex-plain testdoc.tex

does indeed find eplain.tex. Executed three of the “generate” commands:

context --generate
luatools --generate

And now all of the these command will find the file:

luatools --find-file eplain.tex
mtx-run --locate eplain.tex
kpsewhich eplain.tex

In addition, if others have problems with font locations in ConTeXt, for OTF fonts, using Alegreya* as an example, I

  1. created the directory: ''$HOME/texmf/fonts/opentype/huerta/alegreya'' and
  2. copied all the ''*.otf'' files there.
  3. By running the “generate” commands above,
  4. followed by the font update commands below,

\font\x = <font> also now works without having to install the fonts in the operating system.

mtxrun --script fonts --update --force
mtxrun --script fonts --update --simple --force

Edit: Path issues solved. Works on Windows as well, just ensure you're happy with the setting of %TEXMFHOME%, which you can set with a batch file, or permanently in %TEXMF%\tex\texmf\web2c\texmf.cnf). I run this ctxenv.cmd file from a Cmd Prompt console before starting to work with ConTeXt's LuaTeX:

@echo off
:: Sets ConTeXt environment for running ConTeXt tools.
:: NB: This includes setting TEXMFHOME and calling
::     .\tex\setuptex.bat. It also add the ''.\utl''
::     directory to your PATH. This file must live in
::     your ConTeXt base directory. It will set %CTX%
::     for convenience.
set CTX=%~dp0
set CTX=%CTX:~0,-1%
set PATH=%CTX%\utl;%CTX%\bin;%PATH%
set TEXMFHOME=%CTX%\local
:: optional: remove the colons in front of these commands:
::context --generate
::luatools --generate

As for the TL math fonts setting problem, I'll rephrase as a new question.

*Alegrya: http://www.ctan.org/tex-archive/fonts/alegreya/

Related Question