20

I checked the other question similar to this issue yet I could not find a proper solution for the issue I am facing for including an .svg file which is converted using inkscape with pdf+latex option set to ON, and I have also included both the .pdf and .pdf_tex file in the path. Yet I get the above mentioned error.

My code:

\begin{figure}[h!] 
\centering
\def\svgwidth{\columnwidth}
\input{Implementation/Figs/most_changed_from_default_pos_0.pdf_tex}
\end{figure}

Full error description:

!pdfTeX error: pdflatex (file /compile/Implementation/Figs/most_changed_from_default_pos_0.pdf): PDF inclusion: required page does not exist <5>

Any help to solve this issue would be really appreciated. I also downloaded the pdf file to check whether it has 5 pages. I could verify it, there were 5 pages in the pdf file.

The file which I want to convert is Pie chart

I have added the google drive link to the file which I have used for analysis herewith

Files related to the issue

6 Answers6

20

Edit 2: This bug has been fixed. If you still experience it, please update your Inkscape installation to version 0.92.2 (August 2017) or newer.


Apparently there is a bug in Inkscape at the moment (there is a bug report from February here, however someone there mentioned there only being one page too many requested and for me it's quite a few more).

The problem is that the .pdf_tex file requests more pages of the .pdf to be included than there are. You can manually delete the offending lines. They should look something like

put(0,0){\includegraphics[width=unitlength,page=X]{filename.pdf}}%

where X is a number larger than the number of pages in the .pdf file (which is also given to you by LaTeX, in your case <5>).

You will have to repeat this task every time you edit your .svg, so you might want to avoid unnecessary edits.

This is quite arduous, but until a fix is released, this seems to be the best we can do.


Edit: [outdated and thus deleted]

schtandard
  • 14,892
  • This bug is still happening to me on 0.92.2 (mac) – Alex Bogatskiy Feb 16 '19 at 22:09
  • @level1807, try updating to the current version of Inkscape (0.92.4). If that does not help, could you upload an MWE (.tex and .svg) somewhere for us to examine? – schtandard Feb 18 '19 at 16:51
  • 0.92.4 isn't available on mac as a binary yet, so I'll have to wait until it is. – Alex Bogatskiy Feb 18 '19 at 22:11
  • I do not own a Mac, so I cannot test this on my end. On Windows, however, this bug has been fixed since 0.92.2. If you provide me with the necessary files, I could test them on Windows (with 0.92.2). – schtandard Feb 20 '19 at 20:57
  • @schtandard would the lack of inkscape installation be the problem if I'm getting a similar message when I try to compile a R Sweave file? – Amanda R. Sep 11 '19 at 16:17
  • @AmandaR. I don't know R Sweave, but it seems unlikely. The error should complain about not finding Inkscape in that case. What's going to be the same is that some .pdf is created as well as a TeX file that tries to include too many pages from that .pdf. Maybe make an MWE and ask a new question (after making sure your software is up do date). – schtandard Sep 11 '19 at 16:30
  • 1
    I am using inkscape 0.92.4 (5da689c313) and the bug still occurs – blue Dec 05 '19 at 16:32
  • @blue Really? I haven't experienced it for a long time. Also, I think the svg package has had a workaround for quite some time now. Try updating your LaTeX installation and maybe reinstall Inkscape just to be sure. If you still experience the issue, I would have to see an example image that produces the issue. – schtandard Dec 05 '19 at 16:36
  • @schtandard maybe this comment section is not the best place for a bug report, but: inkscape --version prints "Inkscape 0.92.4 5da689c313, 2019-01-14", and I am on archlinux so I assume the package is fairly up to date (and does not lie about the version). You can find the svg at https://file.io/YU2en2 . To be fair, it was initially produced with inkscape v0.92.1 and then opened (and overwritten) with v0.92.4. – blue Dec 05 '19 at 16:57
  • @blue I was talking about updating the svg package (yout LaTeX distribution). Also, yout link does not work for me. But you are right, this is not the best place for this discussion. Maybe ask a new question. – schtandard Dec 06 '19 at 11:52
9

Workaround to avoid layers

The basic idea is to move all the text elements (the ones that will be exported separately to latex) to the top layer.

  1. Open the .svg in inkscape and Ungroup all elements (this action has to be repeated until the tiny squares below the text elements appear)

    enter image description here

    As a result all elements should have their separate box:

    enter image description here

  2. Now select all the text elements, e.g. axis labels, axis titles etc.

    enter image description here

    and move these elements to the topmost layer.

    enter image description here

  3. If you now save the file to .pdf_tex

    enter image description here

    the resulting .pdf should only have one page.

3

The error message

!pdfTeX error: pdflatex (file [...]/most_changed_from_default_pos_0.pdf): PDF inclusion: required page does not exist <18>

does not mean the requested page number with the appended <18>. This number is the total number of pages. That means, the file [...]/most_changed_from_default_pos_0.pdf_tex requests a page number that is not in the range 1 to 18.

Heiko Oberdiek
  • 271,626
  • Thanks a lot for your reply. It would be really nice to know if you could suggest what could be the real issue in this problem. – user3012914 May 06 '15 at 17:38
  • @user3012914 For analyzing the problem, it would be helpful to have the related image files, .svg and the files from the conversion. – Heiko Oberdiek May 06 '15 at 17:56
  • I am trying to find a way how to upload the data here. I am very new to this forum, I couldn't find a way I am sorry for this.... – user3012914 May 06 '15 at 18:00
  • @user3012914 For example, dropbox and friends can be used. – Heiko Oberdiek May 06 '15 at 18:04
  • Hi I have attached the link related to the issue – user3012914 May 06 '15 at 19:20
  • @user3012914 The .pdf_tex file wants to include a non-existent sixth page, thus I assume the export of inkscape failed, bug or whatever reason. Anyway the pie chart looks quite bad (too small fonts, ...) anyway, thus it is easier to redraw a better looking one, see question Package for pie charts. – Heiko Oberdiek May 06 '15 at 21:24
  • I tried with many other files exported from the Inkscape nothing works for me. I even tried with different OS but no success. The issue is that I have so many charts created run time in python which is saved as .svg which I want to upload. So creating chart in Latex is out of my possibility. Is there any solution for this issue. As I feel many others could also stumble upon the same issue. I think the issue is with inkscape. I don't understand what it is actually. – user3012914 May 06 '15 at 21:32
  • Is there any possibility to tell the .pdf_tex about the limitation of page it need to search, hence it could be avoided that it search for non existing 6 th page – user3012914 May 06 '15 at 21:34
  • @user3012914 You can comment the line, which includes the 6th page. (But the pie chart remains ugly looking.) – Heiko Oberdiek May 06 '15 at 22:01
  • Can you please tell me which is the line which includes 6th page? I couldn't trace it – user3012914 May 06 '15 at 23:02
  • 1
    @user3012914 The line with page=6. – Heiko Oberdiek May 07 '15 at 06:22
1

Hey I encountered the same problem. Here's a work around: The different pages Latex want's to include are different layers in inkscape. Try to define everything but your latex commands as one object in inkscape. Then set the text boxes at the correct positions and save as pdf_tex.

Tom
  • 11
1

The bug 1417470 that caused this problem is now fixed in Inkscape.

For Ubuntu, there is an official PPA that has the newest stable: https://launchpad.net/~inkscape.dev/+archive/ubuntu/stable

Laurenz
  • 273
1

I did not experience a fix in the latest Inkscape release which is 1.0.1!

The workarounds provided in this thread are not complete but work sometimes. I can always fix the pdf and the related crash when I move all objects, not only the text, to the first layer and remove all other layers, then tex compiles and the input of the image works. As others metnioned before the layers cause this error but for me it only happens sometimes. Even if I add empty layers or move specific objects to other layers, I cannot reproduce the error. For some reasons the structure of some svg gets buggy.

It is a bit annoying since further edits are somewhat restricted or you have to additionally use the layered version as a backupcopy but finally I can work without this stupid bug.

Miau
  • 121