[Tex/LaTex] Why I can’t insert image with the following code


I tried to insert an image with the following line, but it doesn't work, keeps saying the image doesn't exist. Why is that?


Best Answer

Here's an example of an includegraphics line of code:


To look at this a little more carefully, after the backslash and command, there are the optional brackets to specify width, height, and ratio, and then (the important part) there are curly braces. You should only have one set of curly braces.

Then, I don't know what you are using for your LaTeX editor, but I use an online LaTeX editor. The way you enter the image name on this particular editor is not like you have specified. In the online editor the image should appear off to the left, like in the screenshot below:

enter image description here

Then, you simply type in kSED7 or YKjf6 instead of the full line you did.

The main thing I would say to try is to use only one set of curly braces instead of two.

Finally, also be sure to use the line


at the very beginning of your LaTeX document.


In light of your comment, you can center a graphic by using the command


with your \includegraphics{} function inside the curly braces. An example of this would be


Hope this helps!