I am getting the following error on few images being loaded by pdflatex. The images are in pdf files. MWE


pdflatex foo.tex gives

! Dimension too large.
<argument> \ht \@tempboxa 

l.7 ...,height=\textheight,keepaspectratio]{image}


The image.pdf is this link

It doe not matter if the image size specification is there or not, the error still shows up. i.e. \includegraphics[]{image} also generates the error.

The image pdf file has nothing in it. This is another issue. This image pdf file was created by Mathematica Export command. I was exporting a Mathematica image to pdf and it looks like Mathematica could not export the image to pdf file so it wrote an empty image pdf file. But the question is why pdflatex gives an error?

Is there a memory limit or some build in limit on size of pdf image files or dimensions?

I am using TL 2015 on linux mint 7.2

ps. Here is an example of pdf image file that is correctly read by pdflatex. It is not as large (and happened not to be empty as well).


fyi, Thanks to cfr comment in my other question How to check that image has valid size before `\includegraphics` is called? , using pdfinfo -box image.pdf gives

>pdfinfo -box image.pdf
Creator:        Wolfram Mathematica for Microsoft Windows (64-bit) (March 23, 2015) Student Edition - Personal Use Only
CreationDate:   Tue Jul 21 13:15:48 2015
ModDate:        Tue Jul 21 13:15:48 2015
Tagged:         no
Form:           none
Pages:          1
Encrypted:      no
Page size:      504 x 18988 pts
Page rot:       0
MediaBox:           0.00     0.00   504.00 18988.00
CropBox:            0.00     0.00   504.00 18988.00
BleedBox:           0.00     0.00   504.00 18988.00
TrimBox:            0.00     0.00   504.00 18988.00
ArtBox:             0.00     0.00   504.00 18988.00
File size:      337034 bytes
Optimized:      no
PDF version:    1.5
  • That's a really large image you're trying to include! Commented Jul 26, 2015 at 21:50
  • Your image reports as being 7x263.722 in! So the height is nearly 6.7 meters! Commented Jul 26, 2015 at 21:53
  • @ChristianHupfer No; it's not a blank page; it's full of formulas and code. Commented Jul 26, 2015 at 21:55
  • 1
    It's very big and acrobat says it has invalid ids internally. You can probably load it into something else then save at half size or less, although it's not going to be readable when scale into the a4 page anyway. Commented Jul 26, 2015 at 22:04
  • 1
    @Nasser the limit is not related to images it is a limit on tex dimensions. You can not have a length bigger than \maxdimen Commented Jul 26, 2015 at 22:06

3 Answers 3


There's a limit for graphics dimensions, bounded above by \maxdimen (16384pt); in the case of the height for images, the limit is around 574cm to 576cm for some of the images I tested. For example,





triggers the error message, but using 575 there's no error (just the obvious warning about overfull \vbox)

Your image is almost 670cm high! (clearly higher than \maxdimen) so the error is triggered. Besides that, what would you do with such a large image compressed to fit into an a4paper document?

  • Thanks. Is there a way to check for this in Latex before loading the image? I have thousands of such images, generated automatically and I do not know what size they will come out as. I need a way to check then if the image is too large and not include, else the build will fail. Most the images are small, but few, due to the computation, can show up this large.
    – Nasser
    Commented Jul 26, 2015 at 22:08
  • Open the image in your viewer and check the "Properties" section. Commented Jul 26, 2015 at 22:09
  • 1
    These are Mathematica graphics, exported to pdf using Mathematica Export. From design point of view, it is better to have the program trying to load the pdf to check if it can do it not, than trying to figure how to make Mathematica only export pdf files that Latex can load. May be later I want to use these pdf files by another program than can read them? Also it is hard to map Mathematica graphics sizes to what will show up as in pdf after export.
    – Nasser
    Commented Jul 26, 2015 at 22:38
  • 1
    Well it obviously does care or it wouldn't go bananas when @Nasser does! Indeed, if it cared less, there wouldn't be a problem... ;).
    – cfr
    Commented Jul 26, 2015 at 22:53
  • 2
    The issue not for latex to "correct" anything. The issue is to provide the means for the user to check if they want to load the image or not. This is called defensive programming. I should be able to write a Latex document that handle any size images by adding checks. If the image is too large, I will not load it. Now my Latex document is robust and will compile all the time. I can replace the image by a message saying image too large to include. Any way, I opened new question on this topic so this discussion may be belong to there.
    – Nasser
    Commented Jul 26, 2015 at 23:35

This may happen also if the image has sane size, but has declared incorrect DPI set (for example 800x600 pixels image, but with 2x2 DPI set... which makes it 1000 cm wide).

You can correct the DPI in an image editor (well, if it is not a PDF file), and it should work fine.


Another issue that seems to cause this problem is if the image is in CMYK colorspace (even if the dimensions are below the max limit). To fix this, you can re-save it as an RGB image using Photoshop or another image editing tool, or convert it directly using one of the many converters online such as http://www.cmykconverter.com/

This occurred with XeLateX on the Overleaf platform.


You must log in to answer this question.

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