0

Using the packages adjustbox and qtree simultaneously causes the error:

Package graphics Error: Division by 0. \includegraphics[width=0.3\textwidth]{myimage.bmp}

Minimal working example:

\documentclass{report} \usepackage{adjustbox} %Lets table extend beyond margins \usepackage{qtree} %Allows drawing of syntax etc trees '\Tree' \begin{document} \begin{figure}[hp] \centering \includegraphics[width=0.3\textwidth]{myimage.bmp} \caption{My image} \label{fig:figure1} \end{figure} \end{document} 

Is it possible to use them both in the same document?

Edit: This is being compiled with XeLateX.

Edit2: This bug only occurs with .bmp, and not with .png files; changing file format is a fine workaround.

9
  • Using the code with \includegraphics[width=0.3\textwidth]{example-image} everything is fine. You can test it... . I think its a problem with myimage.bmp. Commented Mar 8, 2017 at 16:19
  • I'd be half-surprised to learn that this works without those two packages and solely graphicx loaded instead. Two thoughts: (1) use a different file format; (2) if sticking with bitmaps, you probably need to use the bmpsize package. Commented Mar 8, 2017 at 19:55
  • 2
    do you really mean that if you remove qtree from that document that it works? Commented Mar 8, 2017 at 20:46
  • 1
    Well, as adjustbox loads graphicx (which is where the \includegraphics command comes from), the question becomes: does qtree conflict with graphicx? But I mean don't use bitmaps as a matter of general practice. I can't actually reproduce the problem, however, so I'm not suggesting it as the solution, just a possible workaround. (Tonight, I'll try again with another .bmp file.) Commented Mar 9, 2017 at 18:41
  • 1
    If you change myimage.bmp to example-image-a, does the example work? I have no idea where I'd get a BMP from. But there is certainly no essential conflict if adjustbox and qtree work with other image formats. Commented Mar 9, 2017 at 22:54

1 Answer 1

1

BMP images are not really supported. Maybe XeLaTeX has some support, but PDFLaTex definitifly hasn't. The "division by 0" error comes from graphics package (loaded by graphicx which in turn is loaded by adjustbox) and is caused most likely has the original width can not be extracted from the BMP file and is therefore 0. When using the width key I guess the original width is used in a division and then the error is caused.

So I would heavily recommend to convert you BMP Image to a PNG Image using an external image tool. Most modern tools can do this and the conversion is lossless.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.