Why an Image Does Not Show with natwidth and natheight
At a glance
- 1. Check the compiler
A DVI-to-PostScript workflow usually expects EPS files; natwidth and natheight do not add support for PNG or JPEG.
- 2. Use a supported format
For latex followed by dvips, use EPS. For PNG, JPEG, or PDF images, compile with a PDF-producing engine.
- 3. Set the display size
Use width or height to control the printed size. Use natwidth and natheight only to declare the image's natural dimensions.
The natwidth and natheight options describe an image’s assumed natural dimensions. They do not change its file format, convert it, or guarantee that the graphics driver can display it. So if the image vanishes in a DVI-to-PostScript build, check the compiler route and image format first.
What natwidth and natheight do
These options give the graphics system a natural width and height, typically when the driver cannot read those dimensions from the image. They can supply size information when it is unavailable, but they do not make an unsupported format readable or repair invalid image data; some drivers may still require suitable bounding-box information. The assumed natural size is the default included size if you do not apply scaling. To request a particular displayed size, use width or height:
\includegraphics[width=0.7\linewidth]{plot.eps}
If you set both width and height, LaTeX scales the image to those dimensions, which can distort its aspect ratio. Usually set just one dimension and let LaTeX preserve the ratio.
Match the image format to the compiler
The traditional DVI route is typically latex → DVI → dvips. In that workflow, EPS is the standard format for included graphics. PNG and JPEG files are not generally handled directly by classic dvips; adding natural dimensions does not make them readable. Some modern toolchains add conversion steps, but you should not assume those are available.
If your source image is PNG, JPEG, or PDF, use a PDF-producing engine such as pdflatex, xelatex, or lualatex. For example, save this as example.tex beside an image named photo.png, then run pdflatex example.tex:
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}[ht]
\centering
\includegraphics[width=0.7\linewidth]{photo.png}
\caption{An image included at 70 percent of the text width.}
\end{figure}
\end{document}
For a DVI-to-PostScript workflow, use an EPS file instead. This complete document can be compiled with latex, followed by dvips:
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}[ht]
\centering
\includegraphics[width=0.7\linewidth]{plot.eps}
\caption{An EPS image included in a DVI workflow.}
\end{figure}
\end{document}
The EPS file must exist and contain valid image data and bounding-box information. If you have a raster image, convert it to EPS for this route, or switch to a PDF-producing engine.
If the image still does not appear
Check these items in order:
- Confirm the output route. If you are using
latexand thendvips, do not assume that PNG, JPEG, or PDF input will work directly. - Check the file name and location. The image must be in the project directory or at a path given to
\includegraphics. Check capitalization on case-sensitive systems. - Inspect the EPS bounding box. A missing or invalid bounding box can prevent correct placement or cause errors.
natwidthandnatheightmay provide dimension information in some situations, but they are not a universal repair for malformed EPS files. - Read the build log. Messages such as “Unknown graphics extension” or “Cannot determine size of graphic” often indicate an unsupported format or missing size information. A blank box can also be caused by draft mode; check for the
draftoption on the document class orgraphicxpackage. - Check the output file you are viewing. In a multi-step build, confirm that you opened the newly generated PS or PDF rather than an older file.
Common mistakes
- Expecting natwidth and natheight to convert an image. They only supply assumed dimensions; conversion is a separate operation.
- Using them instead of width. Natural dimensions describe the image’s reference size. Use
widthorheightto control its displayed size. - Mixing compilation routes. A document that works with
pdflatexand a PNG may not work unchanged withlatexanddvips. - Setting dimensions without units. Write dimensions such as
640bp,10cm, or4in; a bare number is not a complete TeX dimension. - Ignoring the image’s aspect ratio. Prefer specifying only
widthor onlyheightunless you intentionally want to stretch the image.
References
Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.