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}
learner
  • 123
  • 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
  • what is the full name of the image file? – David Carlisle Feb 26 '15 at 22:29
  • /home/USER/Copy/DIR/normalization_analysis-002.pdf. Capitalized words are changed for privacy reasons. – learner Feb 26 '15 at 22:32
  • without seeing a real example or the log have to guess so guesses are: graphics has been passed the wrong option (eg [dvips] would be bad) or the file isn't readable due to permissions or being locked by another process or something, or the current working directory pr pdflatex isn't where you expected so effectively the pdf file isn't there or something I can't guess:-) – David Carlisle Feb 26 '15 at 22:50
  • try putting .pdf explicitly at the end of the \includegraphics argument. that forces a different code path that would rule out some of the guesses in the comment above. – David Carlisle Feb 26 '15 at 22:52
  • I tried your most recent suggestion (post updated). Also, permissions/use issues are not applicable - permissions are what they should be, no other programs are using the PDF. Also, from command line, I call within *.tex directory. – learner Feb 26 '15 at 22:59
  • @DavidCarlisle - Heiko has answered this question. Thank you for your input – learner Feb 26 '15 at 23:10
  • @learner well you made it easy for him with that log fragment:-) – David Carlisle Feb 26 '15 at 23:13
  • 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
  • Ah. Yikes. Is this in general a behavior of latex? Or do I have somewhat unusual system settings? – learner Feb 26 '15 at 23:16
  • expanding macros is a general behaviour (tex is a macro expansion language:-) normally _ is not expandable, it would just write as itself but normally it is a math only character for subscripts x_2 looks like you have a non standard definition of _ so that it makes a _ in text. – David Carlisle Feb 26 '15 at 23:18

2 Answers2

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.

Heiko Oberdiek
  • 271,626
  • 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
0

in windows O.S: go to start --> Miktex --> MikteX console then change to administartor mode just select update center and then update your program packages