Visio figures in LaTeX

This is one way to use figures made in Microsoft Visio in your latex (pdfLatex) document.

The first step is to get the figure as a PDF file. If you are using Visio 2007 you may use the PDF add-in from Microsoft. Another option is using Adobe Acrobat or the free PDFCreator.

When printing, select the figure and in the print dialog select the option to only print the current selection.

The problem is that the figures will use a whole page even if they’re small. You may either crop it (using a tool like pdfcrop) or specify a viewport when including the figure in the document.

To find out the viewport variables, convert the PDF to PostScript using pdf2ps. Now check the beginning of the file for a line like this:

%%BoundingBox: 56 368 446 551

This is the viewport variables to use when including the figure in the latex document:

\includegraphics[viewport = 56 368 446 551]{figure.pdf}

Or include it in a figure with caption that may be referenced:

\begin{figure}
	\begin{center}
		\includegraphics[viewport = 56 368 446 551]{figure.pdf}
	\end{center}
	\caption{Figure caption here}
	\label{myfigure}
\end{figure}

It may be referenced to in the text using e.g. Please see figure ~\ref{figure} for details. The tilde is used as a non-breaking space to avoid unfortunate linebreaks.

See this page for more details working with figures in Latex.

One Comment

  1. granly says:

    Hi I have had similar problems with visio and the pdf created. There is another way to get rid of the default paper size.

    Go to File/Page setup

    Choose the “Page Size” tab and select “Size to fit drawing content”

    Now choose File/Publish as PDF or XPS. Here’s the catch: (or one of them) if you have more than one page in your Visio document, you will get all pages in your drawing with the default page size (A4 in my case). But choose “Options” in the Publish dialogue and select “Current page” in the options window.

    This does the trick for me.

    By the way I was inspired by this page: http://www.codestylist.org/wiki/ExportToPdf

    Where you can find a macro that will do the job for you. :o )

Leave a Reply