[Tex/LaTex] Issue with auto export of SVG using Inkscape shell-escape

exportinkscapepdftexshell-escapesvg

I am currently struggling with exporting an svg that I prepared in Inkscape and would really appreciate any help or hints. I have been using the MWE from the SVG package documentation ( https://ctan.org/pkg/svg ) in chapter 4. I will provide it here aswell, for the sake of completeness:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{svg}
\usepackage[off]{svg-extract}
\svgsetup{clean=true}
%\pdfsuppresswarningpagegroup=1
\usepackage{relsize}
\usepackage{subcaption}
\begin{document}
    \begin{figure}
        \begin{minipage}{.5\linewidth}
            \includesvg[width=\linewidth]{svg-example}%
            \subcaption{This text is too large!}
        \end{minipage}%
        \begin{minipage}{.5\linewidth}
            \includesvg[width=\linewidth,pretex=\relscale{0.6}]{svg-example}%
            \subcaption{This text fits better.}
        \end{minipage}
        \caption{An example figure with \LaTeX~support}\label{fig:example}
    \end{figure}
    \begin{figure}\centering
        \includesvg[%
        width=.5\linewidth,inkscapelatex=false,extractformat={pdf,eps}%
        ]{svg-example}%
        \caption{The same example figure without \LaTeX~support}
    \end{figure}
\end{document}

I am unsure how to provide the svg I was using, but I promise there exists an "svg-example.svg" in the same directory as the tex file above. I will include it here as a png, but it is in svg format within the directory.

my test svg file

I have shell-escape enabled (–shell-escape as parameter for pdflatex.exe in TeXStudio) as well as Inkscape in the system path. The log, which contains the error messages at the bottom, follows here:

This is pdfTeX, Version 3.14159265-2.6-1.40.20 (MiKTeX 2.9.7200 64-bit) (preloaded format=pdflatex 2019.10.7)  8 OCT 2019 09:30
entering extended mode
**./start.tex
(start.tex
LaTeX2e <2019-10-01>
("C:\Programme\MiKTeX 2.9\tex/latex/base\article.cls"
Document Class: article 2019/08/27 v1.4j Standard LaTeX document class
("C:\Programme\MiKTeX 2.9\tex/latex/base\size10.clo"
File: size10.clo 2019/08/27 v1.4j Standard LaTeX file (size option)
)
\c@part=\count80
\c@section=\count81
\c@subsection=\count82
\c@subsubsection=\count83
\c@paragraph=\count84
\c@subparagraph=\count85
\c@figure=\count86
\c@table=\count87
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\bibindent=\dimen102
)
("C:\Programme\MiKTeX 2.9\tex/latex/base\fontenc.sty"
Package: fontenc 2018/08/11 v2.0j Standard LaTeX package

("C:\Programme\MiKTeX 2.9\tex/latex/base\t1enc.def"
File: t1enc.def 2018/08/11 v2.0j Standard LaTeX file
LaTeX Font Info:    Redeclaring font encoding T1 on input line 48.
))
("C:\Programme\MiKTeX 2.9\tex/latex/svg\svg.sty"
Package: svg 2018/11/12 v2.02b (include SVG pictures)

("C:\Programme\MiKTeX 2.9\tex/latex/koma-script\scrbase.sty"
Package: scrbase 2019/02/01 v3.26b KOMA-Script package (KOMA-Script-independent
 basics and keyval usage)

("C:\Programme\MiKTeX 2.9\tex/latex/graphics\keyval.sty"
Package: keyval 2014/10/28 v1.15 key=value parser (DPC)
\KV@toks@=\toks14
)
("C:\Programme\MiKTeX 2.9\tex/latex/koma-script\scrlfile.sty"
Package: scrlfile 2019/02/01 v3.26b KOMA-Script package (loading files)


LaTeX Warning: Command \InputIfFileExists  has changed.
               Check if current package is valid.

)) ("C:\Programme\MiKTeX 2.9\tex/generic/oberdiek\ifpdf.sty"
Package: ifpdf 2018/09/07 v3.3 Provides the ifpdf switch
)
("C:\Programme\MiKTeX 2.9\tex/generic/oberdiek\ifluatex.sty"
Package: ifluatex 2016/05/16 v1.4 Provides the ifluatex switch (HO)
Package ifluatex Info: LuaTeX not detected.
)
("C:\Programme\MiKTeX 2.9\tex/generic/ifxetex\ifxetex.sty"
Package: ifxetex 2010/09/12 v0.6 Provides ifxetex conditional
)
("C:\Programme\MiKTeX 2.9\tex/generic/oberdiek\pdftexcmds.sty"
Package: pdftexcmds 2019/07/25 v0.30 Utility functions of pdfTeX for LuaTeX (HO
)

("C:\Programme\MiKTeX 2.9\tex/generic/oberdiek\infwarerr.sty"
Package: infwarerr 2016/05/16 v1.4 Providing info/warning/error messages (HO)
)
("C:\Programme\MiKTeX 2.9\tex/generic/oberdiek\ltxcmds.sty"
Package: ltxcmds 2016/05/16 v1.23 LaTeX kernel commands for general use (HO)
)
Package pdftexcmds Info: LuaTeX not detected.
Package pdftexcmds Info: \pdf@primitive is available.
Package pdftexcmds Info: \pdf@ifprimitive is available.
Package pdftexcmds Info: \pdfdraftmode found.
)
("C:\Programme\MiKTeX 2.9\tex/latex/tools\shellesc.sty"
Package: shellesc 2016/06/07 v0.02b unified shell escape interface for LaTeX
Package shellesc Info: Unrestricted shell escape enabled on input line 70.
)
("C:\Programme\MiKTeX 2.9\tex/latex/trimspaces\trimspaces.sty"
Package: trimspaces 2009/09/17 v1.1 Trim spaces around a token list
)
("C:\Programme\MiKTeX 2.9\tex/latex/graphics\graphicx.sty"
Package: graphicx 2017/06/01 v1.1a Enhanced LaTeX Graphics (DPC,SPQR)

("C:\Programme\MiKTeX 2.9\tex/latex/graphics\graphics.sty"
Package: graphics 2019/07/20 v1.3b Standard LaTeX Graphics (DPC,SPQR)

("C:\Programme\MiKTeX 2.9\tex/latex/graphics\trig.sty"
Package: trig 2016/01/03 v1.10 sin cos tan (DPC)
)
("C:\Programme\MiKTeX 2.9\tex/latex/graphics-cfg\graphics.cfg"
File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration
)
Package graphics Info: Driver file: pdftex.def on input line 105.

("C:\Programme\MiKTeX 2.9\tex/latex/graphics-def\pdftex.def"
File: pdftex.def 2018/01/08 v1.0l Graphics/color driver for pdftex
))
\Gin@req@height=\dimen103
\Gin@req@width=\dimen104
)
\svg@box=\box27
\c@svg@param@lastpage=\count88
\c@svg@param@currpage=\count89

("C:\Programme\MiKTeX 2.9\tex/latex/ifplatform\ifplatform.sty"
Package: ifplatform 2017/10/13 v0.4a Testing for the operating system

("C:\Programme\MiKTeX 2.9\tex/generic/oberdiek\catchfile.sty"
Package: catchfile 2016/05/16 v1.7 Catch the contents of a file (HO)

("C:\Programme\MiKTeX 2.9\tex/generic/oberdiek\etexcmds.sty"
Package: etexcmds 2016/05/16 v1.6 Avoid name clashes with e-TeX commands (HO)
))))
("C:\Programme\MiKTeX 2.9\tex/latex/xcolor\xcolor.sty"
Package: xcolor 2016/05/11 v2.12 LaTeX color extensions (UK)

("C:\Programme\MiKTeX 2.9\tex/latex/graphics-cfg\color.cfg"
File: color.cfg 2016/01/02 v1.6 sample color configuration
)
Package xcolor Info: Driver file: pdftex.def on input line 225.
Package xcolor Info: Model `cmy' substituted by `cmy0' on input line 1348.
Package xcolor Info: Model `hsb' substituted by `rgb' on input line 1352.
Package xcolor Info: Model `RGB' extended on input line 1364.
Package xcolor Info: Model `HTML' substituted by `rgb' on input line 1366.
Package xcolor Info: Model `Hsb' substituted by `hsb' on input line 1367.
Package xcolor Info: Model `tHsb' substituted by `hsb' on input line 1368.
Package xcolor Info: Model `HSB' substituted by `hsb' on input line 1369.
Package xcolor Info: Model `Gray' substituted by `gray' on input line 1370.
Package xcolor Info: Model `wave' substituted by `hsb' on input line 1371.
)
("C:\Programme\MiKTeX 2.9\tex/latex/oberdiek\transparent.sty"
Package: transparent 2018/11/18 v1.3 Transparency via pdfTeX's color stack (HO)


("C:\Programme\MiKTeX 2.9\tex/latex/oberdiek\auxhook.sty"
Package: auxhook 2016/05/16 v1.4 Hooks for auxiliary files (HO)
))
("C:\Programme\MiKTeX 2.9\tex/latex/svg\svg-extract.sty"
Package: svg-extract 2018/11/12 v2.02b (extract independent graphics from SVG p
ictures)
\c@svgx@runs=\count90
\c@svgx@out@count=\count91


Package svg Warning: The option key `extract' can only
(svg)                be used with package `svg-extract', but
(svg)                you didn't load it on input line 720.

\svgx@stream@in=\read1
\svgx@stream@out=\write3
) ("C:\Programme\MiKTeX 2.9\tex/latex/relsize\relsize.sty"
Package: relsize 2013/03/29 ver 4.1
)
("C:\Programme\MiKTeX 2.9\tex/latex/caption\subcaption.sty"
Package: subcaption 2019/09/01 v1.3a Sub-captions (AR)

("C:\Programme\MiKTeX 2.9\tex/latex/caption\caption.sty"
Package: caption 2019/09/01 v3.3d Customizing captions (AR)

("C:\Programme\MiKTeX 2.9\tex/latex/caption\caption3.sty"
Package: caption3 2019/09/01 v1.8d caption3 kernel (AR)
Package caption3 Info: TeX engine: e-TeX on input line 64.
\captionmargin=\dimen105
\captionmargin@=\dimen106
\captionwidth=\dimen107
\caption@tempdima=\dimen108
\caption@indent=\dimen109
\caption@parindent=\dimen110
\caption@hangindent=\dimen111
)
\c@caption@flags=\count92
\c@ContinuedFloat=\count93
)
\c@subfigure=\count94
\c@subtable=\count95
) (start.aux)
\openout1 = `start.aux'.

LaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line 9.
LaTeX Font Info:    ... okay on input line 9.
LaTeX Font Info:    Checking defaults for T1/cmr/m/n on input line 9.
LaTeX Font Info:    ... okay on input line 9.
LaTeX Font Info:    Checking defaults for OT1/cmr/m/n on input line 9.
LaTeX Font Info:    ... okay on input line 9.
LaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line 9.
LaTeX Font Info:    ... okay on input line 9.
LaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line 9.
LaTeX Font Info:    ... okay on input line 9.
LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line 9.
LaTeX Font Info:    ... okay on input line 9.

("C:\Programme\MiKTeX 2.9\tex/context/base/mkii\supp-pdf.mkii"
[Loading MPS to PDF converter (version 2006.09.02).]
\scratchcounter=\count96
\scratchdimen=\dimen112
\scratchbox=\box28
\nofMPsegments=\count97
\nofMParguments=\count98
\everyMPshowfont=\toks15
\MPscratchCnt=\count99
\MPscratchDim=\dimen113
\MPnumerator=\count100
\makeMPintoPDFobject=\count101
\everyMPtoPDFconversion=\toks16
) ("C:\Programme\MiKTeX 2.9\tex/latex/oberdiek\epstopdf-base.sty"
Package: epstopdf-base 2016/05/15 v2.6 Base part for package epstopdf

("C:\Programme\MiKTeX 2.9\tex/latex/oberdiek\grfext.sty"
Package: grfext 2016/05/16 v1.2 Manage graphics extensions (HO)

("C:\Programme\MiKTeX 2.9\tex/generic/oberdiek\kvdefinekeys.sty"
Package: kvdefinekeys 2016/05/16 v1.4 Define keys (HO)
))
("C:\Programme\MiKTeX 2.9\tex/latex/oberdiek\kvoptions.sty"
Package: kvoptions 2016/05/16 v3.12 Key value format for package options (HO)

("C:\Programme\MiKTeX 2.9\tex/generic/oberdiek\kvsetkeys.sty"
Package: kvsetkeys 2016/05/16 v1.17 Key value parser (HO)
))
Package epstopdf-base Info: Redefining graphics rule for `.eps' on input line 4
38.
Package grfext Info: Graphics extension search list:
(grfext)             [.pdf,.png,.jpg,.mps,.jpeg,.jbig2,.jb2,.PDF,.PNG,.JPG,.JPE
G,.JBIG2,.JB2,.eps]
(grfext)             \AppendGraphicsExtensions on input line 456.
)
Package caption Info: Begin \AtBeginDocument code.
Package caption Info: End \AtBeginDocument code.
Package svg Info: Calling Inkscape on input line 12.
runsystem(inkscape -z -D --export-latex  --file="svg-example.svg.svg" --export-
pdf="svg-example.svg_svg-tex.pdf" )...executed.



Package svg Warning: The export with Inkscape failed for file
(svg)                `svg-example.svg.svg'
(svg)                Troubleshooting: Please check in the log file how
(svg)                the invocation of Inkscape took place and try to
(svg)                execute it yourself in the terminal on input line 12.


! Package svg Error: File `svg-example.svg_svg-tex.pdf' is missing.

See the svg package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.12            \includesvg[width=\linewidth]{svg-example}
                                                  %
Did you run the export with Inkscape? There's no file
`./svg-inkscape/svg-example.svg_svg-tex.pdf'
although `svg-example.svg.svg' was found.


! Package svg Error: File `svg-example.svg_svg-tex.pdf_tex' is missing.

See the svg package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.12            \includesvg[width=\linewidth]{svg-example}
                                                  %
Did you run the export with Inkscape? There's no file
`./svg-inkscape/svg-example.svg_svg-tex.pdf_tex'
although `svg-example.svg.svg' was found.

LaTeX Font Info:    External font `cmex10' loaded for size
(Font)              <7> on input line 14.
LaTeX Font Info:    External font `cmex10' loaded for size
(Font)              <5> on input line 14.
Package svg Info: Calling Inkscape on input line 16.
runsystem(inkscape -z -D --export-latex  --file="svg-example.svg.svg" --export-
pdf="svg-example.svg_svg-tex.pdf" )...executed.


Package svg Warning: The export with Inkscape failed for file
(svg)                `svg-example.svg.svg'
(svg)                Troubleshooting: Please check in the log file how
(svg)                the invocation of Inkscape took place and try to
(svg)                execute it yourself in the terminal on input line 16.


! Package svg Error: File `svg-example.svg_svg-tex.pdf' is missing.

See the svg package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.16 ...ewidth,pretex=\relscale{0.6}]{svg-example}
                                                  %
Did you run the export with Inkscape? There's no file
`./svg-inkscape/svg-example.svg_svg-tex.pdf'
although `svg-example.svg.svg' was found.


! Package svg Error: File `svg-example.svg_svg-tex.pdf_tex' is missing.

See the svg package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.16 ...ewidth,pretex=\relscale{0.6}]{svg-example}
                                                  %
