Quick
index
main
eev
eepitch
maths
angg
blogme
dednat6
littlelangs
PURO
(C2,C3,C4,
 λ,ES,
 GA,MD,
 Caepro,
 textos,
 Chapa 1)

emacs
lua
(la)tex
maxima
git
lean4
agda
forth
squeak
icon
tcl
tikz
fvwm
debian
irc
contact

Show2.lua: a small library for showing LaTeXed LaTeX code

In 2022 I made two videos - here: Pict2e-lua and Eev-TikZ - about how I was using Lua and eepitch to create LaTeX diagrams incrementally using REPLs. Here are two screenshots:

They both use this 3-window setting,

.______________________
|          |           |
|          | [t]arget  |
|          |  buffer   |
|  [e]dit  |___________|
|          |           |
|          |  [v]iew   |
|          |  the PDF  |
|__________|___________|

in which at the left half there's the Lua program that I am editing, at the upper right there's a target buffer running a Lua REPL, and at the lower right there's a buffer viewing the resulting PDF. These are some commands with very short names that I use very often,

  • `M-x e' to go to the file that I am editing,
  • `M-x v' to view the current PDF with pdftools,
  • `M-x D' to view the current PDF in full-screen mode,

so it was natural to define a function called (etv) that would create that 3-window setting. I used it like this:

("a \\cdot b"):show()
* (etv)

Here the "a \\cdot b" is a very small chunk of LaTeX code. The line with the "show" does the first part of showing it as a PDF, and the (etv) does the rest: the :show() produces a PDF, and the (etv) creates a 3-window setting and displays the current version of the PDF in its lower left part. In short, what happens is this:

"a \\cdot b"
     |
     | :show()
     |
     v
/DIR/outer.pdf
     |
     v
 ___________
|     |     |
|     | [t] |
| [e] |_____|
|     |     |
|     | [v] |
|_____|_____|

We can expand it into the diagram below. Running ("a \\cdot b"):show() creates an object of the class Show, so let's start with

s = Show.new("a \\cdot b")

to store that object into a variable s. We have:

Show.bigstr =     "a \\cdot b"
                       |
                       | s:prep("d")
                       v
Show.bigstr =    "$a \\cdot b$"
                       |
                       | s:write()
                       v
s:innertex() =   /DIR/inner.tex
                       :
                       : /DIR/outer.tex contains this line:
                       :  \input inner.tex
                       v
s:outertex() =   /DIR/outer.tex
                       |
                       | s:compile() runs this:
     s:cmd() =         |  cd /DIR/ && lualatex outer.tex
                       v
s:outerpdf() =   /DIR/outer.pdf
                       |
                       | * (etv)
                       v
                   ___________
                  |     |     |
                  |     | [t] |
                  | [e] |_____|
                  |     |     |
                  |     | [v] |
                  |_____|_____|

(TODO: explain the rest; explain globals; explain code-etv2)

elpeg