2

I am using Sweave (in Emacs) to generate a report. I can compile the .tex file just fine. There are images (PDFs) that I generate (I have graphicx included in my \usepackage{}; I am not dealing with issues coming from LaTeX looking for EPS files) in my code. When I go to run pdflatex on my resulting *.tex file, I get the error below. The picture in question (normalization_analysis-002) is in the same folder as my *.tex file. Moreover, I get this error whether I attempt to compile through Emacs or via the command line; in Emacs and command line my working directory is the same directory as where the *.tex file is located. Finally, this is the first time this problem has occurred, despite using Emacs + Sweave for some months now on the same computer system for a variety of projects. What is happening?

I should point out that recompiling other files on the same system works. I cannot generate a reproducible error b/c the data I am using is not public yet, so I am asking instead for advice about how to troubleshoot this issue.

The log is available here

! LaTeX Error: File `normalization_analysis-002' not found.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.30 \includegraphics{normalization_analysis-002}

? 
! Emergency stop.
 ...                                              

l.30 \includegraphics{normalization_analysis-002}

!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on normalization_analysis.log.

Per a comment from @David Carlisle, adding .pdf to the argument to \includegraphic{} yields the following error:

LaTeX Warning: File `normalization_analysis-002.pdf' not found on input line 86
.


! Package pdftex.def Error: File `normalization\unhbox \voidb@x \penalty \@M \h
skip \z@skip \T1\textunderscore \discretionary {-}{}{}\penalty \@M \hskip \z@sk
ip analysis-002.pdf' not found.

See the pdftex.def package documentation for explanation.
Type  H <return>  for immediate help.
...                                              

l.86 ...degraphics{normalization_analysis-002.pdf}
  • You can't include EPS files directly into a pdfLaTeX document. See Which graphics formats can be included in documents processed by latex or pdflatex? If the image is EPS, convert it to PDF and try again. – Werner Feb 26 '15 at 22:04
  • It's not EPS. It's Pdf. – learner Feb 26 '15 at 22:05
  • In the question text, the file name has two hyphens, in the .log excerpt the first hyphen is an underscore. – Heiko Oberdiek Feb 26 '15 at 22:06
  • Yes, sorry, that's a typo on my part. The quote is correct as it is auto generated by Sweave – learner Feb 26 '15 at 22:07
  • 1
    @learner macros are expanded in the file name but you have _ defined to a macro to have an effect on typesetting so latex was looking for a file with the name normalization\unhbox \voidb@x \penalty \@M \h skip \z@skip \T1\textunderscore \discretionary {-}{}{}\penalty \@M \hskip \z@sk ip analysis-002.pdf – David Carlisle Feb 26 '15 at 23:15
9

The .log excerpt of the updated question shows that the underscore is an active character, which is expanded, when the graphics package with driver pdftex.def looks for the file. Here you can deactivate the underscore token with \string:

\includegraphics{normalization\string_analysis-002}

The .log file shows that the underscore is made active by package underscore.

Active characters act like commands or macros. When the graphics package looks for the image file name, then it also expands macros (that allows, that parts of the file name can be specified by macros). Package underscore defines _ as active character. As result the underscore can be directly used to get an underscore without the need to use the backslash. The expansion result of the active _ gives the stuff, you can see in the .log file:

"\unhbox \voidb@x \penalty \@M \hskip \z@skip \T1\textunderscore \discretionary {-}{}{}\penalty \@M \hskip \z@skip "

Pretty surely your system does not contain a file name with such a funny name inside.

Package underscore takes some precaution for the active underscore by supporting babel's mechanism for its shorthand characters, but package graphics does not support babel shorthands.

The command \string converts the next token to its character representation with non-active characters (category code 12 and the space has category code 10). Thus the active _ becomes an inactive underscore character token.

  • Wow. Good catch. Would you mind writing up a bit of explanation about why that was a problem? I'd like to understand, and perhaps others will have this issue as well. – learner Feb 26 '15 at 23:09

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.