Loading images in LaTeX
I'm in a documen开发者_开发技巧tclass in LaTeX. How do I load an image saved as a .png file?
If you work with pdflatex
(direct compilation to pdf), you can use the graphicx
package using the \includegraphics
command. If your image is called foo.png
, you can add the following command inside your document.
\includegraphics{foo}
However, if you work with latex
(compilation into dvi first), you cannot use 'png' file as image (with any package). You have to convert your image into 'eps' first. If your image is called foo.png
, then you can convert it with any graphics software into foo.eps
, and use the following command to include the image.
\includegraphics{foo}
Here is a complete example with width specification:
\documentclass{article}
\usepackage{graphicx}
\begin{document}
Here is my image.
\includegraphics[width=\textwidth]{foo}
\end{document}
Use the graphicx
package (included in most LaTeX distributions), which lets you:
\includegraphics[width=3in]{foo.png}
See an example page to get you started.
I am not using pdflatex. On Ubuntu, I use the convert
command, that comes with imagemagick, to convert from .png to .eps, and then use includegraphics
.
精彩评论