Chinaunix首页 | 论坛 | 博客
  • 博客访问: 112206
  • 博文数量: 22
  • 博客积分: 1611
  • 博客等级: 上尉
  • 技术积分: 180
  • 用 户 组: 普通用户
  • 注册时间: 2010-08-04 21:29
文章分类

全部博文(22)

文章存档

2015年(2)

2014年(1)

2012年(2)

2011年(6)

2010年(11)

我的朋友

分类:

2011-01-28 00:44:10

Graphics inclusion

Contents

 []

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,  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-output latex with pdf-output
eps pdf,jpg,png,mps

See 

epstopf: including eps-graphics in a pdfLaTeX-document

The  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  for more details on the inner-workings of the package.

support for other image-formats

The  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 . 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 .

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日编辑了该文章文章。
-->
阅读(7239) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~