5

I have problem including EPS in LaTeX document. I am using latex->dvips->ps2pdf workflow to compile LaTeX document file. Error is thrown as

Illegal parameter number in definition

The EPS file is generated by OriginPro7.5 by default ouput setting. It can be viewed in evince in Ubuntu. So is there any requirement for an eps file to be successfully included in LaTeX?

EDIT: To be more specific, below is the LaTeX snippet,

\begin{figure}
\centering
\includegraphics[width=4.5cm]{figures/A.eps}
\end{figure}

Following error is thrown,

! Illegal parameter number in definition of \@tempb.
<to be read again>
1.6 ...idth=4.5cm]{figures/A.eps}

But when I replace A.eps with B.eps, the system works fine, which makes me believe it's a problem of the EPS file.

EDIT2: The real file name contains special character #, which is the cause of this problem. After removing # from the file name, problem solved.

  • 1
    you have a macro or environment definition with a defined number of parameters, eg [2], but you are using eg #3 as a parameter in the code part, which is not possible. However, it has nothing to do with the eps image. – user2478 Feb 13 '12 at 21:44
  • 2
    Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. – Reinstate Monica - M. Schröder Feb 13 '12 at 22:02
  • I think it has to do with eps file. I actually replace the current eps with another one. Then it works well. Btw, can you be more specific about which macro? – Richard Feb 13 '12 at 22:04
  • 1
    What's the name of the file causing the error? – egreg Feb 13 '12 at 22:12
  • real file name is rand_#_sample0.5_1.eps..PS: when I remove # from the file name, it works... thanks – Richard Feb 13 '12 at 22:19
5

When \includegraphics does its work, it stores the file name in a macro, so a name such as rand_#_sample0.5_1.eps will produce the illegal

\def\@tempb{rand_#_sample0.5_1.eps}

So no # is allowed in a file name.

|improve this answer|||||
4

arguably that's a bug in latex, please submit a bug report, latex latexbug and follow the instructions to submit a bug in category graphics

Meanwhile, if renaming the file is inconvenient, I believe this should work

\edef\f{rand_\string#_sample0.5_1.eps}
\includegraphics[...]{\f}
|improve this answer|||||
  • With clarification from the OP about the file name containing #, I don't think this is a LaTeX bug. – Werner Feb 13 '12 at 22:42
  • well that's what I meant, I don't think we say anywhere that # isn't allowed and it could be made safe I assume, but perhaps it isn't worth it { couldn't be automatically made safe for instance. – David Carlisle Feb 13 '12 at 23:03
  • If one wants that \includegraphics can be an argument to another command, I guess it's quite difficult to allow # in a name; unless the definition that causes the error can be avoided. However, +1 for the workaround. – egreg Feb 13 '12 at 23:22
  • I wouldn't change catcodes (the source of most problems of using things in arguments) but the filename could be sanitised with \meaning or the e-tex re-scanning, at the cost of extra processing just for this edge case of weird names. – David Carlisle Feb 13 '12 at 23:26
  • Well, weirdness is in the eye of the beholder :-) Strictly speaking, it should be up to the file system to decide if a file name is valid or not. – Daniel Feb 14 '12 at 10:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.