latex 插入图片与pdflatex

Graphics inclusion

Contents

  [hide]

basics

Including graphics in a LaTeX-document is done with a command like this:

\includegraphics{image.jpg}

where image.jpg is a graphic-file of the JPEG-type. It is assumemed that you have loaded the graphics-package in your preamble. There are variants of this command, for example

\includegraphics[width=0.8\textwidth]{image.jpg}

- see for other options, for example, here or the documentation of the graphics-package. While this is very easy, one needs to be aware that not all file types are supported.

supported file types

These are the file types that are supported, depending on the typesetting-mode you are using. As a Mac-User, you are most likely a user of (pdf)latex with pdf-output.

latex with dvi-outputlatex with pdf-output
epspdf,jpg,png,mps

See this article in the PracTeX Journal for more on this.

epstopf: including eps-graphics in a pdfLaTeX-document

The epstopf-package helps to overcome the limitations of latex and pdflatex when it comes to available graphic-formats. Its main purpose is to allow the inclusion of .eps-graphic in documents that are typeset in pdflatex (with a pdf as an output file). What the package does is that it calls an external script (with the same name: epstopdf) that converts a eps-graphic into a pdf such that pdflatex can use this. So, if you are using pdflatex, the following document would work:

\documentclass[11pt]{article}
\usepackage{graphicx}
\usepackage{epstopdf}
\begin{document}
\includegraphics[width=0.8\textwidth]{image.eps}
\end{document}  

It is essential for epstopdf to work that pdf(la)tex (with PDF output) is allowed to call external programs. Therefore a typical call to pdf(la)tex includes the option --shell-escape:

pdflatex --shell-escape --synctex=1

If you are using a recent version of epstopdf (at least 2009/07/16 v2.2), running the example above will result in a file image-epsf-converted-to.pdf in your working directory. See the documentation of epstopf for more details on the inner-workings of the package.

support for other image-formats

The epstopf-package offers also a very convenient way to add support for other graphic-types. For example, if you want to add support for .tif-files, you can add the following to your preamble (again, you need a recent version of epstopdf):

\usepackage{epstopdf}
\epstopdfDeclareGraphicsRule{.tif}{png}{.png}{%
convert #1 \OutputFile
}
\AppendGraphicsExtensions{.tif}

Whenever pdflatex finds a command

\includegraphics{image.tif}

it will try to convert it to an .png-file and use this. However, you need to have the command 'convert' to be available. It is availalable from ImageMagick, see Graphics_helpers#ImageMagick. If you are using the MacTeX-distribution, convert has been installed. ImageMagick can handle a lot of file types! So you can add support for almost any image-format by using epstopdf for a conversion to one of the #supported_file_types.

filenames and the list of known graphics-extensions

If pdflatex finds a command \includegraphics, it looks internally at íts list of supported file types. By default, this list is

.png,.pdf,.jpg,.mps,.jpeg,.PNG,.PDF,.JPG,.JPEG

This lists needs to altered if you add support for other file-types, hence the command \AppendGraphicsExtensions{.tif} in the example above that alters the internal list of supported file-types to

.png,.pdf,.jpg,.mps,.jpeg,.PNG,.PDF,.JPG,.JPEG,.tif

(There is also a command \PrependGraphicsExtensions that would put the new file type at the beginning of the list. Does the order make a difference? Consider you have several version of your a graphics-file in your working directory along with you .tex-document, for example

project.tex 
image.pdf
image.png
image.eps

If you include your image with a command

\includegraphics{image}

that is WITHOUT THE EXTENSION, the order of the internal list matters. If the list of supported file types is the default one, see above, it will be the image.png that is included in your final project.pdf. If you are using

\documentclass[11pt]{article}
\usepackage{graphicx}
\usepackage{epstopdf}

\epstopdfsetup{prepend}

\begin{document}
\includegraphics[width=0.8\textwidth]{image}
\end{document}  

the image.eps will be found first, converted to image-eps-converted-to.pdf (recent epstoopdf) or image.pdf may be overwritten by a newly converted one (older epstopdf), and this will be used. And so on - it can be rather complicated to determine which file is actually used depending on your configuration. Note that this is a problem if you a graphic file in an external program and then it turns out that you were working on a file that doesn't make into your final pdf!

If you include graphics WITH THE EXTENSION, like in

管理员在2009年8月13日编辑了该文章文章。
-->
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
阅读(2257) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~
评论热议
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值