Graphics, Figures & TablesProblem of photo when moving file

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
azizever83
Posts: 41
Joined: Sun Apr 08, 2012 4:31 pm

Problem of photo when moving file

Post by azizever83 »

Hello everybody,
I am using texmaker and sometimes i have to move my file from folder to another. The problem is that i have many figures in this file so that every time i need to run the file after moving it I have to include these figures from the begining which wastes my time.
How can i solve this problem?
Thanks

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

GerlofVito
Posts: 27
Joined: Wed May 16, 2012 8:24 pm

Re: Problem of photo when moving file

Post by GerlofVito »

I keep my figures in the same folder as the tex file, so if I have to move the tex file, I can just move everything along with it. Is there a reason that you can't also move the figures into the new folder along with the tex file?
azizever83
Posts: 41
Joined: Sun Apr 08, 2012 4:31 pm

Problem of photo when moving file

Post by azizever83 »

GerlofVito wrote:I keep my figures in the same folder as the tex file, so if I have to move the tex file, I can just move everything along with it. Is there a reason that you can't also move the figures into the new folder along with the tex file?
.
Hello, thanks for the response, as along as i move the file i have to specify the path of the figures.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10350
Joined: Mon Mar 10, 2008 9:44 pm

Problem of photo when moving file

Post by Stefan Kottwitz »

Use relative paths. It's often a good idea to put figure files into a subfolder of the document folder. So write \includegraphics{photo} if the photo is in the same folder as the document, or

Code: Select all

\includegraphics{figures/photo}
if it's in the subpath figures, i.e. ./figures/, but don't use absolute paths such as

Code: Select all

\includegraphics{/home/user/document/figures/photo}
or

Code: Select all

\includegraphics{c:/documents/figures/photo}
Stefan
LaTeX.org admin
GerlofVito
Posts: 27
Joined: Wed May 16, 2012 8:24 pm

Problem of photo when moving file

Post by GerlofVito »

Ah, I see. Assuming you were using absolute file paths, Stefan's advice will help. Another tip when using relative paths is to use the \graphicspath command in your preamble, so you can just give the file name of the image in the body of the document. For example, put this in the preamble:

\graphicspath{{./}{figures/}}

Notice that you can specify several folders with \graphicspath. And then to insert an image from the figures subfolder, you can just write this is the body of the document:

\includegraphics{photo1}
azizever83
Posts: 41
Joined: Sun Apr 08, 2012 4:31 pm

Problem of photo when moving file

Post by azizever83 »

Hello,
Thanks all for the help.
GerlofVito wrote:Ah, I see. Assuming you were using absolute file paths, Stefan's advice will help. Another tip when using relative paths is to use the \graphicspath command in your preamble, so you can just give the file name of the image in the body of the document. For example, put this in the preamble:

\graphicspath{{./}{figures/}}

Notice that you can specify several folders with \graphicspath. And then to insert an image from the figures subfolder, you can just write this is the body of the document:

\includegraphics{photo1}
where should I use the command \graphicspath{{./}{figures/}}?
is it at the beginning of the document before the command \begin{document}?
Thanks again.
Post Reply