Did you run the export with Inkscape? There's no file
`./svg-inkscape/svg-example.svg_svg-tex.pdf_tex'
although `svg-example.svg.svg' was found.


! Package svg Error: File `svg-example.svg_svg-raw.pdf' is missing.

See the svg package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.24        ]{svg-example}
                     %
Did you run the export with Inkscape? There's no file
`./svg-inkscape/svg-example.svg_svg-raw.pdf'
although `svg-example.svg.svg' was found.

[1{C:/Users/<censored>/AppData/Local/MiKTeX/2.9/pdftex/config/pdftex.map}]
(start.aux) ) 
Here is how much of TeX's memory you used:
 4411 strings out of 492452
 70714 string characters out of 3131664
 158995 words of memory out of 50000000
 8719 multiletter control sequences out of 15000+200000
 5936 words of font info for 17 fonts, out of 3000000 for 9000
 1141 hyphenation exceptions out of 8191
 48i,7n,65p,279b,446s stack positions out of 5000i,500n,10000p,200000b,50000s
 <C:\Users\<censored>\AppData\Local\MiKTeX\2.9\fonts/pk/ljfour/jknappen
/ec/dpi600\ecrm0700.pk> <C:\Users\<censored>\AppData\Local\MiKTeX\2.9\fonts/pk/ljfou
r/jknappen/ec/dpi600\ecrm1000.pk> <C:\Users\<censored>\AppData\Local\MiKTeX\2.9\font
s/pk/ljfour/jknappen/ec/dpi600\ecrm0900.pk>
Output written on start.pdf (1 page, 16378 bytes).
PDF statistics:
 63 PDF objects out of 1000 (max. 8388607)
 0 named destinations out of 1000 (max. 500000)
 1 words of extra memory for PDF output out of 10000 (max. 10000000)

My obvious guess is that for some reason it puts ".svg.svg" (i.e. the file extension twice) after the file name, but I have absolutely no idea why it does that, and also no idea how to fix it.

I have tried converting the svg files to pdf manually, i.e.
inkscape -z -D --export-latex --file="svg-example.svg" --export-pdf="svg-example.svg_svg-tex.pdf" (please note that I changed the ".svg.svg" into ".svg"), which did work and created the pdf file correctly. However, when placing the 2 files into the subdirectory "svg-inkscape", it still does not work, and I get the errors:

LaTeX Warning: File `{./svg-inkscape/"svg-example.svg"_svg-tex}.pdf' not found 
on input line 52.


