# 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):

``````mktexlsr
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.

• Do you have multiple TeX installations on the same machine? I'm confused about what you've installed exactly. I understand about TeX Live. It is the other I'm not sure about. Also I'm not terribly clear what you mean about plain TeX with 'modern conveniences'. As far as I understand, all of these engines are making use of plain TeX but usually when people talk about using plain TeX they have in mind using it precisely without the higher level stuff provided by LaTeX or ConTeXt or whatever. – cfr May 16 '14 at 1:16
• @cfr: Installing the Context distribution alongside Texlive is a common setup and usually works flawlessly. – Philipp Gesang May 16 '14 at 4:36
• They are separate and distinct. Each have their own TEXMF tree. Depending what which one is active, `which luatex` will return either `/usr/texbin/luatex` or `/Users/xxx/ctx/tex/texmf-osx-64/bin/luatex`. No interference. I consider PDF, Unicode, PCs, RAM, GUIs, IDEs, XML "modern" conveniences since they did not exist during TeXbook's time in the abundance of today. – Aíre May 16 '14 at 4:44
• @phg OK. Thanks. I was vaguely aware of ConTeXt's distribution. However, it wasn't clear from the question what was meant since if that distribution is installed, it is obviously installing more than just ConTeXt i.e. it is installing a TeX distribution, basically, which is set up specifically for ConTeXt. This may be able to coexist peacefully with TL but there are still complications here. For example, the OP is using `mktexlsr` to update the database after making changes to, I think, the ConTeXt distribution. So is that distribution getting priority in terms of `PATH`? Which `context` etc.? – cfr May 16 '14 at 14:27
• Related: tex.stackexchange.com/questions/105869/… and you might be interested in: tex.stackexchange.com/questions/163852/… – morbusg May 16 '14 at 19:46

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

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:

``````mktexlsr
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
.\tex\setuptex.bat
:: optional: remove the colons in front of these commands:
::mktexlsr
::context --generate
::luatools --generate
``````

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

• please make sure that you're logged in when you make edits. It makes it easier to track what's going on. `:)` – Paul Gessler May 16 '14 at 20:13
• Yeah, different computer, did not notice -- surprised afterwards that the system effectively lets an anonymous person edit an answer!?. Do understand though, and will be more careful next time. – Aíre May 16 '14 at 21:16