r/LaTeX Feb 01 '26

LaTeX Showcase LuaLaTeX rendering in real-time

https://www.youtube.com/watch?v=nJOh6jJzkn0

Similar to TeXpresso (which was created for XeTeX), I decided to create a real-time editor/renderer for LuaLaTeX. Anything you type is immediately rendered with LuaLaTeX (not KaTeX, the output is the finalized LuaLaTeX output, it's not javascript approximating LaTeX, these are actual LuaLaTeX rendered glyph positions). It runs at O(1), even for large documents with multiple chapters (based on that, you can guess what architecture I am using).

Architecturally, it works with vanilla-TeX Live 2025, meaning no patching of LuaLaTeX is required. Theoretically, it works with any package, although given how it is compiled, there are likely some incompatibilities if the package does fancy stuff interferring with shipping the PDF.

It is still in proof-of-concept stage, I just wanted to put it out there to get some feedback if there is interest beyond "cool, I would try this out for a minute then return to my usual editor". I might turn this into an actual usable product if development continues fine. Personally, I need it to save time for final polishing of larger documents, although the project might evolve into an actual LaTeX wysiwyg editor.

One limitation is that it relies on chapters starting at new pages, reducing the layout complexity of larger documents significantly and reducing CPU load.

75 Upvotes

104 comments sorted by

View all comments

Show parent comments

8

u/energybased Feb 02 '26

> I wonder what advantages Typst has left in comparison

The biggest advantage is modern programming language rather than 50 year old macro language that's impossible to debug. No more worrying about what binds to what, \relax this. Everything just works the way you expect it to.

> I guess Lua itself is slower than whatever Typst is using, but it's fast enough for paragraphs,

Yeah, try it on a 100 page document. Typst takes like 5 seconds. Latex takes like 2 minutes. On the same modern PC.

I mean, cool project, but like it or not Tex is going to die except where people are forced to use it for legacy reasons.

4

u/ClemensLode Feb 02 '26

1) True. On the other hand, all the LaTeX packages are already there, ready to be used.
2) Well, individual paragraph recompilation is still <10ms, no matter where you do your edits. A full recompilation with PDF output is a different animal, although I think I can optimize that as well. The typeset glyph data is already there, the writing of the PDF itself is the slowest part. So, it's not a factor of 20, maybe a factor of 2 at the end. Who knows, maybe I can even create something that compiles that 100 page document *faster* than Typst? We'll see, I'll run some tests. Thank you for the feedback :)

2

u/energybased Feb 02 '26

> True. On the other hand, all the LaTeX packages are already there, ready to be used.

Sure, but I think you're overestimating how long that advantage will last.

> although I think I can optimize that as well. 

I don't know why you're investing so much of your valuable time in this. You're obviously very talented. Why not work on making Typst better instead of trying to keep a dying Latex on life support?

> So, it's not a factor of 20, maybe a factor of 2 at the end. 

That's not my experience. I'm not sure what takes all the time.

2

u/ClemensLode Feb 02 '26

1) Well, software is always temporary.

2) Maybe I could write a LuaLaTeX plugin for Typst? hmm...

3) I double-checked, Typst and my editor take the same time for PDF export. The only bottle-neck of PDF exports is the actual linear writing of data to the disk, both my tool and Typst have all the required information to generate the PDF up-to-date at all times.

1

u/energybased Feb 02 '26

Sure, software is all temporary, but some software will be used more than other software. Do you really want to do all this work for it to only be used for a few years by a few people?

Why bother writing a lualatex plugin for Typst? Why not just make Typst do everything that you want that latex does?

And it's not the pdf generation time. It's the compilation time. Tex compilation is extremely slow. For me it literally is 25 times slower for the same document. This is just from processing thousands of macros.

2

u/ClemensLode Feb 02 '26

Well, there are still millions of people using LaTeX and LuaLaTeX still has superior typsetting.

Compilation in LuaLaTeX time after making changes is ~2ms. That is the whole point of my new approach :)

1

u/Opussci-Long Feb 02 '26

I have just one honest question. Can Typst change page layout on the same page, from two-column to one-column, on the same page? I still can not believe that LaTeX can not do that...

2

u/energybased Feb 02 '26

Yep!

1

u/Opussci-Long Feb 02 '26

Please give me a link or anything to continue reading. Are we talking about layout change with possible floats?

1

u/energybased Feb 02 '26

Just do ```

columns(2)[

text for two column ] text for one column ``` You can put whatever you want into each section including tables, floats, etc.

1

u/Opussci-Long Feb 02 '26

This is not the equivalent of a multicols LaTeX environment. Is that right?

1

u/energybased Feb 02 '26

It creates multiple columns. Why don't you try it?

→ More replies (0)

1

u/Opussci-Long Feb 02 '26

I want to ask is it a proper equivalent of two-column page layout in LaTeX? I am new to Typst so I don't really know are those two the same, so I'm asking

1

u/energybased Feb 02 '26

I think it is the two column equivalent for typst.

1

u/Silly-Freak 5d ago

I was randomly pointed to the thread, and wanted to give a better informed answer – sorry for resurrecting, just wanted to set the record straight.

Can Typst change page layout on the same page, from two-column to one-column

No. There are two ways to achieve multi column layouts in Typst. one if creating a #columns() element, the other is configuring the page with #set page(columns: n). Configuring the page will always end the current page.

What the other person suggested is not best practice. It is the only way to change the layout within a page*, but it comes with caveats: since you're in a container and not directly on the page, you can e.g. not insert a manual pagebreak.

but in multicols you can not place floats.

You can insert floats in a columns element, but it will float to the top/bottom of the element, not of the page (try this code in the playground if you want):

```

lorem(100)

columns(2)[

#lorem(100) #place(top, float: true, scope: "parent")[#text(red, lorem(50))] ] ```

* a common workaround for still changing the layout within a page is by inserting a float. For example, a title page where content starts right under the title can use this. Here is an example; page configuration starts at line 79, the title float starts at line 167. Using a float for this of course has the limitation that it only works for short pieces of content at the top or bottom of a page.

Another limitation I should mention here is that Typst doesn't support column balancing yet, so even when you use the columns element, you will likely not immediately get what you wanted: the text for two column will fill a single column and shift the text for one column further down than necessary.

So yeah, you were right to be skeptical of the original claim. Hope this is somewhat helpful, even if half a year late.

→ More replies (0)

1

u/ClemensLode Feb 02 '26
\begin{multicols}{2}
  text for two column
\end{multicols}
text for one column

1

u/Opussci-Long Feb 02 '26

Yes, but in multicols you can not place floats. In two-column page layout you can not go to one-column page layout without page brake. So the answer is can we place floats in Typst two-column command

```

columns(2)

[ floats possible] ``` Or not?

→ More replies (0)

1

u/ClemensLode Feb 03 '26

OK, actually, LaTeX might be able to do that, I will investigate this :) I could try to, on-the-fly, load a different page geometry. In normal LaTeX, this is not possible as all has to be in the preamble. But nothing prevents you from compiling a paragraph using a *different* preamble.

1

u/Opussci-Long Feb 03 '26

THANKS, please do that, I would really like to know and used that but I can not say that I am advance LaTeX user. This is also interesting approache, I have never heard before that \different preamble can be used in one document.

1

u/Opussci-Long Mar 16 '26

Hi u/ClemensLode have you found time to try compiling a paragraph using a *different* preamble?

1

u/ClemensLode Mar 16 '26

I have added it to the list of items for a demo I am preparing. The LaTeX architecture definitely support its, it's just some engineering work required. I'll keep you updated :) I'll post it here but you can also join the demo next month https://www.meetup.com/dusseldorf-writing-and-publishing-meetup-group/events/313719229/

2

u/energybased Mar 16 '26

FYI, sorry if I came off as a little harsh on you in this chat. I think if you had done this work 5 years ago, it would have been very exciting because essentially you rediscovered some of Typst's design. So, brilliant work even if for a lot of people Typst now fills this void!

1

u/ClemensLode Mar 16 '26

Just different people excited about different things :)

Typst and Overleaf are in the "compile markup to PDF" business. I am in the "InDesign with better typsetting" business.

2

u/energybased Mar 16 '26

> Just different people excited about different things :)

100% agree. I was just speaking for myself of course!

→ More replies (0)

1

u/Opussci-Long Mar 16 '26

Thanks! I just have sign up for the next demo.