1

Consider this code

\documentclass{report}
\usepackage{graphicx}
\begin{document}
\begin{figure}[htp]
\includegraphics[width=0.4\textwidth]{imageA.png}
%\includegraphics[width=0.4\textwidth]{imageB.png}                                                                                                                                      
\end{figure}
\end{document}

Compilation works fine with pdflatex. With xelatex however imageA.png is displayed blank while imageB.png appears normally.

I don't see any warnings what might be wrong with imageA.png nor anything specific in the .log files. Nor do I see any warnings referred to in Why can't XeTeX handle this dank meme?

Any clues?

10
  • use the --nopdf option to xetex, so it makes a xdv file then run xdvipdfmx on the xdv to get the pdf, that way you will see any warnings from the dvi driver, which are usually hidden Jan 29, 2019 at 11:23
  • I run xelatex figcheck.tex --nopdf but cannot find any xdv file
    – Viesturs
    Jan 29, 2019 at 11:29
  • It should be xelatex --no-pdf figcheck.tex Jan 29, 2019 at 11:30
  • I see figcheck.xdv -> figcheck.pdf [1] 50837 bytes written butthere are no warnings.
    – Viesturs
    Jan 29, 2019 at 11:33
  • 1
    The dpi of that image is way out (3dpi) if it was loaded at that scale it would be from here to infinity (toy story joke actually = 155.67 inches !) the default is usually 72 or more likely 96 dpi = 4.86 inches which will fit on the page
    – user170109
    Jan 29, 2019 at 19:09

1 Answer 1

3

See if this download works for you in XeLaTeX

enter image description here

Odd values for dpi can be a problem with different formats such as bmp or png often downloaded by right click from the internet.

In windows 10 folders you can add columns for horizontal and vertical resolution I cant remember if that changed from earlier versions. enter image description here MS paint will also show the problem file properties as 3 dpi x 3dpi but an image with no dpi might on some systems appear as 96 (the default). If you right click download an image with no dpi it will likely also fail.

For a fuller description of a similar problem in XeTeX and an old workaround using MSpaint to save as/re-save as see https://tex.stackexchange.com/a/463610/170109

Depending on your needs to modify images during beamer compilation you may find this answer of interest https://tex.stackexchange.com/a/455862/170109

5
  • What did you change and how?
    – Viesturs
    Jan 29, 2019 at 19:14
  • 1
    Using ifanview on windows simply set dpi to 96 many graphics packages will do similar and likely one of your repertoir of programs could given the right parameters.
    – user170109
    Jan 29, 2019 at 19:17
  • Why is this an issue only for xelatex but not for pdflatex?
    – Viesturs
    Jan 29, 2019 at 19:17
  • Unsure others may answer, but XeLaTeX may be more strict in using the ratio stated by the image, has been similar issues for pdfLaTeX users when not aware of the possibility
    – user170109
    Jan 29, 2019 at 19:20
  • How do you check the dpi of an image?
    – Viesturs
    Jan 29, 2019 at 19:25

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