Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

---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.

share|improve this question
2  
As soon as TeX finish a page and "ships" it, it forgets all about that. The information you want is not tracked. This is why an .aux file 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
1  
It appears from your description that you don't break mid paragraph (verse) and you want to sync the two streams at every verse. That makes it much simpler and you could just conceptually set it as a two column table with a verse in each row and a language in each column, or use the parallel package. If the parallel package doesn't address your needs perhaps you could highlight why not and we could suggest an extension. –  David Carlisle Dec 14 '12 at 14:45
    
@DavidCarlisle I might be missing something, but I don't think the parallel actually syncs my texts properly. –  McGafter Dec 14 '12 at 14:54
    
well the canonical answer to your question is I think, use parallel package. It's quite possible that it doesn't always do what you want (some people sometimes say that about my packages) but hard to say without an example (in a new question) I need to go offline though:-) –  David Carlisle Dec 14 '12 at 15:01

1 Answer 1

up vote 6 down vote accepted

The line breaking and page breaking in TeX work in two asynchronous passes and there is no feedback back from the page breaker to the line breaker. (I'm ignoring luatex in this answer as it makes some things I say wrong). So conceptually The document input is broken up at each paragraph end and placed on an infinite scroll, then every now and then the output routine is invoked which chops off sufficient part of the scroll to make up a page, adding in floating figures page head and foot etc. The thing to note here is that much of the next page (or pages) have already been set by this time.

Basically This assumption isn't true:

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.

At the time of the page breaking TeX is only seeing a vertical list of boxes, it has no track of how those boxes relate to the original source.

If you could edit your question to be more specific about exactly what information you need to pass to each page we can probably help. Classic texniques such as \mark and writing to the aux file as you note can help, also \pdfsavepos is very useful in this context. Or, if luatex is an option, lua callbacks give far more control/information than has traditionally been available in TeX.

share|improve this answer
    
I've updated an explanation. Illustrating the issue, with a proposed solution based on your comment. –  McGafter Dec 14 '12 at 14:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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