Hello, how are you? :)
Do you remember that we talked about figures, the graphicx
package, and the \includegraphics
command?
Well, we were supposing that our images were on the same level of our document, it is, in the same folder. But what can we do if that is not our case, what if our image is in another folder? What can we do? There are three options, let's check them all
- Images in the same level
- Images in a folder that is inside the current folder
- Images in a folder that is outside the current folder
These situations also work with another kind of files, for example, other LaTeX documents, you just change the
\includegraphics
for the desired command
Option 1. Images in the same level
If the image is at the same level, we just use the \includegraphics
command in the usual way
\includegraphics{nameOfTheImage.extension}
Option 2. Images in a folder that is inside the current folder
To illustrate this, we are going to suppose that the folder where the images are is called Images
, so
- Just one folder
\includegraphics{Images/nameOfTheImage.extension}
- More than one folder
If our images are inside the folder Images
which is inside Fn-1
, and so on until F1
\includegraphics{F1/.../Fn-1/Images/nameOfTheImage.extension}
Did you catch the idea? You need to put the name of all the folders until reach the folder where the image is
Option 3. Images in a folder that is outside the current folder
The way that we tell the computer to go back is with ..
, yes, two dots ..
The
..
command goes back one level in our directory
Yes? Let me explain this with an example:
Let's suppose that we are in the directory Documents/MyFolders/LaTeX
, and that in MyFolders
we also have the folders Music
, Pics
, Videos
(and also LaTeX
) but we are already there, so, if we are in Documents/MyFolders/LaTeX
and we write ..
it tells to the computer go back one level, this is going to place us in Documents/MyFolders
and now we can access any of the folders that are in that level, these are Music
, Pics
, Videos
and LaTeX
. Let's take this structure to illustrate the examples
- Let's suppose we have our image one level up of our current folder, we need to write
\includegraphics{../nameOfImage.extension}
So according to our example, the image is in the MyFolders
folder
- What happens if my image is in the
Pics
folder?, well if we are in theLaTeX
folder we need to go back and then go tho thePics
folder, this is
\includegraphics{../Pics/nameOfImage.extension}
Did you catch the idea? You first need to reach the folder where is the folder which has the image and then go to the desired folder
Top comments (0)