# Is there something similar to \graphicspath{ {myPath} } for minted?

Basically what the title says. I would like to know if there is a way to specify a particular folder as a base folder for when you import source code files in minted.

There's currently no provision for this. However, it's not difficult to add a suitable framework.

I used a couple of directories created for answering other questions just by way of example.

\documentclass{article}
\usepackage{minted}

\makeatletter
\newcommand{\pathinputminted}[3][]{%
\expandafter\@tfor\expandafter\next\expandafter:\expandafter=\pathminted@path\do{%
\IfFileExists{\next #3}{\inputminted[#1]{#2}{\next #3}}{}%
}%
}
\newcommand{\mintedpath}[1]{%
\def\pathminted@path{#1}%
}
\makeatother

\mintedpath{{./zeno/}{wenneker/}}

\begin{document}

\pathinputminted{latex}{a.tex}

\pathinputminted{latex}{b.tex}

\pathinputminted{tex}{chsum.tex}

\end{document}


This is quite simplistic, because all files named a.tex in directories specified in \mintedpath will be input.

It would be possible to break the loop at the first hit, but it's easier with expl3.

\documentclass{article}
\usepackage{minted}
\usepackage{xparse}

\ExplSyntaxOn

\tl_new:N \l_mintedpath_paths_tl

\NewDocumentCommand{\mintedpath}{m}
{
\tl_set:Nn \l_mintedpath_paths_tl { #1 }
}

\NewDocumentCommand{\pathinputminted}{O{}mm}
{
\tl_map_inline:Nn \l_mintedpath_paths_tl
{
\file_if_exist:nT { ##1 #3 }
{
\inputminted[#1]{#2}{##1 #3}
\tl_map_break:
}
}
}

\ExplSyntaxOff

\mintedpath{{./zeno/}{./wenneker/}}

\begin{document}

\pathinputminted{latex}{a.tex}

\pathinputminted{latex}{b.tex}

\pathinputminted{tex}{chsum.tex}

\end{document}