TransWikia.com

pdf_tex files and import: PDF file not found

TeX - LaTeX Asked by bjem on January 20, 2021

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
    %%   defsvgwidth{<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%
      providecommandcolor[2][]{%
        errmessage{(Inkscape) Color is used for the text in Inkscape, but the package 'color.sty' is not loaded}%
        renewcommandcolor[2][]{}%
      }%
      providecommandtransparent[1]{%
        errmessage{(Inkscape) Transparency is used (non-zero) for the text in Inkscape, but the package 'transparent.sty' is not loaded}%
        renewcommandtransparent[1]{}%
      }%
      providecommandrotatebox[2]{#2}%
      ifxsvgwidthundefined%
        setlength{unitlength}{1680bp}%
        ifxsvgscaleundefined%
          relax%
        else%
          setlength{unitlength}{unitlength * real{svgscale}}%
        fi%
      else%
        setlength{unitlength}{svgwidth}%
      fi%
      globalletsvgwidthundefined%
      globalletsvgscaleundefined%
      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%

3 Answers

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.

Answered by Maxim on January 20, 2021

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.

Answered by elkevn on January 20, 2021

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.

Answered by confused_zebra on January 20, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP