12

I would like to have a vector graphic with the font I'm using for my captions in my PDF file.

I normally create my graphics in DIA and save them as .eps files. In my .tex file I use following

\usepackage{ifpdf}
\usepackage{graphicx, epstopdf}
\ifpdf
  \DeclareGraphicsExtensions{.pdf,.jpg,.png}
\else
  \DeclareGraphicsExtensions{.eps}
\fi

and

\includegraphics[width=\linewidth]{my_image.eps}

to include images (and auto generate PDF files).

I'm using Windows 7 (64-bit), miktex 2.9 and pdflatex

2
  • 1
    Welcome to tex.sx. So you want to replace the fonts in your vector graphic (which contains text) with the font used in you LaTeX file, especially the one used for captions? At the moment your question is a little difficult to read. Mar 8, 2011 at 10:43
  • yeah, that's what i'm trying to do.
    – Malone
    Mar 8, 2011 at 10:57

3 Answers 3

9

Normally, it won't be possible to have the font changed if you create your diagram outside of TeX (not an issue for inline-generated diagrams using TikZ, for example).

That being said, you have a few options, in no particular order:

  • Check whether the font you use have an OTF version that you can install at the OS-level (for example, Computer Modern has here). Then, just pick that when you create your figure, and you are good to go.

    Pros: Minimal change in your current workflow.

    Cons: If your favourite font does not have OS-compatible version, this doesn't help at all.

  • Recreate your diagrams inline, using a package such as TikZ or PStricks (they should be easily installed as part of your TeX distribution).

    Pros: Your diagrams will be rendered perfectly and you'll have all the flexibility you need typesetting the text in them. In the long term, learning a diagramming package like these will serve you well later on.

    Cons: The steeping curve learning can be quite steep, and for one-off diagrams it's not worth it.

  • Mixed approach: Create your diagrams in Inkscape, and export them as EPS+TeX, or PDF+TeX (see here for more information). Your diagram is created in the WYSIWYG interface (and Inkscape is pretty powerful vector graphics package), and on export a .tex file is created that you include in your document directly instead of doing \includegraphics on the EPS/PDF. The TeX file that is created bootstraps the inclusion of the graphics, and ensures that the text appears in the right place.

    Pros: Minimal disruption to your workflow, no dependence on what font you use in your document.

    Cons: As of this writing, the exporting procedure is somewhat of a hit-and-miss. Your diagram might not appear exactly in the way you want it. Be sure to perform some tests to see whether this works for you.

4
  • Nice answer. Do you know how to use a OTF font with dia under e.g. Ubuntu Linux (or Visio under MS Windows)? I couldn't find anything using a quick search. Mar 8, 2011 at 11:14
  • 1
    Okay, I have found out that Dia also has a PGF and and PSTricks export function. I have tried the PGF export function and it works. I have problems now with the size but I think that I have to do some searching or create a new question. Thanks for the help
    – Malone
    Mar 8, 2011 at 11:55
  • @Martin: In Windows: just copy the OTF file(s) to Windows\Fonts, and then any application you have installed can use them. Unfortunately, there's no way to combine the different shapes and weights into a single typeface, so you might have to install a few versions of the same font. On Ubuntu, this might help: maestric.com/doc/ubuntu/install_otf_font (I have never installed OTF fonts on Ubuntu, so I don't know if that would work). Mar 8, 2011 at 11:55
  • 1
    "just copy" has a lurking trick. You have to do the copy through the shell (windows explorer) for the fonts set up properly. Copying them over with a command-line utility for example won't work.
    – Lev Bishop
    Mar 8, 2011 at 14:54
7

Have a look at psfrag and related packages. With the \psfrag command, you can replace text in an eps graphic with LaTeX text and equations. You have to replace each different piece of text individually, so it can be tedious if you have a lot of labels. Also, getting it to work with pdflatex is awkward (see this question), but you can always use LaTeX + dvips + ps2pdf instead.

3

To do this you will need to edit the eps file, and TeX doesn't do that. The only thing TeX does when it encounters \includegraphics{my_file.eps} is read the file to determine what size box to reserve. The graphic is inserted by a separate process.

Either use Dia to include the right fonts, or create the diagrams in TeX (for instance with TikZ or PSTricks. See also questions tagged and .

Edit I forgot about psfrag and psfragx. It's a way to make substitutions in the eps file. It might do what you want though it may require you to retype all the text.

2
  • I'll have a look into TiKZ or PSTricks. Do they have something like pre-made "shapes" like (desktop, server) computers?
    – Malone
    Mar 8, 2011 at 11:00
  • Yes, they have pre-made "shapes" but more like rectangles and clouds than desktops and servers. But you can include other vector graphics in your tikzpictures Mar 8, 2011 at 11:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .