# pdflatex “Command token too long” error

I am getting this error trying to compile a latex document using pdflatex. I've stripped the tex file down to this

\documentclass[letterpaper,oneside,12pt]{article}
\usepackage[letterpaper,textwidth=7.5in,textheight=9.5in]{geometry}
\usepackage{graphicx}

\begin{document}
\begin{figure}[H]
\includegraphics{figures/Jan25/svdDir_svdCompare1.pdf}
\end{figure}

\end{document}


This produces the final output I want but still gives that error which is hugely annoying because I use vim-latex and the error causes it to take me to another window which I then have to close out and switch back to the tex file every time I compile.

The pdf file was generated from a Matlab figure; a process which I do several times per day with no problem. I did try regenerating the file but it still gives that error. I've also tried copying it and renaming but that also doesn't change anything.

## migrated from stackoverflow.comJan 26 '12 at 11:57

This question came from our site for professional and enthusiast programmers.

• If the problem is the image, one would have to see (and inspect) it in order to assess what the problem might be. As is, with my own replacement image, your MWE compiles without problem. – Werner Jan 26 '12 at 6:47
• Which version of pdfTeX are you using on which OS? And please post the actual lines from the logfile. – Martin Schröder Jan 26 '12 at 13:15
• I'm getting this error too, and it is indeed really annoying. It goes to stderr instead of going to the same place all of pdflatex's other error output goes. Not only is that a lame thing for a library like poppler to do, but it also means that I can't tell where the error is occurring. I have several hundred PDFs in my document, and there is no way to tell which of them is causing the error. – Ben Crowell Mar 3 '12 at 16:56
• I've filed a bug: sarovar.org/tracker/… – Ben Crowell Mar 3 '12 at 17:14
• Ryan0270, can you supply the pdf file that causes the error so we can attach it to the bug report on sarovar.org? In my own case, I can't tell which of the hundreds of figures in my book is the one it's complaining about. – Ben Crowell Mar 3 '12 at 21:55

Most likely your included PDF is broken somehow. The only part in pdftex that throws this error message seems to be the Lexer in poppler when reading PDFs. Can you put up the PDF somewhere online for examination?

I had exactly the same issue on Debian Wheezy. Out of hundreds dynamically produced eps figures, there were some, which lead to the error

Command token too long


This is a known issue in the PDF rendering library poppler. Apparently, the error appears when the first object in the eps is not a stream, the error message itself can safely be ignored.

But when using the in , this cannot be done so easily. There is some facility to ignore errors in , but it didn't work for me.

The error message is removed from poppler in release 0.22, but the version I am using is still using release 0.19.

What fixed this issue for me in the end is to open the eps file in question with inkscape and save it again, without changing anything.

What size is your image? That PDF file may be bigger than the allowed width. Have you tried resizing image? For instance:

\documentclass[letterpaper,oneside,12pt]{article}
\usepackage[letterpaper,textwidth=7.5in,textheight=9.5in]{geometry}
\usepackage{graphicx}

\begin{document}
\begin{figure}[H]
\includegraphics[width=5in,height=1in]{figures/Jan25/svdDir_svdCompare1.pdf}
\end{figure}

\end{document}

• I was originally specifying width=0.45\textwidth when I got the error. It is actually sized to 8in x 6in default anyhow so that shouldn't make a difference. – ryan0270 Jan 26 '12 at 5:11

Does it help if you escape the _ with \_ - that solved the problem as I used an underscore in a gnuplot environment

You may be able to get rid of this by compressing your pdf:

\$ pdftk svdDir_svdCompare1.pdf output svdDir_svdCompare1-compressed.pdf compress

\documentclass[letterpaper,oneside,12pt]{article}
\usepackage[letterpaper,textwidth=7.5in,textheight=9.5in]{geometry}
\usepackage{graphicx}

\begin{document}
\begin{figure}[H]
\includegraphics{figures/Jan25/svdDir_svdCompare1-compressed.pdf}
\end{figure}

\end{document}