# Possibility of extending LaTeX capabilities given technology advancements?

As countless questions/answers have noted in the past, LaTeX requires you to compile at least twice when there are references, TOC/LOF, etc. Many of these situations have been documented in the answer to What are the situations where you have to compile a document more than once?

Efforts at avoiding this extra step have been successful in select, very specific cases, such as How can I avoid compiling twice? Yet, it is a practice that we take as a given today, simply developing scripts and macros to automate this process enough to ease the pain.

The answer to [this question about moving to the previous page] alludes to memory constraints of early computers being central to the reasons why TeX was originally built the way it was. Information that might be needed later is simply stowed away in any number of auxiliary files, and referred to as the next pass was made. Once a page is "complete", it is forgotten by the compiler.

I have often thought: Given the advancements in computer processing and memory capabilities, is it possible/realistic/planned for LaTeX to maintain more of the document in memory to avoid having to compile multiple times?

Keeping the entire document in memory would take a lot of memory, and perhaps some very large documents could not go this route (maybe it would have to be an optional behavior). But it seems that many aspects of typesetting would benefit from this sort of enhanced compilation.

I realize this gets to the heart of what (La)TeX is and how it was built. It is not a simple patch; it likely requires a rewrite of the whole core (or does it?). There are certainly other issues that surround this as well (Would this actually reduce compilation time?); I'd be delighted for a reference to another place that discusses this or related issues. (Has this been thought about for LaTeX3?)

-
Note: unless you use a fundamentally different underlying technology, LateX3 can't do this as it still uses TeX. I also note that ConTeXt MkIV still uses multiple passes (all rolled up into context). – Joseph Wright Mar 19 '14 at 15:08
You might find this question interesting: tex.stackexchange.com/questions/114292/… – alexwlchan Mar 19 '14 at 15:13
What do you mean by "many aspects of typesetting would benefit from this sort of enhanced compilation"? I'm no power-user of any kind but for most of my work, texify.exe does the job of streamlining it all into one, seamless process. – Doggie52 Mar 19 '14 at 16:17
@Doggie52, Perhaps "many aspects" was overstating the problem. Most "ordinary" documents won't benefit greatly; but anything that wants to optimize page breaks or float text itself could use the feature (perhaps this question, for instance). – cslstr Mar 19 '14 at 20:28
I recognize that the feature is not "easy" in any sense. And that TeX doesn't inherently support the feature. Nevertheless, I wonder if there isn't some sort of overlay that could augment TeX in a way that would make it more intelligent in the vertical-mode sense. @alexwlchan The TuG Q&A was pretty insightful and helps me accept the way things are a bit easier. – cslstr Mar 19 '14 at 20:31

One optimization that could be obtained by keeping the whole document in memory would be to first number all sections and equations etc, then resolve references done through \ref, then typeset. In the absence of \pageref, all of the typeset content would be known on a first pass, which reduces the total compilation time. – Bruno Le Floch Aug 7 '14 at 22:42