Set the image folder in LaTeX (graphicspath)

\graphicspath{{images/}} in the preamble tells \includegraphics to look for files in the folder images. After that you write \includegraphics{photo.png} instead of \includegraphics{images/photo.png}.

Preamble

The snippets on this page need these lines before \begin{document}:

\usepackage{graphicx}

Write the path in every command

Without \graphicspath, the file name contains the folder. The path is relative to the folder of the main .tex file, also when the command stands in a file loaded with \input. Use forward slashes on Windows too.

\includegraphics[width=0.5\textwidth]{images/image.png}

Set one image folder

The folder stands in its own pair of braces inside the argument and ends with /. LaTeX looks in the folder of the document first and then in the folders from \graphicspath.

Complete document:

\documentclass{article}
\usepackage{graphicx}
\graphicspath{{images/}}
\begin{document}
\includegraphics[width=0.5\textwidth]{image.png}
\end{document}
Result
The compiled example

Set several folders

Every folder gets its own braces, without commas between them. LaTeX searches the folders in the given order and takes the first file with a matching name.

This goes into the preamble.

\graphicspath{{images/}{plots/}{../shared/logos/}}

Open in the editor

Pitfalls

Compiled with pdfLaTeX from TeX Live 2023.

Related pages