---Edit:
In response to David Carlisle's answer, here is an actual scenario where the problem occurs.
I have two Bible texts in two languages. Let's say English and Spanish. The basic idea of presenting the text in parallel has been addressed by the following question. Syncing text on bilingual pages The remaining problem is that I need to get the verses synced per page. The current proposed solution goes out of sync really quickly. So that for instance Genesis chapter 20 verse 5 of the English and Spanish is on the same set of pages.
So I was thinking about adding a \pdfsavepos at the end of the verse and dumping it into an aux file. This would produce an aux file where the verses would be something like:
book01chapter01verse001=10000ypos
book01chapter01verse002=15000ypos
book01chapter01verse003=20000ypos
and then where a page break occurs:
book01chapter01verse009=50000ypos
book01chapter01verse010=10000ypos
But since I want full verses on each page I will have to do an "if yposCurrent > yposNext then insert \newpage before current verse" for every page. Then it gets messy since the aux file needs to be updated for this verse and the subsequent verses.
Then the compiler needs to be run again. And it will very likely find the same occurrence on the very next page.
So I'll probably end up doing about a thousand compiler runs just to produce the PDF.
---Original post:
In many of my past projects this question has arisen. How can I find out how much of the actual text will LaTeX place on the current page?
LaTeX obviously has a mathematical way of counting and distributing the letters/words (boxes) involved for the text. Using that to calculate how much to place on the page and spread it out to justify it etc.
So when page 1 is done it knows where in the original text to start for page 2, and when page 3 is done the same for page 4 and so on. So somehow it not only calculates these parameters but also keeps track of it.
Now, I want to know if it is possible for me to get a hold of these parameters to be able to parse my text through LaTeX and get this data stored in a variable of where exactly my text will be broken up? (Without hacking into TeX and having to rewrite parts of it, by the way...)
Previous suggested solutions mentioned writing certain "milestones/waypoints" to an aux "log" file which can be used on the next run to adjust your text, but that solution won't fully work for my problem. Since I use source texts which are very large and if you do it by means of a log file then you need a compilation run for every time you adjust any text on any page. And if any of the subsequent pages needs adjusting, then you need another compilation run for that page whilst writing the new "milestones" to the log file, which again requires another run to process and adjust the subsequent text. So on my book which is over a thousand pages, I'll be sitting all day having to compile it. Then if I need to go back to page 23 to fix a minor mistake in the text, I'll probably end up having to compile the whole thing over again about 900 times.
Therefore as far as I can see, I need the variable with the page break data, and be able to adjust this in one compilation run. So that I can then manually do the needed adjustments to my texts and then let LaTeX place it in the correct place.
A bit like a massive FOR loop working on the text in the variable...
In summary: The problem might seem a bit vague to you but I really just need to be able to figure out how much TeX would place on a page, and that's it.
.auxfile is used to write information required at the beginning of the document, but not available until some page. When that page is processed, appropiate commands are written in the.aux, and this file is read at the beginning of the next run. Those commands define macros and variables related to the required information. You should follow a similar approach. – JLDiaz Dec 14 '12 at 10:33