3

To include a .pdf_tex file in the document, two files are required: the .pdf_tex file, and the .pdf file. While the .pdf_tex file can be placed in any folder, the .pdf file must be in the same .tex file directory. Is there a way to make both files fit in the same subfolder?

Example:

\begin{figure}[h] 
\def\svgscale{0.3} 
\input{fig/ef1-4-1.pdf_tex} 
\caption{Immagine creata con Inkscape} 
\label{fig:your image label} 
\end{figure}
  • What do you mean with "include a .pdf_tex file"? Please be a bit more specific. – TeXnician May 7 '17 at 11:19
  • Example: \begin{figure}[h] \def\svgscale{0.3} \input{fig/ef1-4-1.pdf_tex} \caption{Immagine creata con Inkscape} \label{fig:your image label} \end{figure} – Salvo Matteini May 7 '17 at 11:32
3

Possibility 1:

You can add \graphicspath{./fig/} to your document. This adds the subfolder to the places tex looks for images. For example if you add this command to your preamble, you can include all the images from this folder just by their name and you don't need to write their path each time.

Possibility 2:

Or you could edit ef1-4-1.pdf_tex. It should have one or more lines with

\put(0,0){\includegraphics[width=\unitlength,page=1]{ef1-4-1.pdf}}%

replace them by

\put(0,0){\includegraphics[width=\unitlength,page=1]{./fig/ef1-4-1.pdf}}%
  • I don't know why this works only on XeLaTeX. By the way, thank you – Salvo Matteini May 7 '17 at 17:14
  • @SalvoMatteini Both solutions should also work in pdflatex. Can you make a MWE that shows your problem? – user36296 May 7 '17 at 19:26
7

You can use package import and use \import instead if \input to load the .pdf_tex file:

\begin{figure}[h] 
\def\svgscale{0.3} 
\import{fig/}{ef1-4-1.pdf_tex} 
\caption{Immagine creata con Inkscape} 
\label{fig:your image label} 
\end{figure}

Note, that the command has two instead of one argument. The first argument is the directory, the second the file name. The command does extend the search path for files and graphic files by the first argument and then loads the file using the new search path. \inlcudegraphics-commands in the loaded file then uses also the extended search path.

You could also change \graphicspath before loading the .pdf_tex file instead of using package import:

\begin{figure}[h] 
\def\svgscale{0.3} 
\graphicspath{{fig/}}
\input{fig/ef1-4-1.pdf_tex} 
\caption{Immagine creata con Inkscape} 
\label{fig:your image label} 
\end{figure}

but this does only work for one input level. If you have files in subfolders of the subfolder of another file it would not work.

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.