2

As seen in this answer to my previous question “Extra vertical space at end of last column when loading adjustbox (only luatex)”, loading the package pgf causes the following to be added at the end of the document (in pgfutil-latex.def):

\AtBeginDocument{\AtEndDocument{\par\vfil\penalty-10000\relax\the\pgfutil@everybye}}

As shown in the linked question, this can sometimes cause problems.

  • Why is pgf doing this?
  • If I don’t know whether pgf will be loaded in a given document, how can I get rid of this space? (Without having to modify the document content)
Socob
  • 1,693

2 Answers2

1

As to why pgf is "doing this", it looks like a bug.

To deal with the faulty insertion of vertical space, you can try the following code just before \begin{document}

\makeatletter    
\ifdefined\pgfutil@everybye \AtEndDocument{\clearpage\the\pgfutil@everybye}\else\relax\fi
\makeatother

The answer to defining a fading-style directly in the fill command is informative, and I borrowed the \AtEndDocument{...} command from there.

corporal
  • 741
  • How does this address what Ulrike wrote in the linked question? “In your example a work around is to add a \newpage before \end{document}. But if pgf puts something in the toks register \pgfutil@everybye this could lead to a second page.” Also, wouldn’t this output whatever is in \pgfutil@everybye twice? – Socob Nov 10 '18 at 03:02
  • I wasn't really trying to address what Ulrike wrote in the linked question. I was suggesting that you use the code above in the preamble so you don't need to modify the body of the document. The code above more or less checks whether pgf is loaded. I tested the above code with your document and it seems to prevent the unwanted space being inserted. I have looked into the meaning of \pgfutil@everybye and I think it's a bit beyond my understanding. I did wonder whether the \AtEndDocument{...} command could be "beaten" by an \AtVeryEnd or something similar. Have you tested the code above? – corporal Nov 11 '18 at 05:54
0

As revealed in a comment by Henri Menke, it seems that this issue should be addressed in a future PGF release:
https://sourceforge.net/p/pgf/git/ci/fbfabbd01cecb4e8b6b1e43d1f3ad685c7e60778/

I had also opened a bug report on the PGF/TikZ tracker: #502 PGF can cause extra space at the end of a document (\pgfutil@everybye).

Socob
  • 1,693