How to force pdflatex (PDF) over latex (DVI) compilation

April 25, 2019

PSA: If you’re submitting a latex source file to a journal, and their compiler is giving you errors related to DVI output, try adding %&pdflatex to the top of the file (make it line 1, all by itself) to force using pdflatex over plain latex + dvipdf.

In my case, I was getting errors along the lines of

! LaTeX Error: Cannot determine size of graphic in figure.pdf (no BoundingBox)

This is an indication that the backend compiler is plain latex (trying to create a DVI), which is unable to determine the size of PDF, PNG, or JPG images. (If this is your only problem, then another solution is to use EPS images instead, which should be handled just fine by plain latex.)

More info in the following TeX StackExchange threads: