5

I am currently working on my PhD thesis, and I am having trouble including a pdf_tex and pdf file created using Inkscape. I am using TeXStudio and PDFLaTeX.

The relevant files are:

phd_thesis_all/phd_thesis/tex/thesis.tex
phd_thesis_all/phd_thesis/tex/Chapter05/teleoperation.tex
phd_thesis_all/phd_thesis_figs/images/teleoperation/solidworks_model_view.pdf_tex
phd_thesis_all/phd_thesis_figs/images/teleoperation/solidworks_model_view.pdf
phd_thesis_all/phd_thesis_figs/images/teleoperation/solidworks_model_view.png
phd_thesis_all/phd_thesis_figs/images/teleoperation/solidworks_model_view.svg

The svg has added annotations to the png file. This is exported as a pdf and pdf_tex file for use in the thesis.

The command to include the file with the diagram is in thesis.tex.

    % Chapter 5
    \FloatBarrier
    \chapter{Teleoperation}
    \label{ch:teleoperation}
    \include{Chapter05/teleoperation}

The figure import command in Chapter05/teleoperation.tex is:

    \begin{figure}[htb]
    \centering
    \import{../../phd_thesis_figs/}{images/teleoperation/solidworks_model_view.pdf_tex}
    \caption{\SolidWorks Model with Coordinate Systems Highlighted}
    \label{fig:solidworks_model_view}
    \end{figure}

When I try to compile the document, it comes up with the error:

(../../phd_thesis_figs/images/teleoperation/solidworks_model_view.pdf_tex

LaTeX Warning: File `solidworks_model_view.pdf' not found on input line 52.


! Package pdftex.def Error: File `solidworks_model_view.pdf' not found.

See the pdftex.def package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.52 ...length,page=1]{solidworks_model_view.pdf}}
                                                  %
?

In other words, it is finding the .pdf_tex file just fine, but is choking on the \includegraphics command inside to get the pdf file. I thought the \import command modified the search paths for files in its command. My graphicspath is set so I can import graphics file from that directory tree just fine.

If I change the figure inclusion to:

    \includegraphics[width=\linewidth]{images/teleoperation/solidworks_model_view.png}

Everything works perfectly fine. Why can I not do the same with \import and pdf_tex files?

For completeness, here is the pdf_tex file generated by Inkscape. THe offending \includegraphics directive is on line 52.

    %% Creator: Inkscape 0.91_64bit, www.inkscape.org
    %% PDF/EPS/PS + LaTeX output extension by Johan Engelen, 2010
    %% Accompanies image file 'solidworks_model_view.pdf' (pdf, eps, ps)
    %%
    %% To include the image in your LaTeX document, write
    %%   \input{<filename>.pdf_tex}
    %%  instead of
    %%   \includegraphics{<filename>.pdf}
    %% To scale the image, write
    %%   \def\svgwidth{<desired width>}
    %%   \input{<filename>.pdf_tex}
    %%  instead of
    %%   \includegraphics[width=<desired width>]{<filename>.pdf}
    %%
    %% Images with a different path to the parent latex file can
    %% be accessed with the `import' package (which may need to be
    %% installed) using
    %%   \usepackage{import}
    %% in the preamble, and then including the image with
    %%   \import{<path to file>}{<filename>.pdf_tex}
    %% Alternatively, one can specify
    %%   \graphicspath{{<path to file>/}}
    %% 
    %% For more information, please see info/svg-inkscape on CTAN:
    %%   http://tug.ctan.org/tex-archive/info/svg-inkscape
    %%
    \begingroup%
      \makeatletter%
      \providecommand\color[2][]{%
        \errmessage{(Inkscape) Color is used for the text in Inkscape, but the package 'color.sty' is not loaded}%
        \renewcommand\color[2][]{}%
      }%
      \providecommand\transparent[1]{%
        \errmessage{(Inkscape) Transparency is used (non-zero) for the text in Inkscape, but the package 'transparent.sty' is not loaded}%
        \renewcommand\transparent[1]{}%
      }%
      \providecommand\rotatebox[2]{#2}%
      \ifx\svgwidth\undefined%
        \setlength{\unitlength}{1680bp}%
        \ifx\svgscale\undefined%
          \relax%
        \else%
          \setlength{\unitlength}{\unitlength * \real{\svgscale}}%
        \fi%
      \else%
        \setlength{\unitlength}{\svgwidth}%
      \fi%
      \global\let\svgwidth\undefined%
      \global\let\svgscale\undefined%
      \makeatother%
      \begin{picture}(1,0.60119048)%
        \put(0,0){\includegraphics[width=\unitlength,page=1]{solidworks_model_view.pdf}}%
        \put(0.80420207,0.1664867){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{$z$}}}%
        \put(0.77685686,0.12356509){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{$x$}}}%
        \put(0.7926602,0.10007423){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{$y$}}}%
      \end{picture}%
    \endgroup%
7
  • 1
    just use standard \input{solidworks_model_view.pdf_tex} and make sure that the directory with your tex/image combination is in your TEXINPUTS path Commented Jul 15, 2015 at 9:24
  • you can't use page key with \includegraphics[width=\unitlength,page=1]{solidworks_model_view.pdf} use \includegraphics[width=\unitlength]{solidworks_model_view.pdf}
    – touhami
    Commented Jul 15, 2015 at 9:30
  • @touhami page should work with pdf files. Commented Jul 15, 2015 at 9:38
  • @DavidCarlisle i did not know
    – touhami
    Commented Jul 15, 2015 at 9:56
  • @DavidCarlisle, thanks fort he tip but I would prefer to not to alter environment variables, as I want to keep all my compilation steps portable between different computers (my University computer uses Windows and my home computer uses Linux).
    – bjem
    Commented Jul 15, 2015 at 22:23

4 Answers 4

2

Ok, I've just been battling the same problem.

My solution was to add a \graphicspath{{figs/}} in the beginning of the file, so that it know where to look for the .pdf file. I'm not sure why, but adding figs/ in the beginning of the input command \input{figs/AMB-SyRM4d.pdf_tex} was not enough.

Hope this helps.

0
1

I faced the same problem. Here is what worked for me. I first saved the Texmaker file into some folder, say figures. Then I generated Inkscape pdf_tex file and saved it in the same figures folder. Then I simply run \input{filename.pdf_tex} in the tex file.

0

If anyone is still wondering about this, I believe the reason why it didn't work in the original question is because the \import command was used incorrectly. you should include the package import at the beginning of the document

\includepackage{import}

and then import command is used like this

\import{path/to/file/}{thefile.pdf_tex}

for me this is working fine and I don't need to change the graphicspath at the beginning of the document.

0

Maybe this still helps someone.

/graphicspath did not work for me on Overleaf (and I did not want to use import with specific paths all the time, after all my folder structure might change throughout a project). But one workaround they mention is described here.

In short, create an empty file (I did this on the same level as main.tex, but I don't know if this is required) without any extension, call it latexmkrc and add

$ENV{'TEXINPUTS'}='./graphics//:'.$ENV{'TEXINPUTS'};

with graphics being your most upper level folder of interest.

As mentioned, I use Overleaf, but something similar should work on other platforms or at home too.

0

You must log in to answer this question.

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