Dont ask what you can do for LuaTeX, but what LuaTeX can do for you. - - PowerPoint PPT Presentation

don t ask what you can do for luatex but what luatex can
SMART_READER_LITE
LIVE PREVIEW

Dont ask what you can do for LuaTeX, but what LuaTeX can do for you. - - PowerPoint PPT Presentation

Dont ask what you can do for LuaTeX, but what LuaTeX can do for you. Patrick Gundlach 2009-09-03 EuroTeX 2009 Den Haag Goal: create a typesetting system (not related to ConTeXt, LaTeX or similar) But... Problem #1 I dont like TeX...


slide-1
SLIDE 1

Don‘t ask what you can do for LuaTeX, but what LuaTeX can do for you. Patrick Gundlach 2009-09-03 EuroTeX 2009 Den Haag

slide-2
SLIDE 2

Goal: create a typesetting system

(not related to ConTeXt, LaTeX or similar)

But...

slide-3
SLIDE 3

I don’t like TeX...

Problem #1

slide-4
SLIDE 4

I don’t like TeX...the language

but I want to use TeX for typesetting

Problem #1

slide-5
SLIDE 5

98% Lua 2% TeX

But...

slide-6
SLIDE 6

Example #1: Control flow \directlua{...} vs. directtex("...")

slide-7
SLIDE 7

ere is \directlua, but no directtex()

is is what you do in LuaTeX traditionally:

  • \lots\of\texcode\dontrelax{...}

\directlua{calculate.this()} \now\back\to\TeX

I would like to do it the opposite way

slide-8
SLIDE 8

ere is \directlua, but no directtex()

\directlua{ ... tex.sprint("\\setbox\\mybox\\vbox{whatever}") tex.wd["mybox"] ... }

slide-9
SLIDE 9

directtex()

\newbox\mybox \newif\ifcontinue\continuetrue \directlua{ directtex = coroutine.yield function main_loop()

  • - lots of lua code

directtex("\\setbox\\mybox\\vbox{whatever}") ret = tex.wd.mybox / 2^16

  • - more lua code
  • - at the end:

directtex("\\continuefalse") end co = coroutine.create(main_loop) } \loop \directlua{

  • k,str=coroutine.resume(co)

tex.sprint(str ) }\ifcontinue \repeat \bye

slide-10
SLIDE 10

So many files in the TeX tree (lot of i/o, error prone, ugly, ...)

Problem #2

slide-11
SLIDE 11

Example #2: Kpathsea Library

  • not needed most of the time
  • confusing (texmf.cnf)
  • not flexible (texhash, zip files)
slide-12
SLIDE 12

Example #2: Kpathsea Library

texconfig.kpse_init=false kpse = {} filelist = { -- created on startup "a.font"="/location/a.font" , "b.tex" = "/yet/another/location/b.tex", ... } function kpse.find_file(filename,what) return filelist[filename] or filelist[filename .. ".tex"] end callback.register('find_read_file', function(id_number,asked_name) return kpse.find_file(asked_name) end ) ... more callbacks ... more read_..._file handlers (bug in LuaTeX?)

luatex --lua myinit.lua myfile.tex

slide-13
SLIDE 13

Example #3: Hyphenation patterns

l=lang.new() ; l:patterns(" .a6 .ab3b .aben2 .ab5l .abo4 .ab3ol .ab1or ... zzi3s2 z3zo zzoll2")

  • - l:id is now the language id

You can have all patterns in one (.lua) file

slide-14
SLIDE 14

more examples:

  • XML parsing with LPEG
  • font families with Lua

But...

slide-15
SLIDE 15

Some problems remain

  • not everything can be done

inside lua (\vbox, \font)

  • see discussions about embed /

extend and Luigi’s “lunatic”

  • is the license of LuaTeX

problematic?

  • more control needed:

pdf.setpos(x,y)

slide-16
SLIDE 16

Example #4: PDF Layers

\directlua{ view = pdf.immediateobj("<< /Type/OCG /Name (View) >>") .. " 0 R " print = pdf.immediateobj("<< /Type/OCG /Name (Print) >>") .. " 0 R "

  • rder = pdf.immediateobj(" [ " .. view .. print .. "] ")
  • n = pdf.immediateobj(" [ " .. view .. "] ")
  • ff = pdf.immediateobj(" [ " .. print .. "] ")
  • cgs = pdf.immediateobj(" [ " .. view .. print .. "] ")

} \pdfcatalog{ /OCProperties << /OCGs \directlua{tex.sprint(ocgs)} /D<< /Order \directlua{tex.sprint(order)} /OFF \directlua{tex.sprint(off)} /ON \directlua{tex.sprint(on)} >> >> } \edef\x{\pdfpageresources{ /Properties << /OCView \directlua{tex.sprint(view)} /OCPrint \directlua{tex.sprint(print)} >> } } \x \pdfliteral page {/OC/OCPrint BDC} hello \pdfliteral page {EMC/OC/OCView BDC} nice \pdfliteral {EMC} world \bye

slide-17
SLIDE 17

Conclusion

  • You can use Lua as the main

language

  • TeX can be used as a library to

some extend

  • Some limitations that will be

resolved

  • A few unanswered questions
  • LuaTeX is really great!
slide-18
SLIDE 18

Don’t ask what you can do for LuaTeX, but what LuaTeX can do for you. ank you for listening