tech,

# LaTeX Tips and Tricks

Mahesh Aug 17, 2012 · 8 mins read

There seem to be quite a few techniques to embed the fonts while generating PDFs from LaTeX sources, and I just wanted to collate a few in one post. Further, I wanted to share my complicated workflow in creating vector graphics. Let me know if you have better solutions (in the past I have use inkscape with ‘limited’ success: some dots simply disappeared in Mac’s preview).

## Embedding Fonts

#### If you are using pdflatex:

If you have all your figures in PDF and you prefer using pdflatex, then you may want to follow this link.

Update: Most of the time I just use pdf images and so I end up using pdflatex. Pdflatex is not only convenient, I think its recommended. I recently stumbled upon this eternal problem of running into non embedded fonts. This time I could quickly point my fingers towards a few pdf plots generated using Matlab. Thanks to Kimo, I was able to fix the problem quickly. All I had to do was to run the following

I believe ps2pdf14 is equivalent to ps2pdf -dCompatibilityLevel=1.4 (just a guess), and this should also help prevent the error “Acrobat version is less than 5.0” that you might get on IEEE PDF eXpress. [Note that earlier I had ps2pdf13 used, and I had this issue].

I made a handy script to fix all the figures.

If all your images now have embedded fonts, then you should be able to generate an impeccable pdf with all fonts embedded, unless the universe decides against you (which happens quite often with me).

#### If you are prefer the long way:

If you have eps figs or may be pstricks based code for image, then you may want to do latex -> dvi -> ps -> pdf. In that case, I do this:

You will end up with filename.pdf which should have all the fonts embedded.

If you have an EPS image which you want to convert to PDF while making sure the fonts are embedded, you can try

Credit: Joey

Yet another way would be to embed the EPS figure in an article tex file and then compile the above way to generate a PDF. Now you will be stuck with a letter size PDF image, which you can crop (see below).

## Generating Vector Graphics

I generally use this awesome program called LatexDraw which is great except that it gave me a little bit of a headache for about 4 hours because the PDFs I was creating did not have all fonts embedded. Its not always like that, so I do recommend it highly. I tried xfig and it looked it got teleported from 1995.

Install it, and start drawing the block diagram you need. Its quite straight forward. Its cool to see the code getting updated as you draw. In fact you if you can type formulae between $and$. They will get compiled to the correct formulae, but you may have to try several times to get the position right.

Once you are happy and smiling, copy the generated code (they even have a button to do that!), and get ready for some hard work.

Again, you have two options. I like covering these images to PDFs and then embed it in my paper and run pdflatex. Instead, if you are going the long way of running latex->dvi->ps->pdf, then you all you may need to do is to copy paste the code. If you want it as a figure and want to add captions, just surround by figure:

There may be a number of reasons you may not want to do this. May be your mac is complaining that pstricks is not found, in which case I am not sure what to do. I have access to a linux machine which doesn’t complain. But since my pdflatex (in both mac/linux), I use the linux machine to generate the PDF the long way (also an EPS will be nice to have right?).

So fire up your latex editor and create a fresh file, like below.

If for any reason minimal does not work, try article class.

Do the following again:

Keep making sure that the generated PDFs have all the fonts embedded.

NOTE: IF YOU USE DOTS IN LATEXDRAW, IT WILL CREATE CORRESPONDING PSDOTS COMMANDS. THIS SEEMS TO CREATE TYPE-3 FONTS WHICH DON’T GET EMBEDDED. MY SUGGESTION IS TO NOT USE DOTS, BUT JUST USE CIRCLES. Figuring this out took like 4 hours only.

The output will look like this:

but of course in a pdf file. Again make sure it has all fonts embedded.

Next course of action is to crop this pdf. There is a handy tool called pdfcrop by Heiko Oberdiek, which might be already installed in your system, otherwise get it from here

I generally create a folder called helper and put the pdfcrop.pl file and also the following file

You can just run

Make sure not to give the extension (.tex).

Now you will end up with a PDF that you can just embed as usual.

Also, if you want to get EPS file, you can do the following:

If you directly want EPS files, save and use the following script

You should be all set to go.

## Force letter dimensions.

I was writing a one page document in latex and found out that it wasn’t really generating 8.5in by 11in document. So I ended up using:

You can play with the numbers and see what uncommenting other parts does.

Thats all folks. Happy latexing!