I have structured my PDFLaTeX document in folders. Inside them there are .tex files, .PDF figure files. And all works using \import and \subimport commands from the Import package:
Main/
|-- main.tex
|-- work.svg
|-- Chapter1/
|-- body.tex
|-- notwork.svg
|-- figure.PDF
|-- figure.SVG
So in main.tex:
...
\import{Chapter1/}{body.tex} %% OK
...
In body.tex:
...
\includegraphics{figure.PDF} %% OK (so relative path is working)
...
Now, I'd like to use SVG figures and InkScape and automate the process as explained in:
https://ctan.org/tex-archive/info/svg-inkscape/InkscapePDFLaTeX.pdf
It uses \pdffilemoddate command in \executeiffilenewer called by \includesvg.
If I change in body.tex:
...
\includesvg{figure}
...
then \executeiffilenewer macro doesn't invoke InkScape because \pdffilemoddate can't find the file (if figure.SVG and figure.PDF are located in Main folder it works so it's a problem with the file path).
How can I handle this?
I think I need to access the actual path constructed by \import to modify \executeiffilenewer, but I don't know how.
Working Example
You need 2 aditional SVG files (work.SVG and notwork.SVG located as in the tree above)
File Main.TeX
\documentclass[10pt]{minimal}
\usepackage{import}
\usepackage[pdftex]{graphicx}
\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 --export-area-drawing}
\import{}{#1.pdf_tex}
}
%% This is a not working try
\newcommand{\includepathsvg}[2]{
\executeiffilenewer{#1#2.svg}{#1#2.pdf}
{inkscape -z -D --file=#2.svg --export-pdf=#2.pdf --export-latex --export-area-drawing}
\import{#1}{#2.pdf_tex}
}
\begin{document}
%% Delete all PDF figure files in Main and Chapter1 folder and uncomment some lines to test:
%SVG: \includesvg{work}
%SVG: \includesvg{Chapter1/notwork} %% InkScape invoked but notwork.pdf_tex can't find notwork.pdf because unknown relative path
%SVG: \includepathsvg{Chapter1/}{notwork} %% InkScape not invoked becaude \pdffilemoddate can't find notwork.svg
File Body.tex:
\import{Chapter1/}{body.TeX}
\end{document}
File Body.TeX in Chapter1 folder:
%% Delete all PDF figure files in Main and Chapter1 folder and uncomment some lines to test:
%SVG: \includesvg{Chapter1/notwork} %% WORKS but I have to include the relative path
%SVG: \includesvg{notwork} %% InkScape not invoked becaude \pdffilemoddate can't find notwork.svg
%SVG: \includepathsvg{Chapter1/}{notwork} %% Problem with path: Chapter1/notwork.svg when invoking InkScape
\input@pathin fileImport.STY. I can view the relative path using:\makeatletter \input@path \makeatotherbut I can't use it into\pdffilemoddateto work. – Fernando Nadal May 05 '11 at 12:44