I there a way to print messages to the log file so that they appear in the last few line of the log file?

Here is a MWE for my first attempt at doing this:

Here is my nice message^^J
Some important stuff.

At first sight this appears to do what I want because in this case the end of the logfile looks like:

Here is my nice message

(./MWE.aux) )</usr/local/texlive/2014/texmf-dist/fonts/type1/public/amsfonts/cm/c
Output written on MWE.pdf (1 page, 20364 bytes).
Transcript written on MWE.log.

Unfortunately, this is deceptive because the guff between my message and the Output written... line is quite short here. In a real use-case the end of the log file looks more like:

Here is my nice message

[7] (./realexample.aux) )
(see the transcript file for additional information){/usr/local/texlive/2014/te
Output written on realexample.pdf (7 pages, 124830 bytes).
SyncTeX written on realexample.synctex.gz.
Transcript written on realexample.log.

That is, in real-life there is a lot of space between my message and the end of the log file.

It turns out that Heiko Oberdiek has written the atveryend package that provides various commands like: \AtVeryEndDocument, AtEndAfterFileList, \AtVeryVeryEnd. Unfortunately, all of these commands give exactly the same output in the log file as using \AtEndDocument. Similarly, the etoolbox command \AfterEndDocument doesn't help either...

Does anyone know of a way to do this or if this is impossible? Given Heiko's package I suspect this can't be done.

Finally, perhaps I should say that the reason that I want to do this is to remind myself (and others) of the list of options to an undocumented in-house class...


You have already found the latest possibilities for writing into the .log file:

  • \AtVeryVeryEnd of package atveryend
  • \AfterEndDocument of package etoolbox

Both hook into \end{document} to put the hook right before the final \@@end (= the primitive \end). \AtEndDocument is too early, because the final \clearpage and reading of the .aux file with its rerun warnings are following.

But AFAIK there is no way inside TeX code to print something after the fonts, which are output by pdfTeX, when it finishes the output of the .pdf file.

A clumsy workaround would be to write the final message to a file, e.g. \jobname.message and to use a script, which first runs pdflatex and then appends the output of the file \jobname.message to the .log file.

  • Thanks for confirming this Heiko! I thought that was probably the case but hoped otherwise:) – user30471 Aug 21 '14 at 13:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy