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

From LuaTeXWiki
(Fix formatting)
(Really fix formatting?)
 
Line 26: Line 26:
 
did on my system:
 
did on my system:
  
# Find the luatex-plain.tex file. On my system (with TeX-Live 2020)
+
<ol>
 +
<li> Find the luatex-plain.tex file. On my system (with TeX-Live 2020)
 
it was at:
 
it was at:
  
  <pre>
+
<pre>
  /usr/local/share/texmf-dist/tex/generic/context/luatex/luatex-plain.tex
+
/usr/local/share/texmf-dist/tex/generic/context/luatex/luatex-plain.tex
  </pre>
+
</pre>
 +
</li>
  
# If you just build a format file,
+
<li> If you just build a format file,
  
  <pre>
+
<pre>
  luatex --ini /usr/local/share/texmf-dist/tex/generic/context/luatex/luatex-plain.tex
+
luatex --ini /usr/local/share/texmf-dist/tex/generic/context/luatex/luatex-plain.tex
  </pre>  
+
</pre>  
 
 
  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:
 
  
  <pre>
+
you will probably get warnings about using the "merged" file, and not
  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
+
the more current and supported files. Delete, move, or rename this
  </pre>
+
file. On my system I did:
  
# Now, build the format file.
+
<pre>
 +
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
 +
</pre>
 +
</li>
  
  <pre>
+
<li> Now, build the format file.
  luatex --ini /usr/local/share/texmf-dist/tex/generic/context/luatex/luatex-plain.tex
 
  </pre>
 
  
# We are almost done. If the resulting format file (luatex-plain.fmt)
+
<pre>
 +
luatex --ini /usr/local/share/texmf-dist/tex/generic/context/luatex/luatex-plain.tex
 +
</pre>
 +
</li>
 +
 
 +
<li> We are almost done. If the resulting format file (luatex-plain.fmt)
 
is in the current working directory, you can use it with something
 
is in the current working directory, you can use it with something
 
like:
 
like:
  
  <pre>
+
<pre>
  luatex --fmt luatex-plain test
+
luatex --fmt luatex-plain test
  </pre>
+
</pre>
 +
</li>
  
# But, this is too restrictive.
+
<li> But, this is too restrictive.
  
  ## Create a new executable with the name luatex-plain. Something
+
<ol>
  like:
+
<li> Create a new executable with the name luatex-plain. Something like:
  
    <pre>
+
<pre>
    ln -s `which luatex` /usr/local/bin/luatex-plain
+
ln -s `which luatex` /usr/local/bin/luatex-plain
    </pre>
+
</pre>
 +
</li>
  
  ## When you try to invoke it:
+
<li> When you try to invoke it:
  
    <pre>
+
<pre>
    luatex-plain test
+
luatex-plain test
    </pre>  
+
</pre>  
  
  it will fail with a message about failing to find the proper
+
it will fail with a message about failing to find the proper
  format file. There should be a line something like:
+
format file. There should be a line something like:
  
    <pre>
+
<pre>
    mktexfmt [INFO]: writing formats under ~/.texlive2020/texmf-var/web2c
+
mktexfmt [INFO]: writing formats under ~/.texlive2020/texmf-var/web2c
    </pre>  
+
</pre>  
  
  so, copy the format file to that location:
+
so, copy the format file to that location:
  
    <pre>
+
<pre>
    cp luatex-plain.fmt ~/.texlive2020/texmf-var/web2c/
+
cp luatex-plain.fmt ~/.texlive2020/texmf-var/web2c/
    </pre>  
+
</pre>  
  
  now, this should work:
+
now, this should work:
  
    <pre>
+
<pre>
    luatex-plain test
+
luatex-plain test
    </pre>  
+
</pre>  
  
    Finally, run mtxrun to generate a fonts database: <br />
+
Finally, run mtxrun to generate a fonts database: <br />
  
    <pre>
+
<pre>
    mtxrun --script fonts --reload --simple
+
mtxrun --script fonts --reload --simple
    </pre>
+
</pre>
 +
</li>
 +
</ol>
 +
</ol>
  
 
== Contents ==
 
== Contents ==
  
This files for this project are also available at:
+
The most recent files for this project are also available at:
 
[https://github.com/s-dismas/TeX-without-TeX-revised GitHub]
 
[https://github.com/s-dismas/TeX-without-TeX-revised GitHub]
  
There is a Read Eval Print Loop available for interactively exploring:
+
There is a Read Eval Print Loop available for interactive exploring:
  
 
[[T_wo_T_r:repl.lua|repl.lua]]
 
[[T_wo_T_r:repl.lua|repl.lua]]

Latest revision as of 00:35, 23 February 2021

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