1

I am trying to include a .pdf_tex file into my latex document. I saved the file from svg in Inkscape to .pdf_tex file. And I use this in my latex document:

\begin{figure}
  \centering
  \input{myfile2.pdf_tex}
\end{figure}

myfile2.pdf_tex is in the same file as the main folder. But the error said

Package pdftex.def Error: `myfile2.pdf' not found

I don't know what's going on here and tried to check for many forum but couldn't find the answer. I using texmaker.

LOG FILE :
This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016) (preloaded format=pdflatex 2017.1.23) 23 JAN 2017 19:44
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
**"Report-PhysicallyCoupledTask copy.tex"
(./Report-PhysicallyCoupledTask copy.tex
LaTeX2e <2017/01/01>
Babel <3.9r> and hyphenation patterns for 83 language(s) loaded.
(/usr/local/texlive/2016/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/local/texlive/2016/texmf-dist/tex/latex/base/size10.clo
File: size10.clo 2014/09/29 v1.4h Standard LaTeX file (size option)
)
LaTeX Font Info: Try loading font information for OT1+lmtt on input line 63.
(/usr/local/texlive/2016/texmf-dist/tex/latex/lm/ot1lmtt.fd
File: ot1lmtt.fd 2009/10/30 v1.6 Font defs for Latin Modern
)
LaTeX Font Info: External font `lmex10' loaded for size
(Font) <12> on input line 66.
LaTeX Font Info: External font `lmex10' loaded for size
(Font) <8> on input line 66.
LaTeX Font Info: External font `lmex10' loaded for size
(Font) <6> on input line 66.
LaTeX Warning: No \author given.
LaTeX Font Info: External font `lmex10' loaded for size
(Font) <9> on input line 72.
LaTeX Font Warning: Font shape `OT1/lmr/bx/sc' undefined
(Font) using `OT1/lmr/bx/n' instead on input line 85.
(./myfile2.pdf_tex <myfile2.pdf, id=83, page=1, 1284.8pt x 702.625pt>
File: myfile2.pdf Graphic file (type pdf)
<use myfile2.pdf, page 1>
Package pdftex.def Info: myfile2.pdf, page1 used on input line 52.
(pdftex.def) Requested size: 1284.79999pt x 702.64471pt.
<myfile2.pdf, id=84, page=2, 1284.8pt x 702.625pt>
File: myfile2.pdf Graphic file (type pdf)
<use myfile2.pdf, page 2>
Package pdftex.def Info: myfile2.pdf, page2 used on input line 55.
(pdftex.def) Requested size: 1284.79999pt x 702.64471pt.
<myfile2.pdf, id=85, page=3, 1284.8pt x 702.625pt>
File: myfile2.pdf Graphic file (type pdf)
<use myfile2.pdf, page 3>
Package pdftex.def Info: myfile2.pdf, page3 used on input line 59.
(pdftex.def) Requested size: 1284.79999pt x 702.64471pt.
!pdfTeX error: /Library/TeX/texbin/pdflatex (file ./myfile2.pdf): PDF inclusion
: required page does not exist <3>
==> Fatal error occurred, no output PDF file produced!

pdf_tex file:

%% Creator: Inkscape inkscape 0.91, www.inkscape.org
%% PDF/EPS/PS + LaTeX output extension by Johan Engelen, 2010
%% Accompanies image file 'myfile2.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}{1280bp}%
    \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.546875)%
    \put(0,0){\includegraphics[width=\unitlength,page=1]{myfile2.pdf}}%
    \put(0.46834302,0.50912102){\color[rgb]{0.14901961,0.14901961,0.14901961}\rotatebox{90}{\makebox(0,0)[b]{\smash{Force difference [N]}}}}%
    \put(0.63887864,0.31148664){\color[rgb]{0.14901961,0.14901961,0.14901961}\makebox(0,0)[b]{\smash{Total force [N]}}}%
    \put(0,0){\includegraphics[width=\unitlength,page=2]{myfile2.pdf}}%
    \put(0.52089864,0.34793664){\color[rgb]{0.14901961,0.14901961,0.14901961}\makebox(0,0)[b]{\smash{0}}}%
    \put(0.63887864,0.34793664){\color[rgb]{0.14901961,0.14901961,0.14901961}\makebox(0,0)[b]{\smash{15}}}%
    \put(0.75685864,0.34793664){\color[rgb]{0.14901961,0.14901961,0.14901961}\makebox(0,0)[b]{\smash{30}}}%
    \put(0,0){\includegraphics[width=\unitlength,page=3]{myfile2.pdf}}%
    \put(0.49981927,0.36697227){\color[rgb]{0.14901961,0.14901961,0.14901961}\makebox(0,0)[rb]{\smash{-3}}}%
    \put(0.49981927,0.46725539){\color[rgb]{0.14901961,0.14901961,0.14901961}\makebox(0,0)[rb]{\smash{0}}}%
    \put(0.49981927,0.63439414){\color[rgb]{0.14901961,0.14901961,0.14901961}\makebox(0,0)[rb]{\smash{5}}}%
    \put(0,0){\includegraphics[width=\unitlength,page=4]{myfile2.pdf}}%
  \end{picture}%
\endgroup%
Sharah
  • 371
  • Didn't Inkscape also create a pdf file? You need that as well. If I'm not mistaken the pdf_tex file just contains the inclusion of the pdf file plus some code to add text on top of the pdf file. Thus you need both generated files. – daleif Jan 23 '17 at 18:49
  • What is a .pdf_tex file? Do you mean a .tex file that you compile with pdftex? Do you mean a PDF file created by pdftex. – Herb Schulz Jan 23 '17 at 19:00
  • @daleif unfortunately not the file is not compiling. It gives error as above (edited the question) – Sharah Jan 23 '17 at 19:49
  • 1
    @HerbSchulz it's a name given to some Inkscape to latex output files. It is a strange naming convention – daleif Jan 23 '17 at 19:50
  • @Sharah but is is actually reading the pdf before the error. Where exactly is myfile2.pdf and myfile2.pdf_tex placed in relation to your main tex file? Can you post the contents of the pdf_tex file – daleif Jan 23 '17 at 19:54
  • @daleif i placed in in the same folder as main.tex folder. no extra folder. edited the pdf_tex file – Sharah Jan 23 '17 at 20:04
  • Have you removed anything from the log file? Have you included the graphicx package (I did not see it in the list). Is the pdf actually 4 pages? – daleif Jan 23 '17 at 20:10
  • 2
    Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – Martin Schröder Jan 23 '17 at 20:13
  • Can you check that myfile2.pdf has 4 pages? From the error message it looks, like it might only have 2 pages. – samcarter_is_at_topanswers.xyz Jan 23 '17 at 20:13
  • @daleif the file is actually 4 pages but it's actually only a graph. I think this might be a problem with Mac with Inkscape and Latex. I need a different way to include svg file into my latex file so far to none is working – Sharah Jan 23 '17 at 20:19
  • @samcarter it does have 4 pages. I think this is error with file created by inkscape itself. I need a different way to include my svg file into latex but none of the recommendation works – Sharah Jan 23 '17 at 20:19
  • @Sharah As a test, does it compile if you remove the lines \put(0,0){\includegraphics[width=\unitlength,page=3]{myfile2.pdf}}% and \put(0,0){\includegraphics[width=\unitlength,page=4]{myfile2.pdf}}%? – samcarter_is_at_topanswers.xyz Jan 23 '17 at 20:21
  • now it does compile but the picture did not even appear. @samcarter – Sharah Jan 23 '17 at 20:24
  • @Sharah That's good. Can you open myfile2.pdf? Are the first two pages empty and the graph is somewhere on the 3rd or 4th page? – samcarter_is_at_topanswers.xyz Jan 23 '17 at 20:26
  • 1
    Can you upload the pdf somewhere so others can test the code. Perhaps even extend your sniplet at the start to a full minimal example, so we know the preamble you are using for testing this. Btw what exactly are in those graphs? At least the text seems simple enough for this to be made directly in latex using tikz – daleif Jan 23 '17 at 20:27
  • BTW: you should probably change the title. Not that I do not agree that this is a duplicate. As we know both the .pdf_tex file and the .pdf are actually found – daleif Jan 24 '17 at 09:58
  • @daleif After checking high and low, I think the problem is the svg file. There are text within the svg file, however the pdf_tex shows multiple pages. I do not know what's going on.... please find the files in the following link https://drive.google.com/open?id=0B2v2A2ahDj-iSzBKZThESnhhcTQ – Sharah Jan 24 '17 at 10:16
  • @samcarter please find the files in the link above. need your help really bad. Thanks!!! – Sharah Jan 24 '17 at 10:16
  • Your pdf is broken. You may be able to open it in inkscape and fix it, by combining everything onto one page. – Chris H Jan 24 '17 at 10:18
  • @ChrisH can I have explicit explanation on how to do that? – Sharah Jan 24 '17 at 10:21
  • @Sharah The uploaded file.pdf seems to have only three pages. I would suggest 1) you open file.pdf in preview.app and save it. 2) remove the line \put(0,0){\includegraphics[width=\unitlength,page=4]{file.pdf}} – samcarter_is_at_topanswers.xyz Jan 24 '17 at 10:23
  • You probably need to open the pdf in inkscape 3 times, once for page 1, once for page 2, and once for page 3. Then copy all of page 2 and paste onto page 1, aligning it correctly. Then page 3. Then save under the same name (you may want to take a backup). The approach of placing all 3 pages at the same point in the picture is a workaround that might also work. – Chris H Jan 24 '17 at 10:23
  • To avoid dealing with all these layers in the first place, open the svg in inkscape, degroup everything, then select everything which is text (axis lables, axis titles etc.) and move this text to the topmost layer. Now save again as pdf_tex – samcarter_is_at_topanswers.xyz Jan 24 '17 at 10:25
  • @samcarter I couldn't solve my problem. WOuld you be able to try convert the svg file into pdf_tex? I included the file in the folder. – Sharah Jan 24 '17 at 10:49
  • @Sharah Try with these: https://www.dropbox.com/s/d4acjczwb1n3qo9/file.pdf?dl=0 and https://www.dropbox.com/s/ji38ks7xsdrq5bf/file.pdf_tex?dl=0 – samcarter_is_at_topanswers.xyz Jan 24 '17 at 10:54
  • It might sound like a stupid question but that solved the problem most of the times for me: Did you set up you graphicspath correctly? That is where TeX will try to import the pdf from. If its not set (or not pointing in the right direction) the pdf won't be found. – Martin Jan 24 '17 at 10:54
  • @samcarter I think i'm almost there. can you show me how to save the svg image into only one pdf page? I'm sorry I'm such a newb. – Sharah Jan 24 '17 at 10:57
  • @Sharah see http://tex.stackexchange.com/questions/350077/unable-to-compile-pdf-tex-not-on-latex?noredirect=1#comment860017_350077 This is all I have done to save it into one layer. – samcarter_is_at_topanswers.xyz Jan 24 '17 at 10:59
  • @samcarter yeah I don't get it what you mean by degroup everything select everything and move top top layer. How to exactly do that – Sharah Jan 24 '17 at 11:00
  • @Sharah https://inkscape.org/en/doc/basic/tutorial-basic.html So what I meant with "degroup" seems to be called "ungroup" in English, see "Grouping" in the link. Then select all the text elements and move them to the top layer, see "Z-order" in the link. – samcarter_is_at_topanswers.xyz Jan 24 '17 at 11:03
  • @Martin it is not the location of the PDF that is the problem. The .pdf_tex file thinks the PDF has 4 pages, but it does not. – daleif Jan 24 '17 at 11:11
  • @Sharah see http://tex.stackexchange.com/a/350175/36296 for a quick tutorial. I hope you don't mind me borrowing your image. – samcarter_is_at_topanswers.xyz Jan 24 '17 at 11:20
  • @samcarter THANK YOU THANK YOU I DON'T MIND AT ALL. I'm stupid with this kind of stuff I don't know how am I doing a PhD now. – Sharah Jan 24 '17 at 11:32
  • http://tex.stackexchange.com/questions/99475/how-to-invoke-latex-with-the-shell-escape-flag-in-texmakerx/99476#99476

    refering to the suggestion, do you know how to add the shell command (separately ) in texmaker? @samcarter

    – Sharah Jan 24 '17 at 12:57

0 Answers0