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

graphics

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?

    \includegraphics{{C:/Users/XYZ/Pictures/Rplot01.jpg}}

Best Answer

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

\includegraphics[width=10cm,height=5cm,keepaspectratio]{kSED7}

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

\usepackage{graphicx}

at the very beginning of your LaTeX document.

Update:

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

\centerline{}

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

\centerline{\includegraphics[width=10cm,height=5cm,keepaspectratio]{kSED7}}

Hope this helps!