Arlex Marín
Arlex Marín

Reputation: 71

Inkscape "PDF + Latex" export

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?

Upvotes: 6

Views: 14600

Answers (4)

Zach
Zach

Reputation: 616

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).

Upvotes: 3

rzach
rzach

Reputation: 171

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.

Upvotes: 7

weymouth
weymouth

Reputation: 541

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.

Upvotes: 3

Kurt Pfeifle
Kurt Pfeifle

Reputation: 90213

Try it with an illustration that is less wide.

Alternatively, use a wider paperwidth setting.

Upvotes: 0

Related Questions