# Include figure with path relative to graphicspath

by cphyc   Last Updated July 12, 2019 13:23 PM - source

I am trying to insert figures that are deep in a folder structure. Unfortunately, I cannot directly include the directories that contain each of them, since there are multiple name clashes between figure names (see below).

I was wondering if I could include figures based on their relative path with respect to a folder that I have set in the \graphicspath?

Here's a (non-)working MWE. If you have a structure like

main.tex
├── figures
│   ├── A
│   │   └── foo.png
│   └── B
│       └── foo.png


I would like to be able to do \includegraphics{A/foo} and not \includegraphics{figures/A/foo}, by e.g. adding figures to the graphicspath. This would look like

\documentclass[11pt]{article}

\usepackage{graphicx}

\graphicspath{figures/}
\title{Foo}
\author{Bar Baz}

\begin{document}
\maketitle

\includegraphics{A/foo} ! Does not work
\includegraphics{B/foo} ! Does not work

\includegraphics{figures/A/foo} ! Works, but annoying
\includegraphics{figures/B/foo} ! Works, but annoying

\end{document}


Is there a solution to this problem?

Tags :