Difference between revisions of "T wo T r:twotr"

From LuaTeXWiki
(TeX without TeX Revised and expanded)
 
m (Rename some files so I could upload them.)
Line 146: Line 146:
 
The main text file to be typeset is:
 
The main text file to be typeset is:
  
[[T_wo_T_r:text.txt|text.txt]]
+
[[T_wo_T_r:text.tex|text.tex]]
  
 
It includes the following five files:
 
It includes the following five files:
  
[[T_wo_T_r:chapter-1.txt|chapter 1]]
+
[[T_wo_T_r:chapter-1.tex|chapter 1]]
  
[[T_wo_T_r:chapter-2.txt|chapter 2]]
+
[[T_wo_T_r:chapter-2.tex|chapter 2]]
  
[[T_wo_T_r:chapter-3.txt|chapter 3]]
+
[[T_wo_T_r:chapter-3.tex|chapter 3]]
  
[[T_wo_T_r:chapter-4.txt|chapter 4]]
+
[[T_wo_T_r:chapter-4.tex|chapter 4]]
  
[[T_wo_T_r:chapter-5.txt|chapter 5]]
+
[[T_wo_T_r:chapter-5.tex|chapter 5]]

Revision as of 19:20, 22 February 2021

About

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

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
 
  1. 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
 
  1. Now, build the format file.
 
 luatex --ini /usr/local/share/texmf-dist/tex/generic/context/luatex/luatex-plain.tex
 
  1. 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
 
  1. But, this is too restrictive.
 ## Create a new executable with the name luatex-plain. Something
 like:
   
   ln -s `which luatex` /usr/local/bin/luatex-plain
   
 ## 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

This files for this project are also available at: GitHub

There is a Read Eval Print Loop available for interactively 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.tex

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