4

I'm using TexMaker on Mac and try to include some svg's to my document.

I think my question is very similar to this one svg package failing to find svg files But I can't solve my problem.

  • I already installed inkscape and XQuartz
  • Console: which inkscape = /usr/local/bin/inkscape (seems to be good)
  • Console: inkscape -z -D --file=/Users/myName/Desktop/_Images/image.svg --export-pdf=/Users/myName/Desktop/_Images/image.pdf --export-latex generates all files! (seems to be good)
  • I added --shell-escape to PdfLaTeX and LuaLaTex enter image description here

MWE

\documentclass{article}
\usepackage{svg}
\usepackage{amsmath}
\begin{document}

\begin{figure}[htbp]
  \centering
  \includesvg{_Images/image}
  \caption{svg image}
\end{figure}

\end{document}

TexMake error message:

! Package svg Error: File `image.svg' is missing.See the svg package documentation for explanation.Type H for immediate help.... \includesvg{_Images/image}

UPDATE

If I put the image.svg in the root directory and call \includesvg{image} the error message changes to:

! Package svg Error: File `image_svg-tex.pdf' is missing.See the svg package documentation for explanation.Type H for immediate help.... \includesvg{image}

and

! Package svg Error: File `image_svg-tex.pdf_tex' is missing.See the svg package documentation for explanation.Type H for immediate help.... \includesvg{image}

and

The export with Inkscape failed for file(svg) `image.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

UPDATE 2

As mentioned in the comments I don't use another output path now! enter image description here

7
  • Its critical that anywhere (not just from the inkscape location) from a system command line you can get a response from inkscape -V to show it is accessible via --shell-escape thus must be on "path" also the target file path must be "clear" avoid long paths with spaces and relative _Images (no punctuation accents capitals etc.) First test if it works in the same folder as the.tex THEN try ./_images/filetoinclude or other relative combinations
    – user170109
    Commented Feb 9, 2019 at 15:04
  • Looking at your commands as show you are working with -output dir = build , this is highly NOT recommended whilst experiencing path issues unless you have successfully tested in the default directory i.e where main tex is otherwise how do commands now which location to run in is it /build/ is it main is it /_Images/ or where else on texmf paths ? For any issue simplify to main.tex location then mess about with input and output locations but expect hiccups that nobody else can guess at
    – user170109
    Commented Feb 9, 2019 at 15:21
  • I included \setsvg{inkscape = inkscape -z -D} to the preamble. I get this warning: 'Setting the executable and associated options(svg) for Inkscape should be done with options(svg) inkscapeexe=inkscape'(svg) and inkscapeopt=-z -D'.'
    – Pascal
    Commented Feb 9, 2019 at 16:38
  • I can use it like this: \usepackage[inkscapeopt = inkscape -z -D]{svg}
    – Pascal
    Commented Feb 9, 2019 at 17:17
  • I have now updated to latest {svg} and InkScape so have deleted some misleading comments based on old advice
    – user170109
    Commented Feb 9, 2019 at 19:08

2 Answers 2

5

Note that, whilst the questioner has accepted this answer, their problem with \usepackage{svg) has NOT been resolved (see comments below). This is in part due to a known problem with Latex calling Inkscape in Mac OS. The workaround wrapper needs to be called in the same way that Inkscape would normally be. Thus it needs to EITHER be in the $PATH OR called from the editor at a fixed absolute location, the same way as described below. See the wrapper here and the closed issue here

There are at least two packages that interact between .svg / .pdf_tex and inkscape and this answer only addresses one i.e. {svg} thus NOT the {svg-inkscape} package.

There have been a few changes since earlier versions of {svg} (notably use with \pkg{polyglossia} and \pkg{tikzscale}) at present these observations relate to version 2.02b which is the latest in a currently updated MiKTeX (2019) or Tex Live (2018+), both were updated in January 2019. Some older advice is thus misleading but the basics are still the same. Do not expect all older .svg file examples to behave as documented, in those cases raise a separate question. One factor I have not tested is the variations as a result of Inkscape versions (traditionally 0.4x currently 0.9x and soon to be 1.0 upwards) these observations are based on current 0.92.4

