I need to include some graphs from a datasheet in my document, but of course I don't have the source files. What would be the best course of action? It's mostly logarithmic scale graphs.

  • 5
    Hi, it would help if you could minimise the work people have to do if they want to help you. For example, we don't know what kind of datasheets you're using, what OS you're using, what kind of output you're looking for (ps, pdf, ...), and so on. – user10274 Jan 10 '12 at 15:09

Alternatively you could extract the data from the graph and then recreate it in your own style. There are several programs available that digitize graphs (e.g. http://digitizer.sourceforge.net/) and in the end this is often the much nicer than a copy&paste and also avoids copyright issues.

  • Yes. This enables you to apply a consistent style across all the data you ripped off from different sources. I prefer another digitizing program (see `plotdigitizer.sourceforge.net); the one mentioned above gave me some random crashes. – Michael Palmer Jan 10 '12 at 22:20


\includegraphics[page=...,viewport=llx lly urx ury,clip]{pdf-file}

or run

pdfimages [options] <PDF-file> <image-root>

the first one simply inserts the page=<no> of your pdf and clips everything around the viewport. The second one is a Linux command, which extracts all images from a pdf file, eg

pdfimages -f1 -l4 <PDF-file> .

extracts the images of pages 1--4 into the current directory

  • +1: probably worth mentioning that \includegraphics is from the graphicx package – cmhughes Jan 10 '12 at 17:20
  • 1
    no, \includegraphics is from graphics, only the optional arguments need graphicx ... ;-) – user2478 Jan 10 '12 at 17:42
  • 3
    Note that pdfimages will extract only bitmap graphics. If the graphic is a line drawing, such as a cartoon or plot, pdfimages will not find it. Also note that by default pdfimages writes ppm files. You can give it a -j option to make it save jpeg files instead. – Michael Palmer Jan 10 '12 at 22:17
  • @MichaelPalmer, Is there any way to extract line drawings from a pdf file? – Hongying Jun 3 '13 at 12:19
  • pdfimages expects a raster image. If the "image" is actually a bit of vector art---pdfimages won't help, in which inkscape or krop (or one of its alternatives) can be used instead. – Jared Kulik Jul 26 '15 at 18:22

I will assume that you are using OS X with TeXShop and that your original file is in pdf format.

A manual solution that works if there aren't too many images to copy is as follows.

TeXShop's pdf viewer allows you to copy part of a page or image. It works even for pdf files that don't come from a tex file. All you have to do is select the region you want copied with the rectangle selection tool and drag the image to your desktop (or other folder). In TeXShop's preference pane you can select the format of the copied image (pdf, png, etc.)

Maybe other pdf viewers behave like this but since I don't use them I don't know.

  • This answer is gold. – GiuTeX Jun 15 '18 at 19:28

In Linux (Mint 17) a (semiautomatic) trick that worked for me is, first extract the page with the desired vector figure using pdftk:

 pdftk book.pdf cat 51 output page.pdf

in this case, the page 51 from the file book.pdf is extracted into the file page.pdf .

Then using Inkscape, it is possible to open the file page.pdf, select the figure, copy and paste it in a new window, then save it as a new pdf (as a vector image), ready to be included in LaTeX!


Alternatively, it is possible to use a PDF printer in order to print a current view in a PDF file and use a paper format that corresponds to the dimensions. In this way, vector graphics are preserved. This is kind of a dirty trick, but it works for me...


One way to extract data if it is available in the PDF as vector graphics is to use Adobe Acrobat:

  1. Enter editing mode by using the tool "Edit PDF" under Tools.
  2. Select all the points/shapes/markers you want to copy
  3. Select "Edit Using..." in the right sidebar and select your text editor Objects panel
  4. The coordinates of the markers should be available in the text (in centimeters most probably), so find out the format of one marker and extract all the coordinates. Regular expressions can help.
  5. Scale and convert the coordinates into the original values by comparing points to the actual axes in the graph.
  • 1
    Welcome to TeX.SE! – Mensch Mar 14 '19 at 16:28

I use Adobe Acrobat to select regions and save images to .bmp. Then I convert them to .eps with a sam2p utility, using .bat file for batch processing.

sam2p project on google code

.bat file code:

REM Created by M.M.J. Jorritsma. 2011-09-21, Enschede, The Netherlands
@SET /P INPUT=[Type the extension of the images to be batch-converted. example: jpg]
@SET /P OUTPUT=[Type the extension of the target image format. example: eps]
@ECHO Now converting from "%INPUT%" to "%OUTPUT%".
@SET /P CONTINUE=[Continue? [Y/N]]
@if /I %CONTINUE%==Y (
    @for /R %%i In (*.%INPUT%) DO @(
    @echo sam2p %%~ni.%INPUT% %%~ni.%OUTPUT%
    sam2p %%~ni.%INPUT% %%~ni.%OUTPUT%
  • 2
    This is potentially messy. If the image you're copying, which is likely to be a vector graphic if it is a plot, is saved to bitmap before putting it into an eps container then the resultant eps is not a vector graphic. This typically results in low quality images (looks bad) or large files (pdf readers may get choppy when you scroll and the document that it is put in will be large). In short, one should avoid turning a vector graphic into a raster graphic if it is to be placed in another vector graphic later. – qubyte Jan 10 '12 at 15:54
  • Thanks for comment, @MarkS.Everitt! Haven't thought about it. In my case there were raster images. – labramov Jan 10 '12 at 16:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.