The LuaTeX engine provides a callback that allows you to replace the built-in paragraph builder by your own algorithm. My question is twofold:

  • does there exist a lua implementation that fully (or partially) reimplements the normal algorithm that can be used as a basis for paragraph breaking experiences?
  • if not (or even if yes) are there any other known uses of this callback?


Given that my first part of the question was answered in the comments below, i.e., that Taco (I guess) has reimplemented the paragraph builder from TeX (with additions from pdfTeX and Omega/Aleph) in Lua). Can somebody perhaps show how to use this lua script in a simple plain TeX scenario?

In other words how is this applied so that

<some luatex setup setting up the appropriate callback to make use of node-ltp.lua>

This is a sample paragraph ....\par



If that is too complicated with plain (as the code seems to draw a lot on ConTeXt specific material) then something that works with ConTeXt is fine too. After all, all I want to be able to is to see the code in action and be able to do experiments by changing it on the Lua side.

  • Yes; Hans Hagen presented one this week at the ConTeXt conference. Sep 13, 2014 at 15:32
  • 1
    @MartinSchröder Is there any link where we can review that you mentioned?
    – Aradnix
    Sep 13, 2014 at 18:03
  • 4
    @Aradnix The parbuilder code has been part of Context for quite some time. Just check your TeX distribution for the file node-ltp.lua. Of course, the code is available in the official Git repo as well. Sep 14, 2014 at 10:46
  • 1
    @phg must have been blind .. of course it is in TL14 ... now I only have to find out how to actually use it ... but it does only answer the first part of my question ... is there anything else? Sep 14, 2014 at 19:34
  • @phg or anybody else: any chance to help with an answer showing how to make this code work? Sep 22, 2014 at 8:57

1 Answer 1


In ConTeXt, you are supposed to use it like this:

This is a sample paragraph .... \par or more of them

and it is supposed to listen to \tracingparagraphs.

I say supposed, because the current version has some bugs: continued development of ConTeXt has changed some of the internals and this code, which is hardly ever used, has not been kept up to date. I'll send a message off to the ConTeXt mailing list reporting the problems.

  • I'm intrigued: if you've reimplemented the paragraph breaker in Lua, is there a reason it's not used routinely?
    – Joseph Wright
    Sep 25, 2014 at 7:30
  • 1
    I have updated the answer to add the \starttext wrapper. I assume a next ConTeXt beta will have the bug fixed, and hopefully that will then appear in TL. And yes, when you see the 'reverted' line the output comes from the internal par builder Sep 25, 2014 at 15:02
  • 1
    hope one day we'll have a workable solution out of the box but for now it seems this is the best approximation Oct 4, 2014 at 16:42
  • 1
    @FrankMittelbach: FWIW, the code posted by Taco works with a recent ConTeXt installation.
    – Aditya
    Jun 17, 2015 at 21:51
  • 1
    @Aditya yes and no ... it does run that's true but if you set \tracingparagraphs and \tracingonline you see that it still has some problems as it reports several times "Lua linebreak_filter failed, reverting to default on line 1". This is not during the main para breaking (that gets executed using the lua implementation it seems) but in other places -- not yet traced. Sep 12, 2015 at 15:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.