TeX without TeX revised and expanded

From LuaTeXWiki

About[edit]

This is an update and expansion of TeX without TeX --- using TeX's functionality (typesetting, pdf writing) using only Lua code (no \TeX macros).

It is (I believe) an adequate framework for developing a complete type-setting system; although one dedicated to a specific task, rather than a general purpose system such as LaTeX or ConTeXt. It includes a couple of example formatting commands (\Emph and \Bold), titles (\Title), the ability to include other subsidiary text files (\Input) and footnotes (\Footnote). It can be easily adapted and expanded to suit your needs.

I am not much of a programmer, and knew little about TeX and even less about Lua when I started this, so there is undoubtedly much that can be improved. All questions, comments, suggestions, and corrections will be appreciated. You can reach me at "destiny6 <AT> mac <DOT> com".

Pre-requisites[edit]

This system requires the luatex-plain format (from ConTeXt), so that we have access to Open Type Fonts and other goodies. This is what I did on my system:

  1. Find the luatex-plain.tex file. On my system (with TeX-Live 2020) it was at:
    /usr/local/share/texmf-dist/tex/generic/context/luatex/luatex-plain.tex
    
  2. If you just build a format file,
    luatex --ini /usr/local/share/texmf-dist/tex/generic/context/luatex/luatex-plain.tex
    

    you will probably get warnings about using the "merged" file, and not the more current and supported files. Delete, move, or rename this file. On my system I did:

    doas mv /usr/local/share/texmf-dist/tex/generic/context/luatex/luatex-fonts-merged.lua /usr/local/share/texmf-dist/tex/generic/context/luatex/luatex-fonts-merged.lua.bak
    
  3. Now, build the format file.
    luatex --ini /usr/local/share/texmf-dist/tex/generic/context/luatex/luatex-plain.tex
    
  4. We are almost done. If the resulting format file (luatex-plain.fmt) is in the current working directory, you can use it with something like:
    luatex --fmt luatex-plain test
    
  5. But, this is too restrictive.
    1. Create a new executable with the name luatex-plain. Something like:
      ln -s `which luatex` /usr/local/bin/luatex-plain
      
    2. When you try to invoke it:
      luatex-plain test
      

      it will fail with a message about failing to find the proper format file. There should be a line something like:

      mktexfmt [INFO]: writing formats under ~/.texlive2020/texmf-var/web2c
      

      so, copy the format file to that location:

      cp luatex-plain.fmt ~/.texlive2020/texmf-var/web2c/
      

      now, this should work:

      luatex-plain test
      

      Finally, run mtxrun to generate a fonts database:

      mtxrun --script fonts --reload --simple
      

Contents[edit]

The most recent files for this project are also available at: GitHub

There is a Read Eval Print Loop available for interactive exploring:

repl.lua

It can be invoked with repl.repl(), and either quit() or exit will exit it. I use Shell Mode in Emacs, but a simple terminal or similar should also work.

Some utilites are in the file:

utils.lua

The following five files comprise the system:

reader.lua

format.lua

main.lua

pages.lua

commands.lua

The license for this software can be seen at:

License.

The TeX file to be compiled by luatex-plain is:

test.tex

The Lua file executed by \directlua{dofile "test.lua"} within test.tex is:

test.lua

The main text file to be typeset is:

text.tex

It includes the following five files:

chapter 1

chapter 2

chapter 3

chapter 4

chapter 5