4

Assume that you have a program that is writing a report while it computes, and the report is a LaTeX file with text, TikZ figures, ect. that needs to be compiled to a PDF before it can be viewed properly.

By executing a command along the lines of

lualatex "\\input{report}\\end{document}"

it can be compiled while the report is still being written. The figures in the document contain many elements, so if the program is executing faster than lualtex can compile, this doesn't terminate before the program does. As the PDF file produced by Lualatex cannot be viewed (by xpdf, evince, ect.) before compilation has completed, this means that the start of the report cannot be examined before the program writing "report.tex" is finished.

Can I let (lua)latex write checkpoints to the PDF file, so that its first pages can already be viewed while Lualatex isn't done yet?

This would allow to debug the program while it is still running. I'm talking about hours of computation time for the program here, so this would help a lot.


Some details: I don't insist on using lualatex, but pdflatex frequently runs out of memory with the report ("TeX capacity exceeded, sorry [main memory size=5000000]"). Even after stopping the program that creates the report after a few minutes, lualatex still need >30 minutes to compile the report. While the program creating the report can of course be rewritten to use LaTeX commands that are "cheaper", this is an optimization that I would like to avoid as the focus is on keeping the program simple -- the report is actually used to debug this program.

1 Answer 1

10
+50

Unfinished PDF files are not meant to be viewed.

PDF files are made up of objects and references to objects. Objects may be located in arbitrary order within the PDF file. Their exact byte position is defined in the xref table, usually at the end of the PDF file.

There are means to optimize PDF files for faster Web view, trying to put the PDF objects into linear order, such that they can indeed be rendered before complete download of the PDF file. However, such optimization is usually a post-processing step done by other programs, such as pdfopt, and can be applied only after the whole PDF file has been written (a first time).

4
  • 1
    Even linearized PDF can not be changed after it has been written; i.e. there's no way to create the "checkpoint" feature the OP wants with PDF. Commented Mar 10, 2015 at 10:27
  • Thanks for your answer. I just wonder if there is, for example, some way to let (Lua)Latex finish the pdf-file and reopen it after every page. I'll give the question a few more days before accepting an answer.
    – DCTLib
    Commented Mar 12, 2015 at 11:40
  • @DCTLib With --shell-escape you can call another tex in a tex. But why bother while there is shell script?
    – Symbol 1
    Commented Mar 12, 2015 at 13:52
  • @Symbol1 - Using something in this direction will require a change in the document. Looks like I was asking for too much. So I'm accepting this answer.
    – DCTLib
    Commented Mar 18, 2015 at 9:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .