It is possible to generate images using LaTeX commands[Drawing with TeX] (See the pgf/tikz package or The LaTeX Graphics Companion ) however most people find it easier to create a picture in some other application, and include that file into their LaTeX document.
PDFLaTeX can insert PDF, PNG and JPG image files into your
document. If your image file is in a different format, you may be
able to find an application to convert it. [Spawning programs
TeX-distributions can automatically convert EPS files to PDF during the LaTeX run using the Perl script
epstopdf. If your TeX-distribution doesn't support
this, you can convert your EPS file using epstopdf
explicitly. For example, if you have an EPS image called, say,
sample-image.eps, you can convert it to a PDF image called
sample-image.pdf, by using the following command in a
terminal or command prompt:
epstopdf sample-image.epsor (full path name may be required)
perl epstopdf sample-image.eps
To insert an image file into your document, you first need to specify that you want to use the graphicx package. So the following must go in the preamble:
The image can then be included in your document using the command
where <filename> is the name of your image file without the file extension[“Modern” graphics file names], and <key-val options> is a comma-separated list of options that can be used to change the way the image is displayed. Note that if you have an image where the file name contain spaces or multiple dots, you need to use the grffile package:
Suppose you had a file called shapes.pdf, then to include it in your document you would do:
which would produce:
You can specify a full or relative pathname, but you must use a forward slash / as the directory divider, even if you are using Windows. For example:
means the file pictures/shapes.pdf on Unix-type systems, and it means the file pictures\shapes.pdf on Windows.6.1 This is mainly because the backslash character is a LaTeX special character indicating a command, but it also helps portability between platforms.
You can specify the order of the file types to look for with the command
where <ext-list> is a comma-separated list of extensions. For example, you might want to search first for PDF files, then for PNG files, then for JPG files and finally for EPS files:
The optional argument <key-val options> should be a comma-separated list of <key>=<value> pairs. Common options are:
- rotate the image
by x degrees anticlockwise.
- scale the image so that the
width is <length>. (Remember to specify the
- scale the image so that the
height is <length>. (Remember to specify the
- Scale the image by <value>
- trim=<l> <b> <r> <t>
the amount to remove from each side. For example
- Don't actually print the image, just draw a
box of the same size and print the filename inside it.
This example first rotates the image by 45 degrees anticlockwise, then scales it so that the width is 1 inch.
Note that this isn't the same as scaling and then rotating:
You can also scale an image relative to the text area using the
example, to scale a portrait image so that its height is
three-quarters of the text area height, you can do:
or to scale a landscape image so that its width is half the text area width, you can do:
\includegraphics command is another form of box (see
§4.7. Boxes and Mini-Pages), and can be used in the middle of a line of
text, just like the tabular environment. See
§7.1. Figures to find out how to put the image in a
figure with a caption.
This book is also available as A4 PDF or 12.8cm x 9.6cm PDF or paperback (ISBN 978-1-909440-00-5).
Last modified: 2017-02-06.
The free resources on this site are funded by book sales, not by adverts. If you would like to help keep this site free of annoying third-party ads, please consider buying a book.