Export Inkscape "PDF + Latex"
I use inkscape to create vector shapes, save them as SVG to export later as "PDF + Latex", mostly in the TUG inkscape + pdflatex tutorial.
Trying to create a simple shape, however, turns out to be extremely depressing.
The first digit http://i.stack.imgur.com/jIo3z.png is an example of a drawing that I would like to export as "PDF + Latex" (shown here in PNG format).
If I export this value to PDF without latex macros, the generated PDF looks exactly the same except for some minor differences from the fonts used to render the text.
When I try to export it using the "PDF + Latex" option, the resulting PDF consists of 2 pages PDF document: http://i.stack.imgur.com/I9kdf.png
It certainly looks bad when compiling my latex document. The TUG tutorial has been very helpful so far, but I still cannot create a working "PDF + Latex" export from inkscape.
What am I doing wrong?
source to share
I asked this question on the Inkscape online talk page and got some helpful advice from one of the users.
This is a known bug https://bugs.launchpad.net/ubuntu/+bug/1417470 that was inadvertently introduced in Inkscape 0.91 in an attempt to fix a previous bug https://bugs.launchpad.net/inkscape/+bug/771957 .
This error seems to do two things:
- The * .pdf_tex file will have an extra operator
\includegraphics
that needs to be removed manually as described in the bug link above. - The * .pdf file can be split into several pages, regardless of the size of the image. In my case, the line objects were split into their own page. I worked around this by turning off text objects (opacity to zero) and then doing a standard PDF export.
source to share
If you can run 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;
from:
- $ SVGFILE: path to svg
- $ PDF_FILE: path to PDF
It is possible to include these commands in a script and execute it automatically when you compile your tex file (so you don't need to manually export from Inkscape every time you change your SVG).
source to share