0

I am creating pdfs by including some random images from a large scale image database. The resolutions of images in this database are very different, so I can't change the resolution. Besides that, because of the layout restriction I can't use some existing solutions of similar question.

Note: you can download images here.

\documentclass{article}[10pt]
\usepackage[margin=0.5in]{geometry}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{rotating}
\usepackage{tabularx}
\renewcommand\tabularxcolumn[1]{m{#1}}
\usepackage{xcolor}
\newcommand\pic[1]{
    \includegraphics[width=1cm]{#1}
\hspace{0.25cm}
}
\newcommand\rdpic[3]%
{\begin{tabular}[]{@{}l@{}}
        \footnotesize\color{blue}  #1\\[-1ex]
        \footnotesize\color{blue}  #2\\
        \pic{#3}
    \end{tabular}%
}
\begin{document}
    \noindent
    \begin{tabularx}{\textwidth}%
        {>{\begin{sideways}\color{red}}m{2ex}<{\end{sideways}}%
            X%
        }
        \toprule
        row 1
                & \pic{1-13.jpg}
        \\\midrule
        row 2
&       \rdpic{1}{-0.4602}{1-13.jpg}
        \rdpic{2}{-0.4600}{140a900f-0781-4627-80eb-d8789de17812.jpg}
        \rdpic{3}{-0.4600}{5d7bb2d2-041a-420c-a470-384aa15dbe83.jpg}
        \rdpic{4}{-0.4599}{be21f5f1-ad2c-4389-8473-7b18c68e4eb9.jpg}
        \rdpic{5}{-0.4599}{ae5d6366-7d30-4755-bcf1-34fae2be0054.jpg}
        \rdpic{6}{-0.4598}{ed3ae766-9a7e-4f3b-8b57-c6c97b68a04a.jpg}
        \rdpic{7}{-0.4598}{c2e177d3-38a6-48bb-91ca-ee88810fb2c7.jpg}
        \rdpic{8}{-0.4598}{377a7efa-af04-4c21-8284-d0647949aa69.jpg}
        \rdpic{9}{-0.4598}{9b521e94-55d8-4c68-8f22-fb7dd0ce8953.jpg}
        \rdpic{10}{-0.4598}{96ce00e6-f672-4d49-8a90-dd5855eb093f.jpg}
        \\\midrule
        row 3
        &       \rdpic{1}{-0.4602}{1-13.jpg}
        \rdpic{365113}{-0.1779}{10-13.jpg}
        \rdpic{421389}{-0.1196}{2-13.jpg}
        \rdpic{618943}{0.0728}{3-13.jpg}
        \rdpic{801031}{0.1514}{4-13.jpg}
        \rdpic{569609}{0.0503}{5-13.jpg}
        \rdpic{655861}{0.0862}{6-13.jpg}
        \rdpic{894375}{0.7555}{7-13.jpg}
        \rdpic{136541}{-0.3524}{8-13.jpg}
    \\\bottomrule
    \end{tabularx}
\end{document}

enter image description here

  • 2
    Could you please show a minimal working example? – totera Jan 10 '17 at 10:49
  • 2
    99 times out of 100 the too large error comes from scaling after rotating the image to have zero height (so it is division by zero and infinitely large) the way to solve that is not to do it, can you show an example where you are getting this error on an actual finite calculation? – David Carlisle Jan 10 '17 at 10:51
  • @DavidCarlisle you are right, I saw rotated images when the error shows. But I did not do any rotation. Could you explain it? – neouyghur Jan 10 '17 at 11:35
  • @DavidCarlisle I offered images, could not you download it? – neouyghur Jan 10 '17 at 13:27
  • @neouyghur oh so you did, it would have been better to have cut the example down but sorry I just missed that link completely, I'll look – David Carlisle Jan 10 '17 at 13:28
4

really, the example is not at all minimal, it can easily be cut down to the following just by deleting things and checking the error still occurs

\documentclass{article}

\usepackage{tabularx,graphicx}

\begin{document}
   \noindent
    \begin{tabularx}{\textwidth}{X}
        \includegraphics{10-13.jpg}
    \end{tabularx}
\end{document}

If you look at the log or terminal output you see

pdfTeX warning: pdflatex: arithmetic: number too big
<10-13.jpg, id=1, --32768.0pt x 0.0pt> <use 10-13.jpg>
! Dimension too large.

So before the graphics package arithmetic gave up with the ! Dimension too large pdftex had given up reading the natural size of the image and had underflowed its width to be showing as negative maxdimen. Given that starting width any attempt to scale the image to any size is going to fail in arbitrary ways.

There seems to be something odd in that file, if I just get imagemagic convert to re-write the jpg

mv 10-13.jpg x.jpg
convert x.jpg 10-13.jpg

Then pdftex reads it with no problem and shows:

<10-13.jpg, id=1, 718.685pt x 530.98375pt> <use 10-13.jpg> <use 10-13.jpg>

That is, it read the initial width as 718.685pt

  • you are right, it is the problem of these weird images. Thanks. – neouyghur Jan 10 '17 at 14:44
  • 1
    I encountered a similar issue with an image that had a dpi of 1. Increasing the dpi and re-exporting solved the issue. – Sussch Feb 4 '18 at 18:27

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.