# \graphicspath for Inkscape pdf_tex files

For writing a lecture note, I have put my images in a subdirectory named "image". In the main.tex file I have added \graphicspath{{image/}}. I have also included:

\newcommand{\executeiffilenewer}[3]{%
\ifnum\pdfstrcmp{\pdffilemoddate{#1}}%
{\pdffilemoddate{#2}}>0%
{\immediate\write18{#3}}\fi%
}

\newcommand{\includesvg}[1]{%
\executeiffilenewer{#1.svg}{#1.pdf}%
{inkscape -z -D --file=#1.svg %
--export-pdf=#1.pdf --export-latex}%
\input{#1.pdf_tex}%
}


in order to include pdf_tex files.

In the main.tex file I am inserting the SVG file by:

\begin{figure}
\input{filename.pdf_tex}
\end{figure}


but I am getting the following error:

! LaTeX Error: File relativeposition.pdf_tex' not found.


Can anyone tell me what I should do to keep all my SVG files in the image subdirectory and input them from main.tex?

-
Welcome to TeX.SX! Wouldn't it be simpler if you say \input{image/filename.pdf_tex}? In case of only one subdirectory it's not so heavy. –  egreg Oct 15 '12 at 9:26
writing \input{image/filename.pdf_tex} is not working i am getting the same error as the one mentioned above –  mkj Oct 15 '12 at 18:06
add comment

## 1 Answer

A quick hack that allows you to write

\svginput{relativeposition.pdf_tex}


taking into account all subpaths defined with \graphicspath is to add

\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\svginput}{m}
{
\tl_map_inline:cn { Ginput@path }
{
\InputIfFileExists{##1#1}{ \tl_map_break: } { }
}
}
\ExplSyntaxOff


to your document preamble.

However, if only one subdirectory is defined in \graphicspath it's probably easier to define

\newcommand{\svginput}[1]{\input{image/#1}}


where you simply add image` (or the name you want to give to the subdirectory).

-
Concerning your second suggestion should i add only the \newcommand{ \svginput}[1]{\input{image/#1}} or i should add the \usepackage{xparse} also to the preamble. \\ another question when using \svginput should i use it beside an \begin{figure} \svginput{relativeposition.pdf_tex} \end{figure} –  mkj Oct 15 '12 at 18:05
Thanks for your answer i have followed your answer and it is working now. –  mkj Oct 16 '12 at 18:59
add comment