7

I am trying to use pdftex to lay out a document including images made in inkscape.

From inkscape I can output the images as pdfs with accompanying pdf_tex files and put these in a figure environment.

This works if the figures are in the main file. However, I have each chapter in a separate folder with all the images for that chapter. When I include images in a chapter I get the error : "Package pdftex.def Error: File 'peeling_flow_constant_width.pdf' not found."

Googling around (here: http://mirrors.ibiblio.org/CTAN/info/svg-inkscape/InkscapePDFLaTeX.pdf) suggests that if I had all my images in the same folder then I could use \graphicspath. This doesn't work for my case of having graphics in each of the separate chapter subfolders.

I think the problem comes from the fact that the .pdf_tex file automatically generated by inkscape includes the command: \put(0,0){\includegraphics[width=\unitlength]{base_peeling_flow_constant_width.pdf}}%

This command doesn't have any information about the path to the pdf file.

My minimal working example is

\documentclass[12pt,chapterprefix,openright,twoside,a4paper,numbers=noenddot,DIV11,BCOR1cm]{scrbook}
%\include{l_preamble}
\usepackage{graphicx} % to be able to use \includegraphics
\usepackage[rgb]{xcolor} % Needed by pdfcomment

\begin{document}

\begin{figure}[htb]
\input{base_peeling_flow_constant_width.pdf_tex}
\end{figure}

\include{chapter1/chapter1}

\end{document}

with the chapter 1 file

\section{test chapter1}

\begin{figure}[htb]
\input{chapter1/peeling_flow_constant_width.pdf_tex}
\end{figure}
5
  • Previously, I had generated eps_tex files from inkscape, but using eps2pdf does not work on these eps graphics. Any tips on how to do this route would also be helpful, but I should probably post this separately.
    – Chogg
    Jul 24, 2013 at 18:53
  • 2
    I've fixed this now. It seems that \graphicspath can take several directories so I can list all my sub folders there. It would still be nice to avoid writing out the chapter folders individually, but I can cope with that for now. Presumably there is a way to automatically generate a list of subfolders, but I don't know it yet.
    – Chogg
    Jul 24, 2013 at 19:14
  • Don't use include in your preamble. Ever. Use input instead.
    – Juri Robl
    Jul 24, 2013 at 19:30
  • @JuriRobl I was including my whole preamble. That is OK, right - as long as I don't use an include within my preamble? That is what I've seen in templates.
    – Chogg
    Jul 25, 2013 at 16:54
  • No, never use include before your document is startet (\begin{document}). It clears the current page which is meaningless (and wrong) if it's not happening in your document. If you have seen that in other templates, don't use them, they probably do other things wrong, too.
    – Juri Robl
    Jul 25, 2013 at 17:14

1 Answer 1

12

Page 2 of CTAN/info/svg-inkscape/InkscapePDFLaTeX.pdf suggests the alternative use of the import package. Assuming all three files (.PDF, .PDF_TEX, and .SVG) are in the same folder as chapter1.tex, then all you need is

\documentclass{article}

\usepackage{graphicx,import}

\begin{document}
\input{chapter1/chapter1}
\end{document}

and

\chapter{test chapter}

\begin{figure}[h!]\centering
\import{chapter1/}{peeling_flow_constant_width.pdf_tex}
\end{figure}
3
  • Thanks. I've got that working. Is there a reason to use import rather than \input with \graphicspath?
    – Chogg
    Jul 24, 2013 at 19:46
  • @Chogg \graphicspath would be useful if all image files were kept in the same subdirectory, but you stated you want to keep different image files in multiple subdirectories.
    – nnunes
    Jul 25, 2013 at 5:56
  • multiple subdirectories can be used with \graphicspath. I guess it is inconvenient to have to remember to add each new folder with images in it. It seems like the input method is better.
    – Chogg
    Jul 25, 2013 at 16:56

You must log in to answer this question.

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