Posts Tagged ‘pdflatex’

Convincing LatexIt and Illustrator to use the new SIGGRAPH fonts

Saturday, May 20th, 2017

The SIGGRAPH Latex style changed to the Libertine font. Here’re the steps to convince Latexit to use the new stylesheet and then to convince Illustrator to use the libertine font for drag and drop math.

mkdir ~/Library/texmf/tex/latex/local/acmart.cls/
cp ~/Dropbox/boundary/Paper/acmart.cls ~/Library/texmf/tex/latex/local/acmart.cls

In Latexit, open up Preferences, add a new SIGGRAPH “Template” containing:

\documentclass[sigconf, review]{acmart}

If you try to drag and drop these into illustrator you’ll see that illustrator has replaced the nice math font with Myriad or something silly.

Download the TTF libertine font pack

Drag this into

cp /usr/local/texlive/2015/texmf-dist/fonts/type1/public/libertine/*.pfb ~/Library/Application\ Support/Adobe/Fonts/

Update: I also had to issue:

cp /usr/local/texlive/2015/texmf-dist/fonts/type1/public/txfonts/*.pfb ~/Library/Application\ Support/Adobe/Fonts/
cp /usr/local/texlive/2015/texmf-dist/fonts/type1/public//newtx/*.pfb  ~/Library/Application\ Support/Adobe/Fonts/

If you see boxes with X’s replacing symbols after dragging and dropping from LaTeXit, then drag into Finder instead (to create a .pdf file), then open this directly and Illustrator will give a warning and tell you which font it’s (still) missing.

Restart Adobe Illustrator

Make the most recent tex document in the current directory and open it

Wednesday, January 13th, 2016

Here’s a little bash script to compile (pdflatex, bitex, 2*pdflatex,etc.) the most recent .tex file in your current directory that contains begin{document} (i.e. the main document):

if [ -z "$LMAKEFILE" ]; then
  echo "Error: didn't find LMAKEFILE environment variable"
  exit 1
TEX=$( \
  grep -Il1dskip "begin{document}" *.tex | \
  xargs stat -f "%m %N" | \
  sort -r | \
  head -n 1 | \
  sed -e "s/^[^ ]* //")
if [ -z "$TEX" ]; then
  echo "Error: Didn't find begin{document} in any .tex files"
  exit 1
make -f $LMAKEFILE $BASE && open $BASE.pdf

Simply use it:


Emoji in LaTeX documents

Tuesday, August 5th, 2014

Update: Hilariously, it turns out that either wordpress or my wordpress markdown plugin is choking on the emoji inserted into this post. Thus, to see the actually emoji commands see this plaintext version

We were recently joking around about using emoji in math equations. The idea was to satire of the bad rap exterior calculus symbols like the the Hodge star operator (★) and the “musical isomorphisms” (♭,♯) get in the computer graphics community.

I found a solution for upTeX. This works by first extracting all of the emojis as pdfs and then including the pdfs via (includegraphics) whenever a \coloremoji{...} command is found. This unfortunately did not work with my TexLive pdflatex setup. With some help, I’ve redesigned a coloremoji.sty stylesheet that allows you to directly include emoji in your LaTeX documents.

A Hello, EmojiWorld LaTeX document would look like this:

WordPress dies on emoji, see plaintext version

This produces something that should look like:

hello world emoji

You can also use emoji in mathmode:

WordPress dies on emoji, see plaintext version

alligator power integral math emoji latex

Download the coloremoji package and simply add \usepackage{coloremoji} to the top of your document.

Actually, Nobuyuki Umetani gave a talk where he used graphic icons in math (I believe successfully!) to explain Sensitive Couture (change in clothing with respect to change in mouse interaction):

Nobuyuki's emoji math

Update: I’m now hosting this style package on github.

Tricking latexmk into using -draftmode

Thursday, June 12th, 2014

A friend recently showed me latexmk, an alternative to my current setup of using make to compile complicated tex documents (calling bibtex and pdflatex). Latexmk seems cool because it’s really tracking all the dependencies and not just recompiling everything. However, it seems to always run pdflatex in “final draft” mode, even for early passes which might as well use the -draftmode option. On my thesis (218 page document with figures on roughly every other page), this meant latexmk took 50s and my makefile routine took 23s (assuming a cold start).

I guess the sad answer is that it’s impossible to know if the current run of pdflatex should be the last (and hence should not be using -draftmode). So I guess latexmk plays it safe and runs everything without -draftmode.

My makefile assumes that I only ever need 3 passes, which I guess is pretty common but by no means universal.

I came up with gnarly alternative, which almost needs a makefile itsel:

latexmk -f -pdf -pdflatex="touch thesis.pdf && pdflatex -draftmode" thesis.tex && rm thesis.pdf && latexmk -pdf thesis.tex

First it runs latexmk forcing pdflatex to use -draftmode, but also always touching the pdf so latexmk is convinced that it succeeded in making its targets, then before running a final pass with latexmk I need to remove the pdf so that latexmk thinks there’s something to do. Draftmode passes cost very little so this also runs at about 24s on my thesis.

Wonder if there’s a cleaner way. Especially if thesis.pdf could be inferred nicely from thesis.tex (I guess using basename) and whether I can safely wrap this into an alias:

alias latexmk="..."

Update: Here’s a better version, my friend came up with. It still needs the tex filename twice, but at least it’s using substitution in the pdflatex “command” and the -g option forces latexmk to run at least once.

latexmk -f -pdf -pdflatex='pdflatex -draftmode %O %S && touch %D' thesis && latexmk -pdf -g thesis

Monday, May 26th, 2014

I’ve run into this issue before, when using the siggraph latex template. I get an error:

! Undefined control sequence.
<argument> \citename 

It’s tricky to track down. It seems the problem is that the siggraph style is defining cite but then it’s getting wiped out but an included package. In my case I need to remove an unneeded:


Then the problem went away.

Arbitrarily preprocess a .tex file

Tuesday, August 27th, 2013

Here’s a rather magical two lines you can place at the top of your (single-file) latex file to preprocess it with and arbitrary stdin-stdout script (call your script

\input{|"cat \jobname.tex| sed -n '/^__END__/,$ p' | sed '1 d' | ./"}

So for example let’s say your tex file is:

\input{|"cat \jobname.tex| sed -n '/^__END__/,$ p' | sed '1 d' |                                          
sed 's/[Cc]ensor[A-z]*/XXXX/g'"}                                                                          
Censor words starting with censor.                                                                        

Then the output will be

Output of censoring latex with preprocessing script

Note: If you’re using pdflatex you need to enable shell scripts by adding the --shell-escape argument.

Postprocess bad transparency pdfs from pdflatex using inkscape

Friday, August 23rd, 2013

I’ve recently renewed my frustration with pdflatex when trying to include pdfs I’ve created in Illustrator with transparency. I finally have a “solution”. Save the following in a file called

if [ $# -eq 0 ]
    echo "Usage:"
    echo "  fixpdftransp input.pdf output.pdf"
    return 1

# This is known to work with:
# Included pdfs of compatibility >1.4 
# Inkscape version 0.48.2 r9819 (Jul 15 2011)

# This is known not to work with:
# Included pdfs of compatibility 1.3
# Inkscape r9886 (Aug 23 2013)


NUM_PAGES=`pdfinfo $1 | grep Pages: | sed -e "s/ *Pages: *//g"`
for i in $(seq 1 ${NUM_PAGES})
  PAGE_NAME_IN=`printf $FORMATIN $i`
  pdftk $1 cat $i output $PAGE_NAME_IN
  echo "Creating $PAGE_NAME_IN"
  echo "$INKSCAPE $PAGE_NAME_IN --export-pdf=$PAGE_NAME_OUT"
pdftk $LIST cat output $2

Notice you need a specific version of inkscape. I’m using whatever you download from their site today. Notably, this does not work with the inkscape from macports.

Save your included pdfs as PDF 1.4 or higher. Use pdflatex to create a bad pdf and run this on your bad pdf:

./ bad.pdf good.pdf

Update: Though this works on simple pdfs, inkscape seems to screw with the fonts and other images a lot. So, unfortunately resulting pdf is probably not usable.

Transparent gradients in included pdfs using pdflatex lost by

Thursday, August 22nd, 2013

I’m running into this issue again. pdflatex on mac os x installed using macports via texlive somehow garbles pdfs with transparent gradients so that they don’t view correctly with The original PDF looks correct with my linear gradient fails with pdflatex on mac with preview

Try compiling a small test document:

\pdfpageattr {/Group << /S /Transparency /I true /CS /DeviceRGB>>}

For me the middle image doesn’t show up correctly. Of course the jpg does, but it’s pure raster. The last image is a pdf, but it’s a hacky solution. If you save your pdf with linear gradients in Illustrator as Compatibility: Acrobat 4 (PDF 1.3) then Illustrator will raster your transparency. It does a halfway decent job and it seems that the pdf is forward compatible: you can still edit it in Illustrator as vector graphics.

Preview crashes when reopening PDFs created with LaTeX

Sunday, March 17th, 2013

To typeset documents I use pdflatex. I edit my tex files using vim and build the pdfs using a makefile. At the end of my make sequence I like to have:

open my.pdf

Which on my mac causes preview to open my pdf document.

When I recompile and this command runs, sometimes preview just focuses the already open document, but other times it opens a new window. I haven’t backwards engineered how it decides which to do, but it might be correlated with the amount of change in between. In any case, Preview recently has been crashing when it tries to open the same document in a new window. For small, short-term articles this is not so annoying. But now, writing my t****s, I’m really getting frustrated.

I wrote an applescript to replace the open command above. First you’ll need to enable applescript for Then you can save the following in preview.scpt.

on run argv
	set file_name to item 1 of argv
		tell application "Preview"
			set open_already to false
			repeat with this_doc in every document
				set open_already to open_already or (name of this_doc as string is equal to file_name)
				if open_already then
					return "open already"
				end if
			end repeat
			if not open_already then
				open (do shell script "pwd") & "/" & file_name
				return ""
			end if
		end tell
	on error errMsg
		return errMsg
	end try
end run

You can run with:

osascript preview.scpt my.pdf

The rerun to see that no action is taken.

Unsorted (sort according to citation order) acmsiggraph.bst bibtex bibliography

Tuesday, August 21st, 2012

Open acmsiggraph.bst and simply comment out the sort line. So that