# How can I prevent pinlabel/postscript errors?

I would like to ask for help with an error caused by some interaction between the pinlabel package and (it seems) Adobe Illustrator CS2. I will describe the situation below; my question simply put is: what can I do to prevent this error from occurring? A similar situation was described before on this site, but did not contain a question. I hope my question is direct enough, and I appreciate any help that is offered.

My setup: Mac OS 10.7.5; TexShop 2.47; pinlabel.sty v 1.2; Adobe Illustrator CS6 (version 16.0).

The problem: When I use pinlabel with an eps file created by Illustrator, I get the error message

! Text line contains an invalid character.
^^@^^@XÊ^^F^^@^^@^^@^^@^^@^^@^^@^^@^^@xÊ^^F^^@B    ^^@^^@ˇˇ^^@...
l.165 \includegraphics{test}


Some remarks: If I simply hit return in response to the error message (or q for batch mode) then the file will eventually process. If I use pinlabel with an eps file created in another application, I have no problem. If I use the same graphics file without the pinlabel commands, there are again no error messages. So I assume that the issue is an interaction between some pinlabel commands and the eps file produced by Illustrator.

A sample LaTeX file that produces this error is reproduced below. There are 3 versions, showing the 3 behaviors referred to in the preceding paragraph. The eps files that are needed are in the directory http://people.brandeis.edu/~ruberman/pinquestion/ along with the LaTeX source and the log file from my session.

%%%%%%% Sample latex code %%%%%%%

\documentclass[11pt,reqno]{amsart}
\usepackage{amscd,graphicx}
\usepackage{pinlabel}

\newcommand{\M}{\mathcal M}

\begin{document}

\begin{figure}[h]
\begin{center}
\labellist
\normalsize\hair 0mm
\pinlabel {$\M(X,g_t,\beta_t)$} at 83 15
\endlabellist
\includegraphics{fig1}
\end{center}
\caption{The figure from another drawing program, with pinlabel commands}
\label{fig:param1}
\end{figure}

\begin{figure}[h]
\begin{center}
\includegraphics{param1}
\end{center}
\caption{The figure produced by Illustrator, without pinlabel commands}
\label{fig:param1}
\end{figure}

\begin{figure}[h]
\begin{center}
\labellist
\normalsize\hair 0mm
\pinlabel {$\M(X,g_t,\beta_t)$} at 83 15
\endlabellist
\includegraphics{param1}
\end{center}
\caption{The figure produced by Illustrator, with pinlabel commands}
\label{fig:param1}
\end{figure}

\end{document}

-
Welcome to TeX.sx! A tip: If you indent lines by 4 spaces or enclose words in backticks , they'll be marked as code, as can be seen in my edit. You can also highlight the code and click the "code" button (with "{}" on it). –  Torbjørn T. Jan 4 '13 at 19:11
Thanks for the tip(s); I'll try that next time. –  Danny Jan 4 '13 at 19:16

I communicated with the author of the pinlabel package, who gave me a couple of suggestions. The issue seems to be that the EPS file as produced by Illustrator has a lot of junk before the initial %!PS-Adobe-3.1 EPSF-3.0 and also after the %%EOF that is supposed to terminate the file. So one approach, which worked for me, is to open the EPS file in a text editor, and delete those initial and terminal strings. There is a perl script removepreview.pl that will remove the initial string, and presumably it could be modified to remove the characters after %%EOF. I didn't have any luck with this perl script, but that's a matter for another day.
A better approach, which I find more convenient, is to have Illustrator save the graphic as a PDF file, which can be incorporated using pdftex. The only trick here is that if you have the EPS file and the PDF file in the same directory, then pdftex` will actually use the EPS file instead of the PDF file, resulting in the same error. So if you want to keep that EPS file around for some reason, you need to change its name or hide it in some fashion.