Texmaker (& similar) - How to usepackage{svg} especially on Mac OS
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
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!
texmaker editors mac include svg
|
show 3 more comments
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
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!
texmaker editors mac include svg
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
– KJO
2 days ago
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
– KJO
2 days ago
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'.'
– Passe
2 days ago
Thank's for your help!
– Passe
2 days ago
I can use it like this: usepackage[inkscapeopt = inkscape -z -D]{svg}
– Passe
2 days ago
|
show 3 more comments
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
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!
texmaker editors mac include svg
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
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!
texmaker editors mac include svg
texmaker editors mac include svg
edited 2 mins ago
KJO
2,2971118
2,2971118
asked 2 days ago
PassePasse
23819
23819
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
– KJO
2 days ago
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
– KJO
2 days ago
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'.'
– Passe
2 days ago
Thank's for your help!
– Passe
2 days ago
I can use it like this: usepackage[inkscapeopt = inkscape -z -D]{svg}
– Passe
2 days ago
|
show 3 more comments
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
– KJO
2 days ago
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
– KJO
2 days ago
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'.'
– Passe
2 days ago
Thank's for your help!
– Passe
2 days ago
I can use it like this: usepackage[inkscapeopt = inkscape -z -D]{svg}
– Passe
2 days ago
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
– KJO
2 days ago
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
– KJO
2 days ago
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
– KJO
2 days ago
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
– KJO
2 days ago
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'.'– Passe
2 days ago
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'.'– Passe
2 days ago
Thank's for your help!
– Passe
2 days ago
Thank's for your help!
– Passe
2 days ago
I can use it like this: usepackage[inkscapeopt = inkscape -z -D]{svg}
– Passe
2 days ago
I can use it like this: usepackage[inkscapeopt = inkscape -z -D]{svg}
– Passe
2 days ago
|
show 3 more comments
1 Answer
1
active
oldest
votes
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 filesinkscape 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/
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}{.5linewidth}
includesvg[width=linewidth]{svg-example}%
subcaption{Default text is too large!}
end{minipage}%
begin{minipage}{.5linewidth}
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}{.5linewidth}
includesvg[inkscapelatex=false,extractformat={pdf,eps}]{svg-example}
subcaption{Above example figure without LaTeX~support}%
end{minipage}
begin{minipage}{.5linewidth}centering
includesvg[width=1.2linewidth,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.
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.
– Passe
2 days ago
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
– KJO
2 days ago
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...
– Passe
2 days ago
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/…
– KJO
2 days ago
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
– KJO
9 hours ago
|
show 5 more comments
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f474052%2ftexmaker-similar-how-to-usepackagesvg-especially-on-mac-os%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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 filesinkscape 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/
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}{.5linewidth}
includesvg[width=linewidth]{svg-example}%
subcaption{Default text is too large!}
end{minipage}%
begin{minipage}{.5linewidth}
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}{.5linewidth}
includesvg[inkscapelatex=false,extractformat={pdf,eps}]{svg-example}
subcaption{Above example figure without LaTeX~support}%
end{minipage}
begin{minipage}{.5linewidth}centering
includesvg[width=1.2linewidth,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.
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.
– Passe
2 days ago
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
– KJO
2 days ago
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...
– Passe
2 days ago
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/…
– KJO
2 days ago
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
– KJO
9 hours ago
|
show 5 more comments
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 filesinkscape 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/
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}{.5linewidth}
includesvg[width=linewidth]{svg-example}%
subcaption{Default text is too large!}
end{minipage}%
begin{minipage}{.5linewidth}
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}{.5linewidth}
includesvg[inkscapelatex=false,extractformat={pdf,eps}]{svg-example}
subcaption{Above example figure without LaTeX~support}%
end{minipage}
begin{minipage}{.5linewidth}centering
includesvg[width=1.2linewidth,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.
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.
– Passe
2 days ago
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
– KJO
2 days ago
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...
– Passe
2 days ago
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/…
– KJO
2 days ago
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
– KJO
9 hours ago
|
show 5 more comments
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 filesinkscape 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/
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}{.5linewidth}
includesvg[width=linewidth]{svg-example}%
subcaption{Default text is too large!}
end{minipage}%
begin{minipage}{.5linewidth}
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}{.5linewidth}
includesvg[inkscapelatex=false,extractformat={pdf,eps}]{svg-example}
subcaption{Above example figure without LaTeX~support}%
end{minipage}
begin{minipage}{.5linewidth}centering
includesvg[width=1.2linewidth,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.
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 filesinkscape 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/
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}{.5linewidth}
includesvg[width=linewidth]{svg-example}%
subcaption{Default text is too large!}
end{minipage}%
begin{minipage}{.5linewidth}
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}{.5linewidth}
includesvg[inkscapelatex=false,extractformat={pdf,eps}]{svg-example}
subcaption{Above example figure without LaTeX~support}%
end{minipage}
begin{minipage}{.5linewidth}centering
includesvg[width=1.2linewidth,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.
edited 42 mins ago
answered 2 days ago
KJOKJO
2,2971118
2,2971118
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.
– Passe
2 days ago
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
– KJO
2 days ago
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...
– Passe
2 days ago
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/…
– KJO
2 days ago
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
– KJO
9 hours ago
|
show 5 more comments
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.
– Passe
2 days ago
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
– KJO
2 days ago
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...
– Passe
2 days ago
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/…
– KJO
2 days ago
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
– KJO
9 hours ago
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.
– Passe
2 days ago
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.
– Passe
2 days ago
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
– KJO
2 days ago
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
– KJO
2 days ago
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...
– Passe
2 days ago
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...
– Passe
2 days ago
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/…
– KJO
2 days ago
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/…
– KJO
2 days ago
1
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
– KJO
9 hours ago
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
– KJO
9 hours ago
|
show 5 more comments
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f474052%2ftexmaker-similar-how-to-usepackagesvg-especially-on-mac-os%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
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
– KJO
2 days ago
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
– KJO
2 days ago
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'.'– Passe
2 days ago
Thank's for your help!
– Passe
2 days ago
I can use it like this: usepackage[inkscapeopt = inkscape -z -D]{svg}
– Passe
2 days ago