This answer is purely how to invoke Inkscape to build hybrid svg files For those already exported from Inkscape you can use \input{images/image.pdf_tex}
This answer is NOT aimed to address why imported results with figure numbers do not function as anticipated.  
It is assumed you have installed the package via one of the two main tex managers. I am going to ignore any issues related to downloading to a personal texmf/TDS location (just DON'T).

Whilst testing your setup, place your .svg file in the same folder as your .tex file (note the enhanced MWE below, in answering the question, looks in an _Images subfolder, and can be adjusted to work with a fixed location, so either edit to remove _Images/ or place your .svg in the .tex folder and a library folder), then you will not get the initial inevitable File 'image.svg' is missing message.
You may see in the log

There's no file 'image.svg' neither in the current directory nor any other searched path given by \svgpath or \graphicspath. Following folders have additionally been searched: 

 
1) -shell-escape must be active for both the call to Inkscape and the building of the output files and folders, otherwise the log will show confusingly a number of errors
! Package svg Error: File 'image_svg-tex.pdf' is missing. See the svg package documentation for explanation. Did you run the export with Inkscape? There's no file './svg-inkscape/image_svg-tex.pdf' although '_Images/image.svg' was found. ! Package svg Error: File 'image_svg-tex.pdf_tex' is missing. See the svg package documentation for explanation. Did you run the export with Inkscape? There's no file './svg-inkscape/image_svg-tex.pdf' although '_Images/image.svg' was found.

What you are looking for is

"Package svg Warning: You didn't enable 'shell escape' (or 'write18') so it wasn't possible to launch the Inkscape export for '_Images/image.svg' on input line"  

 
2) It is critical Inkscape is active system wide thus available via a system call along "system path". The default action is to call InkScape with the required settings, so do not try to add any of -z -D --export-latex. IF Inkscape is not on path, incorrectly set or otherwise inaccessible you will again see multiple errors as above, and

"Package svg Warning: The export with Inkscape failed for file 'yourimagepath/filename.svg' Troubleshooting: Please check in the log file how the invocation of Inkscape took place and try to execute it yourself in the terminal on input line"

! Package svg Error: File `imagefilename_svg-tex.pdf' is missing etc. etc.

what we should not from the log is

Package svg Info: Calling Inkscape on input line ##. 
runsystem(inkscape -z -D --export-latex --file="_Images/image.svg" --export-pdf="image_svg-tex.pdf" )...executed

On windows you may see after that the not unfamiliar line

'inkscape' is not recognized as an internal or external command, operable program or batch file.   

For Texmaker you can easily add the path to your existing folders at lower left of Option > Configure > Commands NOTE syntax can be different On Mac a colon is used as path separator, whilst on Windows a semicolon is used to prefix a separate path. Remember it is the folder not the executable that needs to be added and on a Mac that may be /Applications/Inkscape.app/Contents/Resources/bin On windows it will probably be in either one of two c:\program files\inkscape folders

NOTE this fix is only applicable to running InkScape from the editor. If you wish to use it system wide (including from a command line console) Either a symbolic link in Mac see https://stackoverflow.com/questions/22085168/inkscape-command-line-where-is-it-on-mac#comment47253346_22085247

For windows users a system path addition will be required. See a guide at https://helpdeskgeek.com/windows-10/add-windows-path-environment-variable/

enter image description here

If on a Mac we "add to path" (as shown above) or in the preamble the correct Inkscape binary location e.g. /Applications/Inkscape.app/Contents/Resources/bin then we should expect a reasonable run of Inkscape shown in the log

NOTE Inkscape wiki still makes reference to an alias issue on Mac OS X and recommends \newcommand 's to try to deal with path issues.

However since we never seemed to achieve a successful call to Inkscape from the editor first on the MAC I have removed them here

For TeXworks (Windows) users there is a similar easy fix to add the Inkscape path here https://tex.stackexchange.com/a/474119/170109

 
3) If in a subfolder the source file.svg must be on a clearly defined / terminated path/, see my comments in the MWE, otherwise you will see similar to above (but only 2nd part)

!  Package svg Error: File 'imagefilename_svg-tex.pdf' is missing.

You can get the same fail if there are problems building the subdirectory svg-inkscape in the working folder. This may be confirmed within the log if you see something like

Access is denied. Access is denied. Access is denied.

Do not use older options for image path, otherwise you may see

"Package svg Warning: The key 'svgpath' is deprecated. It's recommended to use '\svgpath' instead on input line ##"  

 
Amended Generic MWE

\listfiles 
\documentclass[]{scrreprt}% Test
\usepackage[T1]{fontenc}
%\usepackage{amsmath}
\usepackage{hyperref}
\usepackage{subcaption}

\usepackage[]{graphicx}
% \usepackage[options]{graphicx} % if used [with or without options], this package must be before {svg} see readme
\usepackage{svg} % Version 2 will run inkscape -z -D --export-latex  --file="filename.svg" --export-pdf="filename_svg-tex.pdf
% or comment out above and uncomment alternate next line where we specify the location of the Inkscape binary (Note start with / do not add to the end) this is where I tested a path to a bin containing inkscape. For a Mac it may differ if using the wrapper fix as described at https://github.com/mrpiggi/svg/issues/1
% \usepackage[inkscapeexe=/Applications/Inkscape.app/Contents/Resources/bin/inkscape]{svg}

\usepackage{svg-extract} % as and when required
% \svgsetup{clean=true} % remove temporary files
\providecommand{\transparent}[1]{} % see manual
% \pdfsuppresswarningpagegroup=1 % hot fix if required, see manual
\usepackage{relsize} % required for adjusting text using relscale

% we can change the input folder to a group of alternative locations & here one is the subdir _Images/ as requested
\svgpath{{_Images/}{/usr/local/svg/}{/MyDocs/MySVGs/}} % paths must be / terminated and IF a subdir NOT start with /
% On success by default the outputs will be in a new subdirectory as svg-inkscape/filename_svg-tex.pdf and filename_svg-tex.pdf_tex  

\begin{document}

\begin{figure}
\begin{minipage}{.5\linewidth}

\includesvg[width=\linewidth]{svg-example}%
\subcaption{Default text is too large!}

\end{minipage}%
\begin{minipage}{.5\linewidth}

\includesvg[width=\linewidth,pretex=\relscale{0.6}]{svg-example}%
\subcaption{This scaled text fits better.}

\end{minipage}
\caption{An example figure with \LaTeX~support}\label{fig:svg-example}
\end{figure}

\begin{figure}
\begin{minipage}{.5\linewidth}

\includesvg[inkscapelatex=false,extractformat={pdf,eps}]{svg-example}
\subcaption{Above example figure without \LaTeX~support}%

\end{minipage}
\begin{minipage}{.5\linewidth}\centering
\includesvg[width=1.2\linewidth,pretex=\relscale{0.85},angle=-10]{root}
\subcaption{Rendering of a ROOT plot, even @ an angle}\label{fig:root}
\end{minipage}
\end{figure}

\end{document}

We may still get warnings on the first run, and its not much better on the second run when we may use \input{images/image.pdf_tex} (but that's a separate Question)
Here is the raw result with the example .svg's as located in your "TeX....texmf/doc/latex/svg/examples/" documents folder.

![enter image description here

10
  • I tried this without success. As you mentioned, I think the second point is my issue. Maybe it's a hint, that the folder /usr/local/ svg/ doesn't exist.
    – Pascal
    Commented Feb 9, 2019 at 23:00
  • no /usr/local/svg is meaningless on my system that was just an example of adding second or multiple locations such as a library of svg's. PATH to inkscape is your current issue in some editors (just answered similar for TeXworks) it is possible to set support folders for executable files thus just add the inkscape folder to that list of directories but I don't know if texmake has that same ability
    – user170109
    Commented Feb 9, 2019 at 23:12
  • hinzufügen means add, so windows and mac should have the same ability to add path. I added: Applications/Inkscape.app/Contents/Resources/bin/inkscape in this textfield but without success...
    – Pascal
    Commented Feb 9, 2019 at 23:50
  • I am not sure if that is right I expected something like /usr/local/bin or /Applications/Inkscape.app/Contents/Resources/bin/inkscape-bin possibly without the /inkscape-bin see stackoverflow.com/questions/22085168/…
    – user170109
    Commented Feb 10, 2019 at 0:07
  • 1
    Hope you don't mind if I still add to edits on your well raised question since the saga related to more recent svg package changes is continuing cross platform (unfortunately with no yet apparent resolution for Mac which is down for addressing in later versions sorry) good luck with the alternatives
    – user170109
    Commented Feb 11, 2019 at 18:08
1

I am afraid that a part of the problem lies within the svg package, which calls inkscape with options -z and --file, neither of which is valid in the current version 1.0 (2020-05-01).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .