Reason for Images not appearing in YAP (DVI viewer) for LaTex
I’ve just sorted out why some images wouldn’t appear in a LaTex document I’ve been working on. The old hands will probably laugh at his (I’m a newbie to LaTex) but there weren’t any errors, just a big hole were the picture should be. This was the latest version of MikTex (2.7.2).
This doesn’t work:
\begin{figure}
% Requires \usepackage{graphicx}
\center{
\includegraphics[width=0.7\textwidth]{"pictures/Factors.eps"}
\caption{Randomly generated schemes}
\label{ScatterplotOfFFactors}
}
\end{figure}
Whereas this is fine:
\begin{figure}
% Requires \usepackage{graphicx}
\center{
\includegraphics[width=0.7\textwidth]{pictures/Factors.eps}
\caption{Randomly generated schemes}
\label{ScatterplotOfFFactors}
}
\end{figure}
What’s the difference? It’s the quotes around the filename ( {pictures/Factors.eps} vs {“pictures/Factors.eps“} ) – in the first one. I’d been thinking of the filename as a string – but in LaTex it’s not.
If I add quotes the file compiles without error and displays in the DVI viewer not a gap is left where the image should be – remove the quotes and the image displays correctly.
Initially I thought that it was having problems with images in a subdirectory (they’re in a directory called “pictures”) but that was only one of many dead-ends.
This might save someone some time (and sanity). When you’re writing a thesis, the last thing you want is to waste time figuring why the tools won’t work.
This is another example of something that happens so often when programming – seeing what you expect to see. None of the examples had quotes, mine did, and I just didn’t see them.