13

Note: original title was "Is there a maximum size PDF that Latex can create?". I've edited the title to better reflect what I've discovered the issue to be.

I'm creating a presentation in Beamer and I'm including several animations, using the animate package.

This works well when I have about 6 animations and produces a fairly large pdf (~95 Mb). When I try to add a couple more animations however my compiler freezes after a while. No error message is given. If I comment out the new animations everything still works. I tried compiling using both pdflatex and lualatex but ended up with the same result.

Is there a limit to how big a pdf latex can make? Or some other explanation?

Edit 1:

As pointed out below the problem is not with the size of the PDF. I seem to be able to reproduce the problem by including multiple copies of the same animation. I've done some searching and I cannot find any reports of this happening elsewhere. Does anyone know what might be causing this?

If a MWE is needed I can try and provide one.

Edit 2:

Here is a MWE. It actually does compile, but it hangs for about a minute after adding the first copy of the animation. I tried letting my original presentation compile, but after an hour it was still hanging. I am using a Windows 10 machine.

\documentclass{beamer}

\usepackage[utf8]{inputenc}
\usepackage{animate}

\begin{document}
\begin{frame}
    \animategraphics[autoplay,loop,width=0.4\textwidth]{8}{animation}{1}{99}
    \animategraphics[autoplay,loop,width=0.4\textwidth]{8}{animation}{1}{99}
\end{frame}
\end{document}

animation.pdf

  • 1
    Try using the new animations and comment several out, you inserted earlier. So, you will see, if the number of animations is the problem. – MaestroGlanz Feb 12 '17 at 15:22
  • Yes, I should have mentioned that I've done that. The new animations render properly without any issues if the other animations are commented out. – Lukas Bystricky Feb 12 '17 at 15:23
  • 2
    see tex.stackexchange.com/questions/97071/… which asks about the page count but the limiting feature is the number of pdf objects. – David Carlisle Feb 12 '17 at 15:29
  • 1
    Yes a MWE is definitely needed here. – ShreevatsaR Feb 14 '17 at 2:44
  • 2
    Great, +1 for adding the MWE! With the version currently (downloading the animation.pdf linked in the question and running pdflatex on the above tex file), it takes my computer about 12 seconds to compile: it does indeed seem to hang for ~10 seconds towards the end, though. Hopefully someone who knows more about animate now has enough to answer the question. But a presentation that hangs for an hour (for you) may be even better. – ShreevatsaR Feb 14 '17 at 16:27
2
+50

animate ensures that a graphics file/page of a multipage file is embedded only once in case of duplicate animations. It does so by verifying the MD5 checksum of the file to be embedded. Calculating the checksum is rather expensive.

In version [2017/02/24] the code was optimized to reduce the number of MD5 calculations to the bare minimum. This accelerates embedding of the external file for animation (animation.pdf link in the OP) by a factor of 2. All subsequent copies take about the same time for processing as the first, original one, if not even less.

Here is a piece of code for testing, which writes the elapsed time in "scaled seconds" (see pdfTeX manual) to the terminal:

\documentclass{beamer}

\usepackage{animate}[2017/02/24]

\begin{document}
\begin{frame}
    \pdfresettimer%
    \animategraphics[autoplay,loop,width=0.4\textwidth]{8}{animation}{}{}
    \typeout{anim 0: \the\pdfelapsedtime}\pdfresettimer%
    \animategraphics[autoplay,loop,width=0.4\textwidth]{8}{animation}{}{}
    \typeout{anim 1: \the\pdfelapsedtime}\pdfresettimer%

    \animategraphics[autoplay,loop,width=0.4\textwidth]{8}{animation}{}{}
    \typeout{anim 2: \the\pdfelapsedtime}\pdfresettimer%
    \animategraphics[autoplay,loop,width=0.4\textwidth]{8}{animation}{}{}
    \typeout{anim 3: \the\pdfelapsedtime}%
\end{frame}
\end{document}
  • Wow that's great! I tried looking for it in the MiKTex update manager, but I couldn't find it there. Should I try uninstalling and reinstalling the animate package? – Lukas Bystricky Feb 23 '17 at 13:32
  • MiKTeX updates packages only once per week or so. You may think about moving to TeXLive which is much closer to the upstream package versions on CTAN (with a max. delay of 24 to 48 hours). For now, you could download animate.sty directly from CTAN into your working directory. But don't forget to delete it after your next successful updating MiKTeX packages. – AlexG Feb 23 '17 at 13:45
  • @HH animate updated once more, further reducing compilation time. – AlexG Feb 25 '17 at 12:37
16

The PDF file has a cross-reference table that records the file offsets for indirect objects. These offsets are stored with ten decimal digits. This limits the maximum file size to about 1010 bytes (approximately 10 GB).

Other limiting factors:

  • File system.
  • 32-bit software needs to be compiled with large file support (AFAIK pdfTeX has large file support).

Summary: Except for ancient software, generating a file with 100 MB should not pose a problem.

  • I'm compiling on a 64 bit machine. As per @DavidCarlisle 's comment above, my problem may be related to the number of pdf objects. I'm still not clear on what that means. All my animations come from tikz and are high resolution, but I'm precompiling them into pdfs first. Is there anything else I could do to get this to work? – Lukas Bystricky Feb 13 '17 at 19:01
  • @HH The number of objects is not the reason, in my answer to David Carlisle's referenced question, I have successfully generated PDF files with several hundreds of MB before exceeding the object number limit. – Heiko Oberdiek Feb 13 '17 at 22:09
  • Sorry, you are wrong: tex.stackexchange.com/a/97081/5763 – Martin Schröder Feb 15 '17 at 13:00
3

You have some good answers already, but to give you a new datapoint, at my job I work with a 10,000 page book that comes in at about 600mb. That's the SAS/STAT User's Guide, done with pdflatex.

  • A SAS manual done with LaTeX? This improves my (till now not very good) judgement about SAS... – CarLaTeX Feb 17 '17 at 17:11

Your Answer

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

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