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.

1
  • 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) Commented Aug 11, 2017 at 18:33

1 Answer 1

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.

1
  • @Marshall hmm you accepted this but it surely gave a syntax error at the length setting not (initially) the file not found error? Commented Aug 11, 2017 at 21:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .