Graphics, Figures & Tablesexporting a figure into .ps/.pdf

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
etranger
Posts: 1
Joined: Thu Aug 27, 2009 12:36 pm

exporting a figure into .ps/.pdf

Post by etranger »

Hi,

I've been having quite a frustrating problem, I wish to output a graph I have drawn with tikz, and I want the output to be just the size of the graph, instead I keep getting an A4/letter sized output. I thought the \beginpgfgraphicnamed and \endpgfgraphicnamed, were precisely there to delineate exactly what was to be included in the output, preventing the output of an entire page.

Thanks in advance for any help with this problem.

Here is the code I'm executing:

Code: Select all

\documentclass{article}
\usepackage{amsmath,tikz}
\usepackage{graphics}
\long\def\beginpgfgraphicnamed#1#2\endpgfgraphicnamed{\includegraphics{#1}}
\begin{document}
\pgfrealjobname{7-rotations}
\begin{figure}
\centering
\beginpgfgraphicnamed{7-rotations}
\begin{tikzpicture}
	\node [style={draw,circle}](1) at (-0.5,1) {};
	\node [style={draw,circle}] (2) at (0.5,1) {};
	\node [style={draw,circle}] (3) at (1,0.5) {};
	\node [style={draw,circle}] (4) at (1,-0.5) {};
	\node [style={draw,circle}] (5) at (0.5,-1) {};
	\node [style={draw,circle}] (6) at (-0.5,-1) {};
	\node [style={draw,circle}] (7) at (-1,-0.5) {};
	\node [style={draw,circle}] (8) at (-1,0.5) {};
	\node (9) at (-0.5, 1.5) {};
	\node (10) at (0.5, 1.5) {};
	
	\path[->] (9) edge [above, bend left] (10);
	
	\path[-] (1) edge (2)
								edge (8)
						(2)	edge (3)
						(3) edge (4)
						(4) edge (5)
						(5) edge (6)
						(6) edge (7)
						(7) edge (8);	
					
\end{tikzpicture}
\caption{rotations $\times$ 7}
\endpgfgraphicnamed
\end{figure}
\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

kaiserkarl13
Posts: 707
Joined: Tue Mar 25, 2008 5:02 pm

Re: exporting a figure into .ps/.pdf

Post by kaiserkarl13 »

You probably are getting the right size figure, but it's putting on a letter-sized page (therefore your output is letter paper). If the graphic is literally delineated by the ink (no padding whitespace around it), then you can use ps2epsi to convert the .ps file to a .eps file and then (if you need the PDF) epstopdf to get the PDF. You'll have to specify \pagestyle{empty} to make sure LaTeX doesn't put a page number on the bottom, otherwise you'll get an image that contains your graph plus the page number (way at the bottom of the page).

I do this frequently when I have an EPS file and I want to add overlaid text or symbols on it; just include the EPS/PDF file with \includegraphics and use the picture environment to put the text in place. Then issue latex {}.tex && dvips {}.dvi && ps2epsi {}.ps {}.eps && epstopdf {}.eps and you've got a new EPS/PDF image called {}.eps and {}.pdf with your overlaid text in place.

If there IS padding whitespace, you'll have to mess around with setting an alternate paper size (which is harder to do). You'll still need \pagestyle{empty}, though.
Post Reply