0

I'm writing a thesis, and I want to insert images in the document. However, when I tried to use the command \includegraphics for the insertion of an image, the program gave me an error. I tried a lot of things, but all ended with an error.

In particular, I tried the following test configuration. On the desktop I created a main folder called "TestLatex", inside of which I created a subfolder called "Figures" and where the image "Pencils.jpg" is located. Then I wrote the following code and saved it as "Test.tex" in the main folder:

\documentclass[a4paper,10pt]{book}      
\usepackage{graphicx}
\graphicspath{ {./Figures/} }
\begin{document}
\includegraphics{Pencils}
\end{document}

When I tried to compile the file, it gave me the following error:

Undefined control sequence. \includegraphics{Pencils}
! LaTeX Error: File `Pencils' not found.
See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
...                                              
l.5     \includegraphics{Pencils}                             
I could not locate the file with any of these extensions:
.pdf,.png,.jpg,.mps,.jpeg,.jbig2,.jb2,.PDF,.PNG,.JPG,.JPEG,.JBIG2,.JB2,.eps
Try typing  <return>  to proceed.
If that doesn't work, type  X <return>  to quit.
[1{C:/Users/maxim/AppData/Local/MiKTeX/2.9/pdftex/config/pdftex.map}
] (Test.aux) ) 
Here is how much of TeX's memory you used:
1443 strings out of 492895
20377 string characters out of 3133479
81682 words of memory out of 3000000
5366 multiletter control sequences out of 15000+200000
3993 words of font info for 15 fonts, out of 3000000 for 9000
1141 hyphenation exceptions out of 8191
41i,4n,25p,273b,141s stack positions out of 5000i,500n,10000p,200000b,50000s
<C:/Program Files/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmr10.pfb>
Output written on Test.pdf (1 page, 12128 bytes).
PDF statistics:
10 PDF objects out of 1000 (max. 8388607)
0 named destinations out of 1000 (max. 500000)
1 words of extra memory for PDF output out of 10000 (max. 10000000)

I tried also to copy-paste the image file from the subfolder to the main folder and the use the following code, but it resulted in the same error.

\documentclass[a4paper,10pt]{book}      
\usepackage{graphicx}
\begin{document}
\includegraphics{Pencils.jpg}
\end{document}

Summary: From the conducted test, it seems that the original image inserting problem found in the thesis wasn't due to something related to the thesis document itself, but, from what I can deduce, to something strange in the program. Any ideas?

M.M.
  • 75
  • you seem to have edited the log Undefined control sequence. '\includegraphics{Pencils} is not the form of an undefined control sequence error. what command was undefined? – David Carlisle Jul 07 '20 at 23:43
  • From the register file it says "Undefined control sequence. \includegraphics{Pencils}", from the issues report it says "! Undefined control sequence. \Ginclude@graphics ...\Ginput@path \set@curr@file {#1}\edef \uq@curr@file {... l.5 \includegraphics{Pencils}

    The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g., \hobx'), typeI' and the correct spelling (e.g., `I\hbox'). Otherwise just continue, and I'll forget about whatever was undefined."

    – M.M. Jul 08 '20 at 09:04
  • 1
    it would be better to show that in a code block as the line breaks are important but the command before the line break will be \set@curr@file which means that your graphics package is newer than your latex format, which (as always in miktex) probably means that you need to update both user and admin mode to get your implementations back in sync. – David Carlisle Jul 08 '20 at 09:15
  • I don't know what you mean by "register file" that is not a tex output, is this something shown by your editor? If you are using texstudio please comment at https://sourceforge.net/p/texstudio/feature-requests/1068/ – David Carlisle Jul 08 '20 at 09:18
  • This is the link to a dropbox folder where I saved the screenshots of the errors. https://www.dropbox.com/sh/x2cnx4gsb5ne6jp/AAA5SjqBOXZ_sGNANGIjwGdva?dl=0 – M.M. Jul 08 '20 at 10:58
  • So it is texstudio please leave a comment at their bug site, it really is time they stopped confusing people by mangling the errors that latex reports. – David Carlisle Jul 08 '20 at 12:28
  • How do I update both the user and admin mode of tex studio? I need to solve this problem as quick as possible. – M.M. Jul 08 '20 at 13:18
  • texstudio is just your editor you need to update miktex (I do not use miktex so I can not give details) – David Carlisle Jul 08 '20 at 13:35
  • I just updated MikTeK in both user and admin mode, and now the code works, for the test file and for the thesis file. Thank you very much! – M.M. Jul 08 '20 at 16:19

0 Answers0