7

I'm using inkscape to produce vector figures, save them in SVG format to export them later as "PDF + Latex" much in the vein of TUG inkscape+pdflatex guide.

Trying to produce a simple figure, however, turns out to be extremely frustating.

The first figure enter image description here is an example of the figure I would like to export in the form of "PDF + Latex" (shown here in PNG format).

If I export this to a PDF figure without latex macros the PDF produced looks exactly the same, except for some minor differences with the fonts used to render the text.

When I try to export this using the "PDF + Latex" option the PDF file produced consists on a PDF document of 2 pages (again as .png here): enter image description here

This, of course, does not looks good when compiling my latex document. So far the guide at TUG has been very helpful, but I still can't produce a working "PDF + Latex" export from inkscape.

What am I doing wrong?

Cadoiz
  • 1,446
  • 21
  • 31
Arlex Marín
  • 81
  • 1
  • 1
  • 4
  • 1
    I am having the same problem. I just upgraded to inkscape 0.91 and figures that previous exported correctly are now turned into 2-page PDFs. Any solutions? – weymouth Aug 19 '15 at 02:41
  • This feature is no longer broken: https://gitlab.com/inkscape/inkscape/merge_requests/13 (this hint comes from https://tex.stackexchange.com/users/31788/vog ) – Cadoiz Feb 03 '21 at 11:38

4 Answers4

7

I worked around this by putting all the text in my drawing at the top

select text and then Object -> Raise to top

Inkscape only generates the separate pages if the text is below another object.

zx485
  • 28,498
  • 28
  • 50
  • 59
rzach
  • 171
  • 1
  • 1
  • 2
    Worked! I created another layer on top all layers and pushed all my text to that top most layer. – jcchuks Jan 13 '17 at 20:12
4

I asked this question on the Inkscape online discussion page and got some very helpful guidance from one of the users there.

This is a known bug https://bugs.launchpad.net/ubuntu/+bug/1417470 which was inadvertently introduced in Inkscape 0.91 in an attempt to fix a previous bug https://bugs.launchpad.net/inkscape/+bug/771957.

It seems this bug does two things:

  1. The *.pdf_tex file will have an extra \includegraphics statement which needs to be deleted manually as described in the link to the bug above.
  2. The *.pdf file may be split into multiple pages, regardless of the size of the image. In my case the line objects were split off onto their own page. I worked around this by turning off the text objects (opacity to zero) and then doing a standard PDF export.
weymouth
  • 521
  • 6
  • 17
  • 1
    A patch was merged a week ago https://gitlab.com/inkscape/inkscape/merge_requests/13 hooray! – astrojuanlu Jun 28 '17 at 13:29
  • To avoid the bug on multiple pages, you can use the following commands in a shell script in which ${PDFFILE}_tex corresponds to the path of .pdf_tex file: sed -i 's/\\\\/\n/g' ${PDFFILE}_tex; MAXPAGE=$(pdfinfo $PDFFILE | grep -oP "(?<=Pages:)\s*[0-9]+" | tr -d " "); sed -i "/page=$(($MAXPAGE+1))/,\${/page=/d}" ${PDFFILE}_tex; – Zach Oct 20 '17 at 18:45
3

If you can execute linux commands, this works:

# Generate the .pdf and .pdf_tex files
inkscape -z -D --file="$SVGFILE" --export-pdf="$PDFFILE" --export-latex

# Fix the number of pages
sed -i 's/\\\\/\n/g' ${PDFFILE}_tex; 
MAXPAGE=$(pdfinfo $PDFFILE | grep -oP "(?<=Pages:)\s*[0-9]+" | tr -d " "); 
sed -i "/page=$(($MAXPAGE+1))/,\${/page=/d}" ${PDFFILE}_tex; 

with:

  • $SVGFILE: path of the svg
  • $PDF_FILE: path of the pdf

It is possible to include these commands in a script and execute it automatically when compiling your tex file (so that you don't have to manually export from inkscape each time you modify your svg).

Zach
  • 600
  • 5
  • 16
0

Try it with an illustration that is less wide.

Alternatively, use a wider paperwidth setting.

Kurt Pfeifle
  • 86,724
  • 23
  • 248
  • 345
  • I'm having the same problem and it has nothing to do with the paper width. The illustration is very small and fully within the paper. It is splitting the illustration into 2 parts - one for the arrows and one for the shapes. Suggestions? – weymouth Aug 19 '15 at 03:00
  • yes, this turns out to be a version specific issue. – weymouth Aug 20 '15 at 07:54