0

I use Texstudio and MikTex 2.9

I guess maybe there is something wrong with the package. The MikTex told me to install the package several times, but it seems that the package has not be installed.

I did put the .tex document and the graph in the same folder.

the error says:Package pdftex.def Error: File `../figure1.jpg' not found. ...aphics[width=0.7\linewidth]{../figure1.jpg}

The following is my code.

\documentclass{article}
\usepackage{graphicx}

\begin{document}
    \begin{figure}
\centering
\includegraphics[width=0.7\linewidth]{figure1}
\caption{}
\label{fig:figure1}
\end{figure}

\end{document}
Y.X.
  • 157
  • If they are in the same folder, then it should be ./figure1.jpg or simply figure1.jpg – samcarter_is_at_topanswers.xyz Nov 21 '16 at 01:14
  • 1
    .jpg isn't even needed in general. – Bernard Nov 21 '16 at 01:17
  • @Bernard I edited my code, but nothingwork:Package pdftex.def Error: File `../figure1.jpg' not found. ...aphics[width=0.7\linewidth]{../figure1.jpg} – Y.X. Nov 21 '16 at 01:22
  • Just in case: Is graphics-def installed? There were some changes in the architecture of latex recently. – Bernard Nov 21 '16 at 01:36
  • @Bernard The MikTex asked me to install a package and I followed it. But it asked me to do the samething several times so I think maybe the installation failed. – Y.X. Nov 21 '16 at 01:40
  • @Bernard I had check the MikTex, it said that it has been installed today. – Y.X. Nov 21 '16 at 01:42
  • miktex solved in URL: https://tex.stackexchange.com/questions/511138/miktex-graphics-version-1-3b-bug-on-windows-10-setcurrfile-undefined – kenivel Oct 17 '19 at 00:56
  • miktex solved in URL: https://tex.stackexchange.com/questions/511138/miktex-graphics-version-1-3b-bug-on-windows-10-setcurrfile-undefined – kenivel Oct 17 '19 at 00:58
  • miktex solved in URL: https://tex.stackexchange.com/questions/511138/miktex-graphics-version-1-3b-bug-on-windows-10-setcurrfile-undefined – kenivel Oct 17 '19 at 01:02
  • miktex solved in URL: https://tex.stackexchange.com/questions/511138/miktex-graphics-version-1-3b-bug-on-windows-10-setcurrfile-undefined – kenivel Oct 17 '19 at 01:04

2 Answers2

3

The error message shows that the code you've shared is not the code which produces that message.

In your example, you have

\includegraphics[width=0.7\linewidth]{figure1}

but in the code which produces the error, you have

\includegraphics[width=0.7\linewidth]{../figure1.jpg}

Those are not the same. The first tells TeX to look in the current directory for figure1, an image with one of the known extensions. The second tells TeX to look in the parent of the current directory for figure1.jpg. It will not find anything if it is in the current directory instead.

./figure1

figure1 in the current directory.

figure1

figure1 in the current directory.

../figure1

figure1 in the current directory's parent directory i.e. the directory 'above' the current one.

cfr
  • 198,882
  • Sorry but even after I correct that error it does not work...... So could you please tell me what may be wrong with that? – Y.X. Nov 23 '16 at 05:46
  • @Y.X. 'does not work' isn't much help. What happens? Do you get a different error? Which? Does something else happen? Does your computer explode? Presumably you don't get the same error once you've corrected it, so you need to now address the next one. – cfr Nov 23 '16 at 16:04
  • Just the same error, NO change happens. – Y.X. Nov 24 '16 at 01:43
  • @Y.X. If you get exactly the same error after correcting the cause of that error i.e. the error message includes context which is not present in your file at all, delete all generated files and retry. If you still get the same error then either your TeX installation or something else is seriously screwed up. File system corruption, failing hardware, malicious OS, mixed up TeX installation ... You have serious problems if TeX thinks your file includes ../ when it does not. Certainly, those problems are well beyond me. – cfr Nov 24 '16 at 02:18
1

@cfr is right. There's a world of difference.

I cannot offer an explanation as good as cfr. I, however, can offer what I follow as a practice.

Consider the below picture

![Folder Structure

All my .tex files are in .tex folder and images in Images Folder. If I have to link to an image in Images folder I use the command \graphicspath.

I specify the path only ONCE (before \begin{document}) and use the images by their file name everywhere.

MWE:

\documentclass{article}
\usepackage{graphicx}

%%%%%Format:- \graphicspath{{path1}{path2}{path3}...}%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \graphicspath{{../ImagesFolder/}}

\begin{document} \begin{figure} \centering \includegraphics[width=0.7\linewidth]{LiLi-USB-Creator} \caption{} \label{fig:figure1} \end{figure} \end{document}

No matter how many images I use or how many .tex files I create, I stick to the said structure.

AVOID SPACES IN FILE AND FOLDER NAMES. LaTeX doesn't like spaces in the files you refer to.

I tried your example in my setup -- with one alteration (graphicspath) -- and found no errors (none, zero, zilch).

Output:

enter image description here

Compiler: TexLive 2015

IDE: TexStudio

OS: Ubuntu 15.10

Edit:

I have tried this with Windows 8, 8.1 and 10. \graphicspath needed no modification.

Thanks Jan

abyshukla
  • 411
  • 1
    this is also en excellent answer and a lesson worth learning. In my experience, you also have to avoid the usual Windows path separation character, (\), which has a special meaning in LaTeX. Instead, you have to replace all backslashes into normal slashes (/). – Jan Dec 21 '16 at 08:18