Archive

Posts Tagged ‘latex’

Embed Fonts in PDFs

February 3, 2015 Leave a comment

It is typical of IEEE/ACM conferences to ask for pdf files with embedded fonts. When the submission deadline is fast approaching, it is an unpleasant experience to see a prompt saying that the submission does not meet the requirement of embedded fonts.

Until 2014, pdflatex (as part of MacTeX) was configured not to embed fonts by default. There is a simple solution to this problem. Run the following commands and any pdf generated with pdflatex will have fonts embed in them.

$ updmap --setoption pdftexDownloadBase14 true
$ updmap

pdffonts is a nifty tool, which can be used to list the fonts embedded in a pdf document. Below is a log of the outputs before and after I changed the configuration.

$ pdffonts test.pdf                                                                                                        
name                                 type              emb sub uni object ID
------------------------------------ ----------------- --- --- --- ---------
PQJFKD+CMR17                         Type 1            yes yes no       4  0
OIKBLN+CMR12                         Type 1            yes yes no       5  0
VDNHSL+CMR10                         Type 1            yes yes no       6  0
Times-Roman                          Type 1            no  no  no       7  0
Helvetica                            Type 1            no  no  no       8  0
Courier                              Type 1            no  no  no       9  0
IAPCTB+URWPalladioL-Roma             Type 1            yes yes no      10  0
IQSCJF+URWChanceryL-MediItal         Type 1            yes yes no      11  0
ZINFER+CenturySchL-Roma              Type 1            yes yes no      12  0
SXEYYX+URWBookmanL-Ligh              Type 1            yes yes no      13  0

$ updmap --setoption pdftexDownloadBase14 true
$ updmap
...

$ pdffonts test.pdf                                                                                                        
name                                 type              emb sub uni object ID
------------------------------------ ----------------- --- --- --- ---------
PQJFKD+CMR17                         Type 1            yes yes no       4  0
OIKBLN+CMR12                         Type 1            yes yes no       5  0
VDNHSL+CMR10                         Type 1            yes yes no       6  0
RFZQJL+NimbusRomNo9L-Regu            Type 1            yes yes no       7  0
KRXWNA+NimbusSanL-Regu               Type 1            yes yes no       8  0
IJPKSY+NimbusMonL-Regu               Type 1            yes yes no       9  0
IAPCTB+URWPalladioL-Roma             Type 1            yes yes no      10  0
IQSCJF+URWChanceryL-MediItal         Type 1            yes yes no      11  0
ZINFER+CenturySchL-Roma              Type 1            yes yes no      12  0
SXEYYX+URWBookmanL-Ligh              Type 1            yes yes no      13  0

We can see that all the fonts are embedded in the pdf.

pdffonts is available as part of xpdf. It is available as a Homebrew recipe and can be installed using the following command:

$ brew install xpdf
...

An alternate solution is to open the pdf file in Preview and export or print as a pdf. The resulting file will have embedded fonts.

If you have figures as eps files, then those files may not have embedded fonts as well. You can convert them to pdf while embedding fonts. (pdflatex will not embed fonts in figures that were created by other software.)

ps2pdf13 -dPDFSETTINGS=/prepress figure-without-fonts.eps figure-with-fonts.pdf
Categories: best practices Tags:

Using latexdiff to Highlight Revisions in a LaTeX Project

April 21, 2014 Leave a comment

Typically research papers are put together as LaTeX projects. I was under the impression that it is a challenge to keep a visual track of who made what changes; typically there are more than one authors on the paper and we try to learn from the experienced writers. But then I came across a useful tool, latexdiff, which opened the door for many possibilities.

What latexdiff does is that it highlights, in color, the differences between two LaTeX files. Consider a trivial example below. Latexdiff compares the two LaTeX files (original.tex and revised.tex) and generates a LaTeX file as output (diff.tex), which can then be compiled into pdf to view the output.

latexdiff original.tex revised.tex > diff.tex
pdflatex diff.tex

An example is shown below, where red color highlights the text that was deleted and blue color highlights the text that was added.

latexdiff example output

When collaborating, the LaTeX project includes multiple files that are pulled into the primary LaTeX file. This can be done using the flatten option.

latexdiff --flatten original.tex revised.tex > diff.tex

I’ll leave it to you to explore the documentation for other possibilities.

The tool can also be used along with version control systems (e.g., svn). Below is a crude bash script that pulls an old version from the svn repository and compares it to the version in your working directory.

#!/bin/bash 
# Version: 0.01
# Author:  Umar Kalim

if [ $# -ne 2 ] ; then
  echo "Usage: $0 <svn revision no.> <filename>"
  exit 1
fi

svn_revno=$1
filename=$2

mkdir tmp
echo "exporting svn repo $svn_revno"
svn export --force -r $svn_revno . tmp

echo "generating diff"
latexdiff --flatten tmp/$filename $filename > diff.tex

echo "compiling output with highlights"
pdflatex diff.tex

echo "cleanup"
rm -rf tmp
Categories: best practices Tags: