77

I am sorry if my question is too silly, I am totally new to LaTeX.

I have just downloaded TeXstudio 2 days ago and am trying to include some figures/images in the document. I found out about the \includegraphics command but cannot understand how it works at all. Every guide I have found jump to something like

\usepackage{graphicx}
\includegraphics[width=0.5\textwidth]{bird1}

and I don't have a clue how I am supposed to use the command except that I need to use the package graphicx.

Where do I have to put my images so that TeXstudio can find it? Let's say I have an image called cat.png located at C:\Users\ASUS\Desktop\PICS, do I just type \includegraphics{cat} and TeXstudio is going to magically find it?

5
  • If it is in the same folder as the .tex file, it will find magically find it. The package also has the command \graphicspath so you could put the images in a subdirectory (e.g., \graphicspath{{jpg/}{png/}}) -- though how this works exactly on Windows is not clear to me. Luckily there are experts around....
    – jon
    Commented Mar 30, 2016 at 5:31
  • Can anybody post the authoritative link to the \includegraphics command documentation? Commented Apr 8, 2020 at 20:26
  • Using amsart the command \includegraphics is not recognized. Commented Jul 25, 2020 at 13:07
  • This video contains your answer. How to add a figure in LaTeX using \includegraphics Commented Aug 4, 2020 at 13:45
  • @WilliamEntriken (and future readers coming across this, if any) texdoc graphicx, or unofficial LaTeX reference manual, page 212. special case of macros - Where do I find out how a command/environment is defined? - TeX - LaTeX Stack Exchange I guess
    – user202729
    Commented Aug 10, 2022 at 3:40

1 Answer 1

66

The easiest way is to put the pictures in the same directory as your (main) LaTeX document. Then

\includegraphics[width=0.5\textwidth]{bird1}

is working fine. If you put it in some subfolder (relative to the main document) you say, e.g.

\includegraphics[width=0.5\textwidth]{Pics/bird1}

Or you can define where LaTeX should look for pictures using the \graphicspath command in the preamble, e.g. when you sort your pictures to corresponding folders

\graphicspath{
    {Pics/PDFs/}
    {Pics/JPGs/}
    {Pics/PNGs/}
}

and LaTeX will search the folders in the given order using the first found picture matching the name given to \includegraphics.

5
  • Thank you a lot! It seems to be working after I move the image to the same folder containing the document. Just 1 more question, I still don't quite understand the structure of \graphicspath command. Could you please explain it in a bit more detailed?
    – BigbearZzz
    Commented Mar 30, 2016 at 5:38
  • 2
    Have a look at that question and the corresponding answers. Is that enough? Commented Mar 30, 2016 at 7:20
  • You really helped me a lot, thank you again. I wish I could upvote more than 1 time.
    – BigbearZzz
    Commented Mar 30, 2016 at 7:32
  • what do the / correspond to in \graphicspath? I currently have one like this \graphicspath{{images/}} and it only seems to work with one of the /. I don't know why there needs to be a nested argument either.
    – user71207
    Commented Jul 13, 2021 at 6:56
  • The forward slash is for directories. So "images/" is a directory. But you can also leave it out. It's only required for nested directories like "images/favourite/" or "images/favourite". The nested arguments are because you can use space and commas inside a file name but not curly brackets. So it can decide if its still part of the file name or not. Hope that helped
    – Huhngut
    Commented Jan 4, 2023 at 15:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .