[Tex/LaTex] \includesvg does not detect SVG file

svg

Input

test.tex:

\documentclass{article}
\usepackage{svg}

\begin{document}

    \includesvg{my-svg-file}

\end{document}

my-svg-file.svg (in the same folder): http://ftp.gwdg.de/pub/ctan/info/svg-inkscape/image.svg

Error output

Process started: "C:\Program Files (x86)\MiKTeX 2.9\miktex\bin\lualatex.exe"  -synctex=1 -interaction=nonstopmode "test".tex

Process exited with error(s)

This is LuaTeX, Version beta-0.70.2-2012060719 (MiKTeX 2.9)  (format=lualatex 2014.1.21)  4 FEB 2014 19:27
**test.tex
(D:/Desktop/TEST/test.tex
LaTeX2e <2011/06/27>
LuaTeX adaptation of babel <v3.8m-luatex-1.5> and hyphenation patterns for engl
ish, loaded.
("C:/Program Files (x86)/MiKTeX 2.9/tex/latex/base/article.cls"
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
("C:/Program Files (x86)/MiKTeX 2.9/tex/latex/base/size10.clo"
File: size10.clo 2007/10/19 v1.4h Standard LaTeX file (size option)
)
\c@part=\count79
\c@section=\count80
\c@subsection=\count81
\c@subsubsection=\count82
\c@paragraph=\count83
\c@subparagraph=\count84
\c@figure=\count85
\c@table=\count86
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\bibindent=\dimen102
)
("C:/Program Files (x86)/MiKTeX 2.9/tex/latex/svg/svg.sty"
Package: svg 2012/09/05 v1.0 SVG inclusion and extraction

("C:/Program Files (x86)/MiKTeX 2.9/tex/latex/xkeyval/xkeyval.sty"
Package: xkeyval 2012/10/14 v2.6b package option processing (HA)

("C:/Program Files (x86)/MiKTeX 2.9/tex/generic/xkeyval/xkeyval.tex"
\XKV@toks=\toks14
\XKV@tempa@toks=\toks15
\XKV@depth=\count87
File: xkeyval.tex 2012/10/14 v2.6b key=value parser (HA)

("C:/Program Files (x86)/MiKTeX 2.9/tex/generic/xkeyval/keyval.tex")))
("C:/Program Files (x86)/MiKTeX 2.9/tex/latex/subfig/subfig.sty"
Package: subfig 2005/06/28 ver: 1.3 subfig package

("C:/Program Files (x86)/MiKTeX 2.9/tex/latex/caption/caption.sty"
Package: caption 2013/05/02 v3.3-89 Customizing captions (AR)

("C:/Program Files (x86)/MiKTeX 2.9/tex/latex/caption/caption3.sty"
Package: caption3 2013/05/02 v1.6-88 caption3 kernel (AR)
Package caption3 Info: TeX engine: e-TeX on input line 57.
\captionmargin=\dimen103
\captionmargin@=\dimen104
\captionwidth=\dimen105
\caption@tempdima=\dimen106
\caption@indent=\dimen107
\caption@parindent=\dimen108
\caption@hangindent=\dimen109
)
\c@ContinuedFloat=\count88
)
\c@KVtest=\count89
\sf@farskip=\skip43
\sf@captopadj=\dimen110
\sf@capskip=\skip44
\sf@nearskip=\skip45
\c@subfigure=\count90
\c@subfigure@save=\count91
\c@lofdepth=\count92
\c@subtable=\count93
\c@subtable@save=\count94
\c@lotdepth=\count95
\sf@top=\skip46
\sf@bottom=\skip47
)
("C:/Program Files (x86)/MiKTeX 2.9/tex/latex/import/import.sty"
Package: import 2009/03/23  v 5.1
)
("C:/Program Files (x86)/MiKTeX 2.9/tex/latex/graphics/graphicx.sty"
Package: graphicx 1999/02/16 v1.0f Enhanced LaTeX Graphics (DPC,SPQR)

("C:/Program Files (x86)/MiKTeX 2.9/tex/latex/graphics/graphics.sty"
Package: graphics 2009/02/05 v1.0o Standard LaTeX Graphics (DPC,SPQR)

("C:/Program Files (x86)/MiKTeX 2.9/tex/latex/graphics/trig.sty"
Package: trig 1999/03/16 v1.09 sin cos tan (DPC)
)
("C:/Program Files (x86)/MiKTeX 2.9/tex/latex/00miktex/graphics.cfg"
File: graphics.cfg 2007/01/18 v1.5 graphics configuration of teTeX/TeXLive
)
Package graphics Info: Driver file: pdftex.def on input line 91.

("C:/Program Files (x86)/MiKTeX 2.9/tex/latex/pdftex-def/pdftex.def"
File: pdftex.def 2011/05/27 v0.06d Graphics/color for pdfTeX

("C:/Program Files (x86)/MiKTeX 2.9/tex/generic/oberdiek/infwarerr.sty"
Package: infwarerr 2010/04/08 v1.3 Providing info/warning/error messages (HO)
)
("C:/Program Files (x86)/MiKTeX 2.9/tex/generic/oberdiek/ltxcmds.sty"
Package: ltxcmds 2011/11/09 v1.22 LaTeX kernel commands for general use (HO)
)
("C:/Program Files (x86)/MiKTeX 2.9/tex/generic/oberdiek/pdftexcmds.sty"
Package: pdftexcmds 2011/11/29 v0.20 Utility functions of pdfTeX for LuaTeX (HO
)

("C:/Program Files (x86)/MiKTeX 2.9/tex/generic/oberdiek/ifluatex.sty"
Package: ifluatex 2010/03/01 v1.3 Provides the ifluatex switch (HO)
Package ifluatex Info: LuaTeX detected.
)
("C:/Program Files (x86)/MiKTeX 2.9/tex/generic/oberdiek/ifpdf.sty"
Package: ifpdf 2011/01/30 v2.3 Provides the ifpdf switch (HO)
Package ifpdf Info: pdfTeX in PDF mode is detected.
)
Package pdftexcmds Info: \pdf@primitive is available.
Package pdftexcmds Info: \pdf@ifprimitive is available.
Package pdftexcmds Info: \pdfdraftmode found.

("C:/Program Files (x86)/MiKTeX 2.9/tex/generic/oberdiek/luatex-loader.sty"
Package: luatex-loader 2010/03/09 v0.4 Lua module loader (HO)

(C:/Program Files (x86)/MiKTeX 2.9/scripts/oberdiek/oberdiek.luatex.lua))
\pdftexcmds@toks=\toks16
)
\Gread@gobject=\count96
))
\Gin@req@height=\dimen111
\Gin@req@width=\dimen112
)
("C:/Program Files (x86)/MiKTeX 2.9/tex/latex/oberdiek/transparent.sty"
Package: transparent 2007/01/08 v1.0 Transparency via pdfTeX's color stack (HO)


("C:/Program Files (x86)/MiKTeX 2.9/tex/latex/oberdiek/auxhook.sty"
Package: auxhook 2011/03/04 v1.3 Hooks for auxiliary files (HO)
))
("C:/Program Files (x86)/MiKTeX 2.9/tex/latex/xcolor/xcolor.sty"
Package: xcolor 2007/01/21 v2.11 LaTeX color extensions (UK)

("C:/Program Files (x86)/MiKTeX 2.9/tex/latex/00miktex/color.cfg"
File: color.cfg 2007/01/18 v1.5 color configuration of teTeX/TeXLive
)
Package xcolor Info: Driver file: pdftex.def on input line 225.
Package xcolor Info: Model `cmy' substituted by `cmy0' on input line 1337.
Package xcolor Info: Model `hsb' substituted by `rgb' on input line 1341.
Package xcolor Info: Model `RGB' extended on input line 1353.
Package xcolor Info: Model `HTML' substituted by `rgb' on input line 1355.
Package xcolor Info: Model `Hsb' substituted by `hsb' on input line 1356.
Package xcolor Info: Model `tHsb' substituted by `hsb' on input line 1357.
Package xcolor Info: Model `HSB' substituted by `hsb' on input line 1358.
Package xcolor Info: Model `Gray' substituted by `gray' on input line 1359.
Package xcolor Info: Model `wave' substituted by `hsb' on input line 1360.
)
\SVG@out@width=\skip48
\SVG@out@height=\skip49
\c@svgfigure=\count97
)
(D:/Desktop/TEST/test.aux)
LaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line 4.
LaTeX Font Info:    ... okay on input line 4.
LaTeX Font Info:    Checking defaults for T1/cmr/m/n on input line 4.
LaTeX Font Info:    ... okay on input line 4.
LaTeX Font Info:    Checking defaults for OT1/cmr/m/n on input line 4.
LaTeX Font Info:    ... okay on input line 4.
LaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line 4.
LaTeX Font Info:    ... okay on input line 4.
LaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line 4.
LaTeX Font Info:    ... okay on input line 4.
LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line 4.
LaTeX Font Info:    ... okay on input line 4.
Package caption Info: Begin \AtBeginDocument code.
Package caption Info: subfig package v1.3 is loaded.
Package caption Info: End \AtBeginDocument code.

("C:/Program Files (x86)/MiKTeX 2.9/tex/context/base/supp-pdf.mkii"
[Loading MPS to PDF converter (version 2006.09.02).]
\scratchcounter=\count98
\scratchdimen=\dimen113
\scratchbox=\box26
\nofMPsegments=\count99
\nofMParguments=\count100
\everyMPshowfont=\toks17
\MPscratchCnt=\count101
\MPscratchDim=\dimen114
\MPnumerator=\count102
\makeMPintoPDFobject=\count103
\everyMPtoPDFconversion=\toks18
)

See the next code block, please.

The relevant parts probably start at this line:

! Undefined control sequence.
\@includesvg ...extracttrue \fi \ifnum \pdfstrcmp 
                                                  {\pdffilemoddate {\SVG@in@...
l.6     \includesvg{my-svg-file}

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

! Missing number, treated as zero.
<to be read again> 
                   {
l.6     \includesvg{my-svg-file}

A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)

! Missing = inserted for \ifnum.
<to be read again> 
                   {
l.6     \includesvg{my-svg-file}

I was expecting to see `<', `=', or `>'. Didn't.

! Missing number, treated as zero.
<to be read again> 
                   {
l.6     \includesvg{my-svg-file}

A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)

! Undefined control sequence.
\@includesvg ...ifnum \pdfstrcmp {\pdffilemoddate 
                                                  {\SVG@in@path #2.svg}}{\pd...
l.6     \includesvg{my-svg-file}

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

! Undefined control sequence.
\@includesvg ...@in@path #2.svg}}{\pdffilemoddate 
                                                  {\SVG@in@path #2.pdf}}>0\i...
l.6     \includesvg{my-svg-file}

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

runsystem(inkscape -z -C -f./my-svg-file.svg -A./my-svg-file.pdf --export-latex
)...disabled.


! LaTeX Error: File `./my-svg-file' not found.

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

l.6     \includesvg{my-svg-file}

I could not locate the file with any of these extensions:
.png,.pdf,.jpg,.mps,.jpeg,.jbig2,.jb2,.PNG,.PDF,.JPG,.JPEG,.JBIG2,.JB2
Try typing  <return>  to proceed.
If that doesn't work, type  X <return>  to quit.


! LaTeX Error: File `./my-svg-file' not found.

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

l.6     \includesvg{my-svg-file}

I could not locate the file with any of these extensions:
.png,.pdf,.jpg,.mps,.jpeg,.jbig2,.jb2,.PNG,.PDF,.JPG,.JPEG,.JBIG2,.JB2
Try typing  <return>  to proceed.
If that doesn't work, type  X <return>  to quit.


! LaTeX Error: File `my-svg-file.pdf_tex' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: pdf_tex)

Enter file name: 
! Emergency stop.
<read *> 

l.6     \includesvg{my-svg-file}


*** (cannot \read from terminal in nonstop modes)



Here is how much of LuaTeX's memory you used:
 3383 strings out of 495011
 100000,128383 words of node,token memory allocated 482 words of node memory still in use:
    nodes
   avail lists: 1:1,2:26,3:1,4:2,6:2,7:1,9:2
 6764 multiletter control sequences out of 65536+200000
 15 fonts using 431807 bytes
 68i,1n,98p,308b,87s stack positions out of 5000i,500n,10000p,200000b,50000s
!  ==> Fatal error occurred, no output PDF file produced!

System

  • Windows 8 Pro 64-bit
  • Inkscape installed and added to PATH (verified)
  • MiKTeX-pdfTeX 2.9.4535 (1.40.13) (MiKTeX 2.9)
  • LuaTeX beta-0.70.2-2012060719

I'm sorry for not being able to further analyze the errors. I've already done some research via Google, but I haven't found any usable result yet. I appreciate every hint!


After incorporating Heiko Oberdiek's code, I get LaTeX Error: File./my-svg-file' not found.. Changing the relative path to an absolute one (D:\Desktop\TEST\my-svg-file` in this case), leads to completely different errors:

Log file
...
! Undefined control sequence.
\\  ->\let \reserved@e 
                       \relax \let \reserved@f \relax \@ifstar {\let \reserv...
l.15    \includesvg{D:\\Desktop\\TEST\\my-svg-file}

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

! Undefined control sequence.
\\  ->\let \reserved@e \relax \let \reserved@f 
                                               \relax \@ifstar {\let \reserv...
l.15    \includesvg{D:\\Desktop\\TEST\\my-svg-file}

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

! Undefined control sequence.
\in@ #1#2->\begingroup \def \in@@ 
                                  ##1#1{}\toks@ \expandafter {\in@@ #2{}{}#1...
l.15    \includesvg{D:\\Desktop\\TEST\\my-svg-file}

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

! Undefined control sequence.
\in@ ...f \in@@ ##1#1{}\toks@ \expandafter {\in@@ 
                                                  #2{}{}#1}\edef \in@@ {\the...
l.15    \includesvg{D:\\Desktop\\TEST\\my-svg-file}

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

! Undefined control sequence.
\in@ ... \expandafter {\in@@ #2{}{}#1}\edef \in@@ 
                                                  {\the \toks@ }\expandafter...
l.15    \includesvg{D:\\Desktop\\TEST\\my-svg-file}

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

! Undefined control sequence.
\in@ #1#2->\begingroup \def \in@@ 
                                  ##1#1{}\toks@ \expandafter {\in@@ #2{}{}#1...
l.15    \includesvg{D:\\Desktop\\TEST\\my-svg-file}

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

! Undefined control sequence.
\in@ ...f \in@@ ##1#1{}\toks@ \expandafter {\in@@ 
                                                  #2{}{}#1}\edef \in@@ {\the...
l.15    \includesvg{D:\\Desktop\\TEST\\my-svg-file}

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

! Undefined control sequence.
\in@ ... \expandafter {\in@@ #2{}{}#1}\edef \in@@ 
                                                  {\the \toks@ }\expandafter...
l.15    \includesvg{D:\\Desktop\\TEST\\my-svg-file}

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

! Undefined control sequence.
<argument> \ifSVG@in@read 

l.15    \includesvg{D:\\Desktop\\TEST\\my-svg-file}

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

)
! Incomplete \iffalse; all text was ignored after line 15.
<inserted text> 
                \fi 
<*> test.tex

The file ended while I was skipping conditional text.
This kind of error happens when you say `\if...' and forget
the matching `\fi'. I've inserted a `\fi'; this might work.

Best Answer

LuaTeX does not provide all primitives of pdfTeX. Many of the missing are implemented by package pdftexcmds via Lua code. Thus the following example makes \pdfstrcmp and \pdffilemoddate available for LuaTeX:

% test.tex
\documentclass{article}

\usepackage{ifluatex}
\ifluatex
  \usepackage{pdftexcmds}
  \makeatletter
  \let\pdfstrcmp\pdf@strcmp
  \let\pdffilemoddate\pdf@filemoddate
  \makeatother
\fi
\usepackage{svg}

\begin{document}
  \includesvg{my-svg-file}
\end{document}

Further remarks and adaptations for Windows:

  • Package svg needs the shell escape feature. If it is not enabled, then the error would be "./my-svg-file not found". The feature can be enabled at the command line, e.g.:

    lualatex --shell-escape test
    

    In MiKTeX the option is also called --enable-write18.

  • Also an installation of inkscape is needed. If inkscape is not in the PATH, then an absolute file name can be specified:

    \setsvg{inkscape={"C:/Program Files/Inkscape/inkscape.exe"= -z -C}}
    
  • ImageMagick is needed for PNG output with convert in the PATH. Or the absolute file name can be tried, e.g.:

    \setsvg{convert={"C:/Program Files/ImageMagick-6.8.0-Q16/convert.exe" -density 300}}
    
  • Package svg uses pdftops of xpdf for EPS output ; the program can be specified in keypdftops`:

    \setsvg{pdftops={"C:/Program Files/.../pdftops.exe" -eps}}
    
  • The next problem for Windows, is that package svg uses the programs mv for moving a file and rm for deleting files. Either the package svg needs to be patched or make a feature request, because these programs are hard-coded in svg.sty and cannot be configured by options.

    Alternatively Cygwin can be installed that should come with these programs.

  • Then hopefully all obstacles for Windows are successfully solved and the remark from the documentation is rendered false:

    this package will not work on Windows

  • Disclaimer: I haven't tried this on Windows, because I am using Linux.