在LaTeX中加载图片

8

我正在使用LaTeX的documentclass。如何加载保存为.png文件的图像?

3个回答

17

如果您使用pdflatex(直接编译为PDF),则可以使用graphicx包使用\includegraphics命令。如果您的图像名为foo.png,则可以在文档内添加以下命令。

\includegraphics{foo}

然而,如果您使用latex(首先编译为dvi),则无法使用'png'文件作为图像(使用任何软件包)。 您必须先将图像转换为'eps'。 如果您的图像名为foo.png,则可以使用任何图形软件将其转换为foo.eps,并使用以下命令将图像包含在其中。

\includegraphics{foo}

这里是一个带宽度规范的完整示例:

\documentclass{article}
\usepackage{graphicx}

\begin{document}
Here is my image.
\includegraphics[width=\textwidth]{foo}
\end{document}

10

使用graphicx包(包含于大多数LaTeX发行版中),它可以让你实现以下功能:

\includegraphics[width=3in]{foo.png}

请看示例页面以便入门。


2

我没有使用pdflatex。在Ubuntu上,我使用随imagemagick一起提供的convert命令将.png转换为.eps,然后使用includegraphics


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接