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

1
  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. A suggestion: Do us a favour and change your username to something more telling than "user1234". May 7, 2015 at 14:50

6 Answers 6

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]

10
  • This bug is still happening to me on 0.92.2 (mac)
    – level1807
    Feb 16, 2019 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, 2019 at 16:51
  • 0.92.4 isn't available on mac as a binary yet, so I'll have to wait until it is.
    – level1807
    Feb 18, 2019 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, 2019 at 20:57
  • 1
    I am using inkscape 0.92.4 (5da689c313) and the bug still occurs
    – blue
    Dec 5, 2019 at 16:32
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.

4
  • Has anyone verified that this works? For me, for three different documents, this does nothing. (Inkscape 0.92.3, compiling with PDFLaTeX 3.14159265-2.6-1.40.18) Dec 7, 2019 at 0:14
  • 1
    @EricTowers Works for me.
    – tush
    Apr 4, 2021 at 14:20
  • @tush : ... and in what way, if any, is your configuration different from mine? Apr 5, 2021 at 2:09
  • Inkscape 1.0.1 on Windows 7 64bit, and I also cross checked on Mac OS 10 (same Inkscape version).
    – tush
    Apr 5, 2021 at 12:02
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.

11
  • 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. May 6, 2015 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. May 6, 2015 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.... May 6, 2015 at 18:00
  • @user3012914 For example, dropbox and friends can be used. May 6, 2015 at 18:04
  • 1
    @user3012914 The line with page=6. May 7, 2015 at 6: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.

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

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.

You must log in to answer this question.

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