0

I'm trying to include PDF+LaTeX figures exported from Inkscape in my document. Both .pdf_tex and .pdf files are inside the same path, nested within the project root. These two pieces of code work nicely:

\def\svgwidth{\linewidth}
\import{figs/}{myfig.pdf_tex}

or

\def\svgwidth{\linewidth}
\graphicspath{{figs/}}
\input{figs/myfig.pdf_tex}

I wanted to make a macro of these, so I tried:

\newcommand{\includepdflatexOne}[3][\linewidth]{
\def\svgwidth{{#1}}
\import{#2}{#3.pdf_tex}
}

and

\newcommand{\includepdflatexTwo}[3][\linewidth]{
\def\svgwidth{#1}
\graphicspath{{#2}}
\input{#2#3.pdf_tex}
}

but calling either \includepdflatexOne{figs/}{myfig} or \includepdflatexTwo{figs/}{myfig} results in

! LaTeX Error: File `myfig.pdf_tex' not found.

Why doesn't LaTeX find the file when \input or \import are called from within a macro? I also tried subimport, but the same happened.

I believe my question may be related to this (unanswered) question, but reading it didn't help me.

Just in case, I'm using ShareLaTeX.

  • 2
    \input works the same way whether or not it is in a macro but it is hard to say why your file is not found just from these fragments. (setting graphicspath-per inclusion is rather odd but should work) – David Carlisle Aug 11 '17 at 18:33
1
\def\svgwidth{{#1}}

if #1 is \linewidth (your default) will be

\def\svgwidth{{\linewidth}}

which will be an error. You only want want set of braces.

  • @Marshall hmm you accepted this but it surely gave a syntax error at the length setting not (initially) the file not found error? – David Carlisle Aug 11 '17 at 21:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.