Tx · LaTeX & TikZ

How to Show Images in LaTeX Draft Mode

Published By the 9to5Science editorial team

At a glance

  1. 1. Find the draft setting

    Check the document class, graphicx options, and any options passed to graphicx.

  2. 2. Turn off image drafts

    Set the graphicx draft key to false globally or on each includegraphics command.

  3. 3. Compile and check

    Confirm the image file exists and rebuild the document to verify it appears.

Draft mode can replace included images with empty boxes, often labeled with the image filename. You can keep draft settings for the rest of your document and tell graphicx to render the pictures normally.

Turn off draft mode for all images

Load graphicx, then set its Gin keys so that draft is false:

\usepackage{graphicx}
\setkeys{Gin}{draft=false}

Put \setkeys{Gin}{draft=false} after loading graphicx and before the images you want to display. This overrides a draft setting passed to the graphics package, including one inherited from the document class.

Here is a complete example. The mwe package supplies the example-image file used below; replace that filename with your own image when adapting the example.

\documentclass[draft]{article}
\usepackage{graphicx}
\usepackage{mwe}

\setkeys{Gin}{draft=false}

\begin{document}
\includegraphics[width=0.45\linewidth]{example-image}
\end{document}

The class remains in draft mode, but the image is rendered. Draft mode can still provide other layout aids, such as marking overfull lines, depending on the class and packages in use.

Show one image while leaving others in draft mode

If only a particular figure needs to appear, set the key on that command:

\includegraphics[draft=false,width=0.6\linewidth]{photo.jpg}

This lets other \includegraphics commands continue to use the current draft setting. The order of the options does not affect the result.

Find where draft mode comes from

Check the document’s preamble for settings such as:

\documentclass[draft]{article}

or:

\usepackage[draft]{graphicx}

If you do not need draft behavior at all, remove draft or replace it with final at the setting that introduced it. If you do want to keep draft behavior elsewhere, use draft=false as shown above instead.

Packages for revision or change tracking are separate from image rendering in graphicx. If you use a package such as trackchanges, check the document class and graphics-package options first; a draft option may be affecting images independently of the change markup.

Common mistakes

  • Changing only the class option: Removing draft from the class can affect other draft behavior. Use the graphics key if you want to retain that behavior.
  • Setting the override too early: Place \setkeys{Gin}{draft=false} after \usepackage{graphicx} so the graphics keys are defined.
  • Assuming every blank image is caused by draft mode: If the image still does not appear, check that the file exists, the filename and path are correct, and the compiler supports the image format. Draft mode is only one possible cause.
  • Using the wrong image option: draft=false belongs in the optional argument to \includegraphics, or in the global Gin settings. It is not a replacement for the image filename or format.

References

  1. The graphicx package

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.