0

I'd like to determine approximately how far down the page TeX's paragraph builder (i.e., tex.linebreak(...) in LuaTex) is when it starts. For example, in \begin{document}A\par B\end{document} when the tex.linebreak is about to start I assume it is one baselineskip down the page.

The reason I ask for an approximate answer is because I believe it's not really possible to determine the answer exactly. The obstacles include (I think) the fact that the vertical list destined to become a page may be stretchable and hence until the page is set the the vertical position is not known. And of course, the page is set after line-breaking happens.

However, a reasonable approximation (I think) would be to compute the natural vsize of all the matter on the vertical list when linebreak is called. A very simple approach is to simply count how many lines have been created so far (see the amazing answer https://tex.stackexchange.com/a/403353/1078). But this won't deal with things like section headings and display math. What struck me as a better approximation was to track the vertical size of everything that gets added to the main vertical list.

What I have tried is writing my own linebreak_filter that calls tex.linebreak and intercepts its return. Unfortunately the retuned list of nodes is quite complicated. Furthermore, I seem to be missing things like displayed mathematics. So I wonder whether I am on the right track (or reinventing the wheel).

banbh
  • 1,055
  • Beside being stretchable you generally don't even know which page the first line of the paragraph will be on before linebreaking (e.g. does it still fit on the previous page?) Also floating figures can lead to significant offsets. The usual approach is to have multiple passes: In the first pass you let TeX place the page content and you save the resulting position, in a second TeX run you can access and interpret these values. (Potentially repeat until the position stops changing) What are you actually trying to do with this information? – Marcel Krüger Jan 17 '22 at 18:22
  • What is your use case for this? What might you do with the information? – Peter Wilson Jan 17 '22 at 19:09
  • @MarcelKrüger, @PeterWilson: Fair question (and perhaps I should edit my question). What I am trying to do is something similar to what @ShreevatsaR was trying to do but a little more general. Namely, I want text to flow around something, but I want what it flows around to be fixed on the page (say, bottom right corner) rather than attached to a particular paragraph. I thought that if I could determine at the start of linebreak_filter where I am, then I can pass tex.linebreak a suitable parshape table. Perhaps this is hopeless (or the domain of flowfram)? – banbh Jan 17 '22 at 22:44

0 Answers0