! LaTeX Error: Unknown graphics extension: .svg_svg-tex}.pdf.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.52 ...\unitlength]{svg-example.svg_svg-tex.pdf}}
                                                  %
Try typing  <return>  to proceed.
If that doesn't work, type  X <return>  to quit.

)
LaTeX Font Info:    External font `cmex10' loaded for size
(Font)              <7> on input line 14.
LaTeX Font Info:    External font `cmex10' loaded for size
(Font)              <5> on input line 14.
Package svg Info: Last page of `./svg-inkscape/"svg-example.svg"_svg-tex.pdf' i
s 1 on input line 16.
 (svg-inkscape/svg-example.svg_svg-tex.pdf_tex

LaTeX Warning: File `{./svg-inkscape/"svg-example.svg"_svg-tex}.pdf' not found 
on input line 52.


! LaTeX Error: Unknown graphics extension: .svg_svg-tex}.pdf.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.52 ...\unitlength]{svg-example.svg_svg-tex.pdf}}
                                                  %
Try typing  <return>  to proceed.
If that doesn't work, type  X <return>  to quit.

)

! Package svg Error: File `svg-example.svg_svg-raw.pdf' is missing.

See the svg package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.24        ]{svg-example}
                     %
Did you run the export with Inkscape? There's no file
`./svg-inkscape/svg-example.svg_svg-raw.pdf'
although `svg-example.svg.svg' was found.

The generated files from Inkscape are there in the correct folder, however! I guess this is due to quotation marks, the curly bracket or sth, but I really dont know what is causing this and how I can fix it.

This is my first post here on Stackexchange, so if I forgot to provide some info, please let me know! I'm really grateful for any help, so that I can continue writing my thesis, and stop having to waste hours and hours on this!

Best regards,

Tripedior

Best Answer

This is a non-answer but I wanted to post the code, I'll post a full answer here once the eventual fix is worked out.

Could you test this with your svg?

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{svg}
\usepackage[off]{svg-extract}
\svgsetup{clean=true}
%\pdfsuppresswarningpagegroup=1
\usepackage{relsize}
\usepackage{subcaption}
\makeatletter
\def\set@curr@file#1{\def\@curr@file{#1}}
\makeatother
\begin{document}
    \begin{figure}
        \begin{minipage}{.5\linewidth}
            \includesvg[width=\linewidth]{svg-example}%
            \subcaption{This text is too large!}
        \end{minipage}%
        \begin{minipage}{.5\linewidth}
            \includesvg[width=\linewidth,pretex=\relscale{0.6}]{svg-example}%
            \subcaption{This text fits better.}
        \end{minipage}
        \caption{An example figure with \LaTeX~support}\label{fig:example}
    \end{figure}
    \begin{figure}\centering
        \includesvg[%
        width=.5\linewidth,inkscapelatex=false,extractformat={pdf,eps}%
        ]{svg-example}%
        \caption{The same example figure without \LaTeX~support}
    \end{figure}
\end{document}