mrpiggi / svg Goto Github PK
View Code? Open in Web Editor NEWHandling SVG pictures in LaTeX documents using Inkscape, ImageMagick and/or Ghostscript
License: Other
Handling SVG pictures in LaTeX documents using Inkscape, ImageMagick and/or Ghostscript
License: Other
Hello. This MWE doesn't work with version 2.02c:
% !TeX spellcheck = it_IT
% !TeX TS-program = lualatex
% !TeX encoding = UTF-8
\documentclass{scrreprt}
\usepackage{svg}
\begin{document}
Hello world!
\includesvg{crystal}
\end{document}
The issue seems to be related to the quotes that the package adds when searching for the file. This is suggested both by the .log
file, which reads
! error: (file ./svg-inkscape/"crystal"_svg-tex.pdf) (pdf backend): cannot find
image file './svg-inkscape/"crystal"_svg-tex.pdf'
! ==> Fatal error occurred, no output PDF file produced!
and by this workaround, posted by David Carlisle on StackExchange, which actually fixes the problem.
\makeatletter
\let\quote@name\unquote@name
\makeatother
EDIT - Also this solution, used by alessanderbotti in a previous issue, works fine:
\RequirePackage[2019/09/30]{latexrelease}
Subsequent dates will not work.
Hi, many thanks for the great package. Despite spending time reading the doc, I haven't been able to figure out the answer to the following question:
Given an SVG input file with specified height and width in pixels and the default scale=1
, what are the dimensions of the resulting compiled image (in units understood by latex)? I would have expected includesvg
to use a DPI value that translates the size in pixels to a size in cm/in/pt, but I haven't been able to find this (in my code, changing the value of the inkscapedpi
option seems to have no effect on the resulting size of the image).
Hi,
so, I'm having some trouble trying to include files with a bit of a funky extension. Specifically, I'm trying to include svg files ending in drawio.svg
.
I'm trying to do that like this:
\begin{figure}[H]
\centering
\includesvg[width=0.8\linewidth]{"Figures/Chapter 3/Software structure.drawio"}
\caption[Overall software structure of the solution]{Software structure}
\label{fig:3_Software_structure}
\end{figure}
This gives me this error:
Package pdftex.def: File `{./svg-inkscape/Software structure.drawio_svg-tex}.pdf' not found: using draft setting.
The files shown below are created, however:
I have tried doing this in a lot of different ways, like using "
or {}
in different places or removing and adding extensions in different places, but nothing works. I have also tried specifying svgextension
like this:
\begin{figure}[H]
\centering
\includesvg[width=0.8\linewidth, svgextension=drawio.svg]{"Figures/Chapter 3/Software structure"}
\caption[Overall software structure of the solution]{Software structure}
\label{fig:3_Software_structure}
\end{figure}
But this gives me these errors:
Package svg: File `Software structure.drawio.svg_drawio.svg-tex.pdf' is missing.
Package svg: File `Software structure.drawio.svg_drawio.svg-tex.pdf_tex' is missing.
I'm not sure why this causes it to seemingly look for a double (quadruple?) extension.
Is there any good way to solve this, except for renaming the files in question?
The recent change supporting double quotes, relying on babel, causes an error compiling with xelatex and polyglossia because \bbl@deactivate is not defined.
\documentclass{article}
\usepackage{polyglossia}
\setmainlanguage{english}
\usepackage{svg}
\begin{document}
\includesvg{./figure.svg}
\end{document}
ERROR: Undefined control sequence.
--- TeX said ---
\svg@deactivate@dq ->\bbl@deactivate
{"}
l.595 }
#3 is a partial attempt to support this using polyglossia, but a simple workaround seems to be just to load svg before polyglossia.
When creating a standalone document to convert it into a PNG file, I get an error if I include the SVG package.
MWE
%\documentclass{standalone}
\documentclass[convert={density=720,outext=.png}]{standalone}
\usepackage{svg}
\begin{document}
\includesvg{test}
\end{document}
Without the convert option it works perfectly. With the convert option I get the following log result:
(/usr/local/texlive/2020/texmf-dist/tex/latex/svg/svg.sty
Package: svg 2020/05/07 v2.02f (include SVG pictures)
(/usr/local/texlive/2020/texmf-dist/tex/latex/koma-script/scrbase.sty
Package: scrbase 2020/04/19 v3.30 KOMA-Script package (KOMA-Script-independent basics and keyval usage)
! LaTeX Error: Missing \begin{document}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.478 \FamilyProcessOptions{KOMA}
\relax
?
! Emergency stop.
I have tried to compile using both, pdftex and luatex, and get the same result.
First of all, thanks for your work.
I am having issues with a project that stopped working, after a month from the last build and with no changes in-between. Given the error log and the timing of your last update, I guess it is this package to be the source of the problem.
I edit my sources (.tex and .svg files) on Windows, but run the building process on docker. I use this VS Code extension and this docker image. Note that to do this, the project folder is mounted with docker run -v
, but the files are still hosted on Windows. The tools used are latexmk
and LuaTex
.
The build fails with error: (pdf inclusion): file has changed
on a _svg-raw.pdf
file. This happens at each new attempt, even if the file was already correctly converted and present in the svg-inkscape
folder when building started.
I have verified this in two different Windows PCs; both are instead able to build other documents which do not use the svg
package, using the same setup.
I also verified that the same setup hosted on an Ubuntu machine successfully builds.
I was unable to try the setup with a precedent version of this package, since CTAN hosts only the latest one. So, while I think the error may be related to detecting updates to a file hosted under Windows, I cannot say if this is due svg
or Docker Desktop, which also got an update recently (version 2.2). My guess is on the former since only svg
file conversions are affected in my case.
Is there any way to export selected layers from an Inkscape svg file?
Hi there,
Thanks for the very useful package.
I've recently switched over to using Inkscape 1.0a1 and I've noticed that they're changed the export CLI interface from having an --export-<filetype>
option per filetype to a uniform --export
and an --export-type <filetype>
flag. Would it be possible to support this new version of inkscape?
Pre 1.0 inkscape (Inkscape 0.92.4 5da689c313, 2019-01-14)
Usage: inkscape [OPTIONS...] [FILE...]
Available options:
-V, --version Print the Inkscape version number
-z, --without-gui Do not use X server (only process files from console)
-g, --with-gui Try to use X server (even if $DISPLAY is not set)
-f, --file=FILENAME Open specified document(s) (option string may be excluded)
-p, --print=FILENAME Print document(s) to specified output file (use '| program' for pipe)
-e, --export-png=FILENAME Export document to a PNG file
-d, --export-dpi=DPI Resolution for exporting to bitmap and for rasterisation of filters in PS/EPS/PDF (default 96)
-a, --export-area=x0:y0:x1:y1 Exported area in SVG user units (default is the page; 0,0 is lower-left corner)
-D, --export-area-drawing Exported area is the entire drawing (not page)
-C, --export-area-page Exported area is the entire page
--export-margin=VALUE Sets margin around exported area (default 0) in units of page size for SVG and mm for PS/EPS/PDF
--export-area-snap Snap the bitmap export area outwards to the nearest integer values (in SVG user units)
-w, --export-width=WIDTH The width of exported bitmap in pixels (overrides export-dpi)
-h, --export-height=HEIGHT The height of exported bitmap in pixels (overrides export-dpi)
-i, --export-id=ID The ID of the object to export
-j, --export-id-only Export just the object with export-id, hide all others (only with export-id)
-t, --export-use-hints Use stored filename and DPI hints when exporting (only with export-id)
-b, --export-background=COLOUR Background colour of exported bitmap (any SVG-supported colour string)
-y, --export-background-opacity=VALUE Background opacity of exported bitmap (either 0.0 to 1.0, or 1 to 255)
-l, --export-plain-svg=FILENAME Export document to plain SVG file (no sodipodi or inkscape namespaces)
-P, --export-ps=FILENAME Export document to a PS file
-E, --export-eps=FILENAME Export document to an EPS file
--export-ps-level=PS Level Choose the PostScript Level used to export. Possible choices are 2 and 3 (the default)
-A, --export-pdf=FILENAME Export document to a PDF file
--export-pdf-version=PDF_VERSION Export PDF to given version. (hint: make sure to input the exact string found in the PDF export
dialogue, e.g. "1.4" which is PDF-a conformant)
--export-latex Export PDF/PS/EPS without text. Besides the PDF/PS/EPS, a LaTeX file is exported, putting the text on
top of the PDF/PS/EPS file. Include the result in LaTeX like: \input{latexfile.tex}
-M, --export-emf=FILENAME Export document to an Enhanced Metafile (EMF) File
-m, --export-wmf=FILENAME Export document to a Windows Metafile (WMF) File
-T, --export-text-to-path Convert text object to paths on export (PS, EPS, PDF, SVG)
--export-ignore-filters Render filtered objects without filters, instead of rasterising (PS, EPS, PDF)
Post 1.0 inkscape (Inkscape 1.0alpha (f7d4648084, 2019-03-06, custom)
Usage:
inkscape [OPTION…]
Help Options:
-?, --help Show help options
--help-all Show all help options
--help-gapplication Show GApplication options
--help-gtk Show GTK+ Options
Application Options:
-a, --actions=ACTION(:ARG)[;ACTION(:ARG)]* Actions (with optional arguments), semi-colon separated.
--action-list Actions: List available actions.
-V, --version Print: Inkscape version.
-x, --extension-directory Print: Extensions directory.
--verb-list Print: List verbs.
-g, --with-gui GUI: With graphical interface.
-G, --without-gui GUI: Console only.
--batch-process GUI: Close window after processing actions (needed as some verbs require GUI).
--pdf-page=PAGE Open: PDF page to import
--convert-dpi-method=[...] Open: Method used to convert pre-0.92 document dpi, if needed: [none|scale-viewbox|scale-document].
--no-convert-text-baseline-spacing Open: Do not fix pre-0.92 document's text baseline spacing on opening.
-I, --query-id=OBJECT-ID[,OBJECT-ID]* Query: ID(s) of object(s) to be queried.
-S, --query-all Query: Print bounding boxes of all objects.
-X, --query-x Query: X coordinate of drawing or object (if specified by --query-id).
-Y, --query-y Query: Y coordinate of drawing or object (if specified by --query-id).
-W, --query-width Query: Width of drawing or object (if specified by --query-id).
-H, --query-height Query: Height of drawing or object (if specified by --query-id).
--vacuum-defs Process: Remove unused definitions from the <defs> section(s) of document.
--select=OBJECT-ID[,OBJECT-ID]* Process: Select objects: comma separated list of IDs.
--verb=VERB-ID[;VERB-ID]* Process: Verb(s) to call when Inkscape opens.
--shell Process: Start Inkscape in interactive shell mode.
--export-type=[...] Export: File type:[svg,png,ps,psf,tex,emf,wmf,xaml]
-o, --export-file=EXPORT-FILENAME Export: File name
--export-overwrite Export: Overwrite input file.
--export-area=x0:y0:x1:y1 Export: Area to export in SVG user units.
-D, --export-area-drawing Export: Area to export is drawing (not page).
-C, --export-area-page Export: Area to export is page.
--export-margin Export: Margin around export area: units of page size for SVG, mm for PS/EPS/PDF.
--export-area-snap Export: Snap the bitmap export area outwards to the nearest integer values.
-w, --export-width=WIDTH Export: Bitmap width in pixels (overrides --export-dpi).
-h, --export-height=HEIGHT Export: Bitmap height in pixels (overrides --export-dpi).
-i, --export-id=OBJECT-ID[;OBJECT-ID]* Export: ID(s) of object(s) to export.
-j, --export-id-only Export: Hide all objects except object with ID selected by export-id.
-l, --export-plain-svg Export: Remove items in the Inkscape namespace.
-d, --export-dpi=DPI Export: Resolution for rasterization bitmaps and filters (default is 96).
--export-ignore-filters Export: Render objects without filters instead of rasterizing. (PS/EPS/PDF)
-T, --export-text-to-path Export: Convert text to paths. (PS/EPS/PDF/SVG).
--export-ps-level=PS-Level Export: Postscript level (2 or 3). Default is 3.
--export-pdf-level=PDF-Level Export: PDF level (1.4 or 1.5)
--export-latex Export: Export text separately to LaTeX file (PS/EPS/PDF). Include via \input{file.tex}
-t, --export-use-hints Export: Use stored filename and DPI hints when exporting object selected by --export-id.
-b, --export-background=COLOUR Export: Background color for exported bitmaps (any SVG color string).
-y, --export-background-opacity=VALUE Export: Background opacity for exported bitmaps (either 0.0 to 1.0 or 1 to 255).
--xverbs=XVERBS-FILENAME Process: xverb command file.
The following snippet
\includesvg[]{folder1/graphics.svg}
\includesvg[]{floder2/graphics.svg}
produces one single file pair
svg-inkscape/graphics_svg-tex.pdf(_tex)
which is then embedded twice.
Is there a way of preventing this behavior?
I had to change svg.sty
to get it to work:
\newcommand*\svg@ink@cmd[2]{%
\svg@ink@exe\space--without-gui\space\svg@ink@area\space%
\ifx\svg@ink@dpi\relax\else--export-dpi=\svg@ink@dpi\space\fi%
\if@svg@ink@latex--export-latex\space\fi%
\svg@ink@opt\space%
"#1.svg"\space%
--export-filename="#2.\svg@ink@format"\space%
}
but most likely I'm on an outdated version, can't check that right now.
Input:
\documentclass{article}
\usepackage{markdown}
\usepackage{svg}
\begin{document}
a
\end{document}
Expected output: a
Received: gibberish.
Also see same issue on markdown.
Hello,
I noticed that the option inkscapeexe behaves differently when set as a package option from the case when set as a parameter to the svgsetup macro:
This works:
% !TeX encoding = UTF-8
% !TeX spellcheck = en_GB
% !TeX program = lualatex
\documentclass{article}
\usepackage{svg}
\svgsetup{inkscape=overwrite,inkscapeexe="C:/Program Files/Inkscape/bin/inkscape.exe"}
\begin{document}
\includesvg{test.svg}
\end{document}
This fails:
% !TeX encoding = UTF-8
% !TeX spellcheck = en_GB
% !TeX program = lualatex
\documentclass{article}
\usepackage[inkscape=overwrite,inkscapeexe="C:/Program Files/Inkscape/bin/inkscape.exe"]{svg}
\begin{document}
\includesvg{test.svg}
\end{document}
with the following error:
("C:/Users/Username/AppData/Local/Programs/MiKTeX 2.9/tex/context/base/mkii/su
pp-pdf.mkii"
[Loading MPS to PDF converter (version 2006.09.02).]
\scratchcounter=\count189
\scratchdimen=\dimen153
\scratchbox=\box50
\nofMPsegments=\count190
\nofMParguments=\count191
\everyMPshowfont=\toks24
\MPscratchCnt=\count192
\MPscratchDim=\dimen154
\MPnumerator=\count193
\makeMPintoPDFobject=\count194
\everyMPtoPDFconversion=\toks25
)
("C:/Users/Username/AppData/Local/Programs/MiKTeX 2.9/tex/latex/epstopdf-pkg/e
pstopdf-base.sty"
Package: epstopdf-base 2020-01-24 v2.11 Base part for package epstopdf
Package epstopdf-base Info: Redefining graphics rule for `.eps' on input line 48
5.
) ("|'C:/ProgramFiles/Inkscape/bin/inkscape.exe' -V")
runsystem(call "C:/ProgramFiles/Inkscape/bin/inkscape.exe" -V > test.svg.ink.ver
.aux)...failed
runsystem(del test.svg.ink.ver.aux)...executed
Package svg Info: Calling Inkscape on input line 11.
runsystem("C:/ProgramFiles/Inkscape/bin/inkscape.exe" "test.svg" -D --export-lat
ex --export-filename="test_svg-tex.pdf")...failed
runsystem("C:/ProgramFiles/Inkscape/bin/inkscape.exe" "test.svg" -D --export-lat
ex --without-gui --export-pdf="test_svg-tex.pdf")...failed
! Package svg Error: Inkscape version not detected.
See the svg package documentation for explanation.
Type H <return> for immediate help.
...
l.11 \includesvg{test.svg}
It was tried to invoke `"C:/ProgramFiles/Inkscape/bin/inkscape.exe"'
for file "test.svg"
but no result was produced. Check the log file
and set `inkscapeversion=<version>' manually.
i.e. the space in the path name is removed (whole log is attached). Using the short 8.3 name format does not work either. Using a pathname without a space works perfectly when inkscapeexe is set as a package option. I expected that the location of inkscapeexe does not matter. Anyway, please add the line
\svgsetup{inkscapeexe="C:/Program Files/Inkscape/bin/inkscape.exe"}
as an example to the documentation. I assume especially Windows users need to set this option and I had to do some trial and error before I figured out how to do it correctly.
Hello!
First and foremost, thank you very much for maintaining the svg package.
Before the latest update (v2.02f), the package worked flawlessly for me.
Now, after performing the referred update, when I try to compile a latex file using lualatex (with shell-escape enabled), I am faced with the message bellow, during compilation:
'\\?\D:\Thiago\Documents\AULA-07' CMD.EXE was started with the above path as the current directory. UNC paths are not supported. Defaulting to Windows Directory.
I am almost certain that the issue is not related with the latex file I am trying to compile, neither with my system setup. Before the update, I had compiled the same exact file without any issues.
I have tried debugging the code to pinpoint where the issue is, but to no avail. (I admit I have almost no experience with lua / latex scripting.)
If you think I can help debugging the issue, please give me instructions.
Thank you!
我用的编辑软件是texstudio,但是在插入svg图片处,不能够使用ctr+鼠标右键在tex文档和pdf之间相互定位。
The editing software I use is texstudio, but when I insert the svg image, I can't use the ctr + right mouse button to locate each other between the tex document and the pdf.
(frome translate.google.com)
So it turns out that Inkscape 1.1 (and presumably 1.0) saves as SVG 2.0 by default, and this includes some subtle changes* that break SVG 1.1 parsers i.e. older Inkscape releases. This is a problem for example when using ubuntu 21.10 for editing the SVGs on the desktop and editing the LaTeX document on overleaf.com with the 2021 texlive environment which is presumably running on the previous ubuntu LTS.
Unfortunately all that LaTeX has to say about it is a relatively uninformative "blahblah_svg.pdf_tex: no such file". I've already reported this to overleaf, but on selfhosted overleaf instances and other environments this might still come as a surprise and as such it would be great if the svg package could report problems the inkscape shell command encounters.
*such as using context-stroke
and context-fill
instead of specific colours in curve end markers
It has always confused me that the default for inkscapearea
is drawing
and not page
. To me, page
is the obvious choice. To my knowledge, all other contexts in which svg
s are used (e.g. websites) use the page as the bounding box for the drawing. That is to say, users will likely expect that behavior. After all, that's its whole purpose. Using drawing
means discarding information on how the drawing should be displayed that was provided by its creator. The aliases crop
and nocrop
illustrate this quite well: I find it pretty weird for an image inclusion mechanism to crop the image by default.
Especially in the context of LaTeX, I often need to make use of the page boundaries. An example is when I have multiple drawings that should be displayed next to / above each other. Then I can create svg
s with identical sizes (or at least aspect ratios) without worrying about the precise drawing size and just scale them identically in LaTeX.
It gets even messier when LaTeX code is involved. As an example, consider the following drawing.
Including this with the drawing
option cannot yield anything sensible. The page
option preserves the intention of the creator (frame added in LaTeX):
All in all, this seems like a really strange default choice to me and I would argue for changing it. It isn't a super pressing issue (there are two questions caused by it on tex.sx for now) but I think page
would be a much better default.
I do realize, of course, that this would mean breaking backward compatibility, which is unfortunate. If other things doing that are also in the works, I would love to see this change included in the next major release, though.
Files used for illustration:
geometric_series.svg
<?xml version="1.0" encoding="UTF-8"?>
<svg width="108.49mm" height="12.396mm" version="1.1" viewBox="0 0 108.49 12.396" xmlns="http://www.w3.org/2000/svg">
<defs>
<marker id="StopL" overflow="visible" orient="auto">
<path transform="scale(.8)" d="m0 5.65v-11.3" fill="none" stroke="#000" stroke-width="1pt"/>
</marker>
</defs>
<g transform="translate(-33.067 -30.844)">
<text x="121.70834" y="37.041664" font-family="'Libertinus Sans'" font-size="4.2333px" letter-spacing="0px" stroke-width=".26458" word-spacing="0px" style="line-height:1.25" xml:space="preserve"><tspan x="121.70834" y="37.041664" stroke-width=".26458">\raisebox{-.5ex}{\(\displaystyle\sum_{k = 0}^\infty \frac{1}{2^k} = 2\)}</tspan></text>
<path d="m58.208 37.042h29.104 14.552 7.276 3.638 1.819 0.90951 0.45475 0.22737 0.22738" fill="none" marker-end="url(#StopL)" marker-mid="url(#StopL)" marker-start="url(#StopL)" stroke="#000" stroke-width=".265"/>
<text x="52.916668" y="37.041664" font-family="'Libertinus Sans'" font-size="4.2333px" letter-spacing="0px" stroke-width=".26458" text-align="end" text-anchor="end" word-spacing="0px" style="line-height:1.25" xml:space="preserve"><tspan x="52.916668" y="37.041664" stroke-width=".26458" text-align="end" text-anchor="end">\raisebox{-.5ex}{a series:}</tspan></text>
</g>
</svg>
svg_test.tex
\documentclass{article}
\usepackage[inkscapearea=page]{svg}
\begin{document}
\fbox{%
\includesvg{geometric_series}%
}
\end{document}
My project folder looks like this:
.
├── mydoc.tex
├── topic 1
│ ├── im.svg
│ └── text.tex
└── topic 2
├── im.svg
└── text.tex
In mydoc.tex
, I input topic 1/text.tex
and topic 2/text.tex
. In the former file, I use includesvg{topic 1/im}
, in the latter file I use includesvg{topic 2/im}
.
Of course in the svg-inkscape/
directory that is created on the same level as mydoc.tex
, the file names are now ambiguous and one of the images can be seen a second time instead of the second image in the rendered document mydoc.pdf
.
Is there a way to instruct your extension to be able to differentiate between the files by including information about the relative path between images and the root tex document?
I believe that option inkscapename
should be the way to go but I couldn't figure out how to use it...
Thanks in advance!
Since the latest release, a problem occured using the svg package together with the tikzscale package.
MWE:
\documentclass{scrreprt}
\usepackage{tikz}
\usepackage{tikzscale}
\usepackage[]{svg}
\svgpath{figures/}
\begin{document}
\begin{figure}[tb]
\centering
\includesvg[width=0.7\linewidth]{figures/test}
\end{figure}
\end{document}
Compiling the above code fails with following error message:
! LaTeX Error: File `{./svg-inkscape/test_svg-tex}.pdf' not found.
However, the files 'test_svg-tex.pdf' and 'test_svg-tex.pdf_tex' in the 'svg-inkscape' folder are correctly generated.
When commenting out the line '\usepackage{tikzscale}', the error vanishes and the document compiles correctly. The test system used pdfLaTex on Windows and Inkscape 0.92.3.
This is a continuation of Issue #20 regarding support for Inkscape 1.0.
Maybe I am missing something but it seems the code still uses the -z
flag for all Inkscape versions:
\def\SVG@cmd@inkscape{inkscape -z -C}%
However, -z
is just an alias for --without-gui
(see e.g. Issue #8 ) so it probably should be removed from the above definition. The package already sets the --without-gui
flag for Inkscape 0.x so there is no need to set it via -z
.
Calling Inkscape 1.0 with -z
will cause it to fail with error message Unknown option -z
.
(Inkscape 1.0 dropped the --without-gui
flag completely man page and automatically runs export commands without GUI unless specified with --with-gui
.)
Solution would probably be to just change this line to:
\def\SVG@cmd@inkscape{inkscape -C}%
or even better (because more verbose):
\def\SVG@cmd@inkscape{inkscape --export-area-page}%
I have a handful of files from matplotlib
that don't like to be included with svg
. The one thing they have in common is being created with the imshow
command, which means they contain an image. I have no issues with any other files generated with matplotlib
.
The relevant part of the log:
Package svg Info: Calling Inkscape on input line 642.
runsystem(inkscape "figures//test.svg" -C --export-latex --export-filename="test_svg-tex.pdf")...executed.
Package svg Warning: The export with Inkscape failed for file
(svg) `figures//test.svg'
(svg) Troubleshooting: Please check in the log file how
(svg) the invocation of Inkscape took place and try to
(svg) execute it yourself in the terminal on input line 642.
The best part is that I can copy-paste the command to the terminal and it will work like a charm.
I included an example bad file here:
test.zip
Acording to this issue:
https://gitlab.com/inkscape/inbox/issues/1244
Inkscape 1.0 (beta) does not accept the --file
and --export-TYPE=
anymore. Therefore this package is broken if used with a newer inkscape version.
Problem is fedora is already rolling out this version therefore on fedora this package can not be used anymore.
Just run into this very annoying.
I'm using SVG v2.02, and I've just run into a bug where I'm doing the following:
\includesvg{subdir1/drawing.svg}
\includesvg{subdir2/drawing.svg}
This results in subdir1/drawing.svg
being inserted twice, which isn't right...
Looking at the svg-inkscape
directory, it's clear that only the file name is being used as a cache key, leading to incorrect results when files by the same name appear in different directories.
In this case, it was easy enough for me to rename one of the files, but it would be good if the cache mechanism could be adjusted to make the entire path part of the key (by hashing it for instance, e.g. 3a406d0e_drawing_svg-raw.pdf
instead of drawing_svg-raw.pdf
).
I am not sure how doable it is, but I would prefer the package to assemble a list of all svg files and call inkscape only once in batchmode, to convert all the files in one invocation. This is typically much faster than one invocation per file.
The batch interface changed a bit recently. This is what I do to convert pdf to svg with the current (1.2.2) version:
(for file in *.pdf; do echo "file-open:$file; export-filename:$(echo $file | sed s/.pdf/.svg/); export-do;";done ) | inkscape --shell
(yes, I could have bash variable text substitution, but I think calling sed
is more portable?).
export-latex
can be used as well.
This could roughly results in the following sequence:
$ inkscape --shell
file-open:file1.svg; export-filename:file1.pdf; export-latex; export-do;
file-open:file2.svg; export-filename:file2.pdf; export-latex:false; export-do;
file-open:file3.svg; export-filename:file3.pdf; export-latex:true; export-do;
For reference, I used to do the following pdf->svg
conversion in a Makefile with an older version of inkscape:
# Yes, the pattern makes no sense, it's just to tell make that these are built all at once
# https://stackoverflow.com/questions/2973445/gnu-makefile-rule-generating-a-few-targets-from-a-single-source-file
$(PDF_SVG_FILES:%-svg-converted-to.pdf=%-svg-converted-to.pd%): $(SVG_FILES)
# converting svg files with inkscape...
(for file in $?; do echo $$file --export-pdf=$$(echo $$file | sed s/.svg/-svg-converted-to.pdf/);done ) | inkscape --shell
But I'm not sure it's worth it to support older versions with a new feature.
If it's not possible to do so (if files need to be passed to the pdf engine right away), I suggest adding an option to allow skipping graph generation on the first pass. Ideally, placeholders of the right size should be created, but I am not sure this is possible either.
I don't mind compiling once more, personally (currently, I run a first --draft-mode
compilation anyway, plus ~3 others), especially if it leads to much faster compile times overall.
Temporary solution: in text preferences, uncheck the auto-flow svg2 feature. Here is an example svg with working and non working flow-texts
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="143.30655mm"
height="200.40955mm"
viewBox="0 0 143.30655 200.40955"
version="1.1"
id="svg8"
inkscape:version="1.0.1 (c497b03c, 2020-09-10)"
sodipodi:docname="textExample.svg">
<defs
id="defs2">
<rect
x="67.057052"
y="144.37375"
width="84.00729"
height="53.808591"
id="rect117" />
<rect
x="62.897285"
y="111.42723"
width="80.712883"
height="69.731544"
id="rect107" />
<rect
x="47.053143"
y="206.93263"
width="124.46315"
height="71.844582"
id="rect48" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.48187782"
inkscape:cx="197.14541"
inkscape:cy="430.60707"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
inkscape:document-rotation="0"
showgrid="false"
inkscape:window-width="1252"
inkscape:window-height="943"
inkscape:window-x="1756"
inkscape:window-y="25"
inkscape:window-maximized="0"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-36.858353,-24.677086)">
<text
xml:space="preserve"
id="text46"
style="font-style:normal;font-weight:normal;font-size:10.58329999999999949px;line-height:1.25;font-family:sans-serif;white-space:pre;shape-inside:url(#rect48);fill:#000000;fill-opacity:1;stroke:none;" />
<rect
style="fill:#e6e6e6;fill-rule:evenodd;stroke-width:0.264583"
id="rect111"
width="143.85562"
height="200.40955"
x="36.542057"
y="24.674601" />
<path
style="fill:#e6e6e6;stroke-width:2.07521"
d="M 51.000607,438.91732 V 60.190619 H 321.81614 592.63167 V 438.91732 817.64403 H 321.81614 51.000607 Z"
id="path113"
transform="matrix(0.26458333,0,0,0.26458333,23.364443,8.7516514)" />
<text
xml:space="preserve"
id="text115"
style="font-style:normal;font-weight:normal;font-size:10.58329999999999949px;line-height:1.25;font-family:sans-serif;white-space:pre;shape-inside:url(#rect117);fill:#000000;fill-opacity:1;stroke:none;"><tspan
x="67.056641"
y="154.02851"><tspan>auto-flow svg2 </tspan></tspan><tspan
x="67.056641"
y="167.25764"><tspan>on - not </tspan></tspan><tspan
x="67.056641"
y="180.48676"><tspan>working as </tspan></tspan><tspan
x="67.056641"
y="193.71589"><tspan>expected</tspan></tspan></text>
<flowRoot
xml:space="preserve"
id="flowRoot121"
style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none"><flowRegion
id="flowRegion123"><rect
id="rect125"
width="76.320351"
height="57.102989"
x="70.351456"
y="65.857132"
style="stroke-width:0.264583" /></flowRegion><flowPara
id="flowPara127">auto-flow svg2 off - works as expected</flowPara></flowRoot>
</g>
</svg>
Looks like currently only the <flowRoot>
tag is taken into consideration but the SVG2 auto-flow uses <text>
and <tspan>
s for flowing text.
Hi, is there any plan to add support to 'trim' and 'clip' like in '\includegraphics' ?
https://tex.stackexchange.com/questions/570819/includesvg-and-trim
Thanks.
I'm on macos and Inkscape 0.92 works with full paths to the image files only. See https://bugs.launchpad.net/inkscape/+bug/181639
Is it possible that a full path for all files can be used in the Inkscape invocation? I tried with \svgpath
, but this does not work if the same path like the current directory was given.
Here's my SVG drawing:
I include it in my LaTeX document using the svg
package as follows:
\documentclass{article}
\usepackage{svg}
\begin{document}
\includesvg{idea.svg}
\end{document}
Which results in the following:
Then I use the svg-extract
package to extract it out into a PDF including the rendered LaTeX math:
\documentclass{article}
\usepackage[extractformat=pdf]{svg-extract}
\begin{document}
\includesvg[keepaspectratio]{idea.svg}
\end{document}
I run latexmk --shell-escape idea.tex
and the resulting PDF is as follows:
It looks like the text has been moved to accomodate some smaller bounding box than that which the SVG originally intended.
How can I prevent this behavior and get back the SVG as it looked in the original PDF?
I updated MikTex today. Now I get the warning for every \ includesvg instruction:
Package scrbase Warning: Usage of deprecated command \ ifstr '. (scrbase) The command has been renamed because of a (scrbase) recommendation of The LaTeX Project Team. (scrbase) Please replace
\ ifstr 'by` \ Ifstr' on input line xx.
Is there any way to fix this error?
I'm using TeXnicCenter with Komascript scrbook.
Hello!
First and foremost, thank you very much for maintaining the svg package.
'\?\D:\Thiago\Documents\AULA-07' CMD.EXE foi iniciado tendo o caminho acima como pasta atual. NÆo h suporte para caminhos UNC. Padronizando para pasta do Windows.
If the text inside a svg-file contains special characters (#$%&^_{}~) the import fails.
Looking at the produced name.pdf_tex the problem seems to be that these characters are not automatically escaped.
Manually escaping these characters in name.pdf_tex fixes the problem an produces the expected result.
Example of a line producing an error:
\put(0.5,0.5){\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}Relative Error [%]\end{tabular}}}}%
If I render the following .tex-File everything works as expected. Rendering twice results in an empty PDF document.
I am on TeXLive 2022, Ubuntu 22.04. My drawing.svg is located in my working directory.
\documentclass[11pt,a4paper]{article}
\usepackage{svg}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\begin{document}
Hello \\
\begin{figure}[h]
\includesvg{drawing.svg}
\end{figure}
\end{document}
The drawing.svg was created with Inkscape and contains the following.
Minimal working example
\documentclass{article}
\usepackage[inkscapeversion=auto]{svg}
\begin{document}
\includesvg{first.svg}
\end{document}
Compilation of MWE fails:
! Use of \svg@tempb doesn't match its definition.
\svg@tempa ->P
ango version: 1.46.1
l.4 \begin{document}
^^M
?
Reason for failure:
Autodectection of inkscape version fails since version output of inkscape
(v1.01) now has two lines, indicating pango
version as well:
REM Windows
C:\>inkscape --version
Inkscape 1.0.1 (3bc2e813f5, 2020-09-07)
Pango version: 1.46.1
# Linux
$ inkscape --version
Inkscape 1.0.1 (3bc2e813f5, 2020-09-07)
Pango version: 1.40.14
This can be easily fixed by specifiying inkscapeversion=1
as option which causes auto-detection to be skipped.
I'm reporting this error anyway since it might confuse newcomers.
Environment
I cannot really get text to correctly align with the image. I am guessing because the image is heavily scaled down. I tried using pretex=\tiny
and pretex=\relscale{0.1}
but it is still off (text too large).
I am thinking that maybe a solution would be if:
That would make it use the LaTeX fonts but allow precise scaling as needed.
It looks like this package could support that but it is not yet fully possible? So svg-extract
could extract to a separate PDF with custom preamble in extractpreamble
, but then I think that instead of the original image the extracted PDF should be included in the main document.
Hi,
I just noticed that on Windows the import of an SVG file doesn't work when it contains an German special characters like umlauts (ä, ö or ü.) or "ß".
For example:
\begin{figure}[h]
\includesvg[width=\textwidth, inkscapelatex=false]{3_Dateigröße_Vergleich.svg}
\end{figure}
Will result in:
** (org.inkscape.Inkscape:8104): WARNING **: 11:06:36.618: Can't open file: d:\checkouts\laurenz-bachelorarbeit\images\3_Dateigröße_Vergleich.svg (doesn't exist)
** (org.inkscape.Inkscape:8104): WARNING **: 11:06:36.618: Can't open file: d:\checkouts\laurenz-bachelorarbeit\images\3_Dateigröße_Vergleich.svg (doesn't exist)
ink_file_open: 'd:\checkouts\laurenz-bachelorarbeit\images\3_Dateigröße_Vergleich.svg' cannot be opened!
InkscapeApplication::document_open: Failed to open: d:\checkouts\laurenz-bachelorarbeit\images\3_Dateigröße_Vergleich.svg
ConcreteInkscapeApplication::on_open: failed to create document!
Package svg Warning: The export with Inkscape failed for file
(svg) `images//3_Dateigröße_Vergleich.svg'
(svg) Troubleshooting: Please check in the log file how
(svg) the invocation of Inkscape took place and try to
(svg) execute it yourself in the terminal on input line 86.
! Package svg Error: File `3_Dateigröße_Vergleich_svg-raw.pdf' is missing.
See the svg package documentation for explanation.
Type H <return> for immediate help.
...
l.86 ...pelatex=false]{3_Dateigröße_Vergleich.svg}
[26]
On my Linux machine, i never had this problem, but here on Windows it doesn't work.
I am using This is LuaHBTeX, Version 1.13.2 (TeX Live 2021/W32TeX)
.
latex code was
\begin{figure}
\includesvg[width=\linewidth, pretex=\relscale{0.6}]{C:/Users/LiJZh/Desktop/app_data/FI}
\end{figure}
getting error
Package svg Error: File
FI_svg-tex.pdf' is missing. ...{0.6}]{C:/Users/LiJZh/Desktop/app_data/FI} Package svg Error: File
FI_svg-tex.pdf_tex' is missing. ...{0.6}]{C:/Users/LiJZh/Desktop/app_data/FI}
I'm using TeXstudio to edit LaTeX documents and svg
package to include images edited with Inkscape. It works well... thanks for that!
However, I noticed that commands from the svg
package, like \includesvg
are not recognized within TeXstudio application.
I suspect that this has something to do with the fact that there is no CWL file associated with svg
package. I say I suspect as I'm only an amateur about LaTeX packages.
Let me know what you think about this enhancement request. Does it make sense? If so, I may volunteer to work on a pull request.
Thanks.
In the docs and error message it says that I should be able to view the command for inkscape, but it's not being output to any log.
\documentclass{article}
\usepackage{svg}
\begin{document}
\includesvg{MWE}
\end{document}
OK
OK
Problem with log:
Package svg Info: Calling Inkscape on input line 7.
runsystem(inkscape -z -D --export-latex --file="MWE.svg.svg" --export-pdf="MWE
.svg_svg-tex.pdf" )...executed.
Package svg Warning: The export with Inkscape failed for file
(svg) `MWE.svg.svg'
(svg) Troubleshooting: Please check in the log file how
(svg) the invocation of Inkscape took place and try to
(svg) execute it yourself in the terminal on input line 7.
! Package svg Error: File `MWE.svg_svg-tex.pdf' is missing.
See the svg package documentation for explanation.
Type H <return> for immediate help.
...
l.7 \includesvg{MWE}
Problem with log:
runsystem(mkdir -p "./svg-inkscape/")...executed.
Package svg Info: Exporting `./MWE.svg' on input line 7.
runsystem(inkscape "./MWE.svg" --without-gui -D --export-latex --export-pdf="./
svg-inkscape/MWE_svg-latex.pdf" )...executed.
Package svg Info: Last page of `"./svg-inkscape/MWE_svg-latex.pdf"'
(svg) is `1' on input line 7.
(./svg-inkscape/MWE_svg-latex.pdf_tex
LaTeX Warning: File `{./svg-inkscape/MWE_svg-latex}.pdf' not found on input lin
e 56.
! Package pdftex.def Error: File `"{./svg-inkscape/""MWE_svg-latex}".pdf' not f
ound: using draft setting.
See the pdftex.def package documentation for explanation.
Type H <return> for immediate help.
...
l.56 ...th=\unitlength,page=1]{MWE_svg-latex.pdf}}
The following
\documentclass{standalone}
\usepackage{svg}
\usepackage{relsize}
\usepackage{amsmath}
\begin{document}
\includesvg[inkscapelatex=false,pretex=\relsize{1.3}]{idea.svg}
\end{document}
results in
If I set inkscapelatex=true
I get the following:
Notice that:
This indicates that svg
package takes the bounding box of the original SVG as opposed to the bounding box resulting from converting all the text into math.
With Inkscape 1.0 the command line interface with change a little. One important change is, that the -z
and the --file
options are gone. This makes the svg
incompatible with Inkscape 1.0.
Inkscape 0.92.5 --help output:
Usage: inkscape [OPTIONS...] [FILE...]
Available options:
-V, --version Print the Inkscape version number
-z, --without-gui Do not use X server (only process
files from console)
-g, --with-gui Try to use X server (even if
$DISPLAY is not set)
-f, --file=FILENAME Open specified document(s)
(option string may be excluded)
-p, --print=FILENAME Print document(s) to specified
output file (use '| program' for
pipe)
-e, --export-png=FILENAME Export document to a PNG file
-d, --export-dpi=DPI Resolution for exporting to
bitmap and for rasterization of
filters in PS/EPS/PDF (default 96)
-a, --export-area=x0:y0:x1:y1 Exported area in SVG user units
(default is the page; 0,0 is
lower-left corner)
-D, --export-area-drawing Exported area is the entire
drawing (not page)
-C, --export-area-page Exported area is the entire page
--export-margin=VALUE Sets margin around exported area
(default 0) in units of page size
for SVG and mm for PS/EPS/PDF
--export-area-snap Snap the bitmap export area
outwards to the nearest integer
values (in SVG user units)
-w, --export-width=WIDTH The width of exported bitmap in
pixels (overrides export-dpi)
-h, --export-height=HEIGHT The height of exported bitmap in
pixels (overrides export-dpi)
-i, --export-id=ID The ID of the object to export
-j, --export-id-only Export just the object with
export-id, hide all others (only
with export-id)
-t, --export-use-hints Use stored filename and DPI hints
when exporting (only with
export-id)
-b, --export-background=COLOR Background color of exported
bitmap (any SVG-supported color
string)
-y, --export-background-opacity=VALUE Background opacity of exported
bitmap (either 0.0 to 1.0, or 1
to 255)
-l, --export-plain-svg=FILENAME Export document to plain SVG file
(no sodipodi or inkscape
namespaces)
-P, --export-ps=FILENAME Export document to a PS file
-E, --export-eps=FILENAME Export document to an EPS file
--export-ps-level=PS Level Choose the PostScript Level used
to export. Possible choices are 2
and 3 (the default)
-A, --export-pdf=FILENAME Export document to a PDF file
--export-pdf-version=PDF_VERSION Export PDF to given version.
(hint: make sure to input the
exact string found in the PDF
export dialog, e.g. "1.4" which
is PDF-a conformant)
--export-latex Export PDF/PS/EPS without text.
Besides the PDF/PS/EPS, a LaTeX
file is exported, putting the
text on top of the PDF/PS/EPS
file. Include the result in LaTeX
like: \input{latexfile.tex}
-M, --export-emf=FILENAME Export document to an Enhanced
Metafile (EMF) File
-m, --export-wmf=FILENAME Export document to a Windows
Metafile (WMF) File
-T, --export-text-to-path Convert text object to paths on
export (PS, EPS, PDF, SVG)
--export-ignore-filters Render filtered objects without
filters, instead of rasterizing
(PS, EPS, PDF)
-X, --query-x Query the X coordinate of the
drawing or, if specified, of the
object with --query-id
-Y, --query-y Query the Y coordinate of the
drawing or, if specified, of the
object with --query-id
-W, --query-width Query the width of the drawing
or, if specified, of the object
with --query-id
-H, --query-height Query the height of the drawing
or, if specified, of the object
with --query-id
-S, --query-all List id,x,y,w,h for all objects
-I, --query-id=ID The ID of the object whose
dimensions are queried
-x, --extension-directory Print out the extension directory
and exit
--vacuum-defs Remove unused definitions from
the defs section(s) of the
document
--dbus-listen Enter a listening loop for D-Bus
messages in console mode
--dbus-name=BUS-NAME Specify the D-Bus bus name to
listen for messages on (default
is org.inkscape)
--verb-list List the IDs of all the verbs in
Inkscape
--verb=VERB-ID Verb to call when Inkscape opens.
--select=OBJECT-ID Object ID to select when Inkscape
opens.
--shell Start Inkscape in interactive
shell mode.
--no-convert-text-baseline-spacing Do not fix legacy (pre-0.92)
files' text baseline spacing on
opening.
--convert-dpi-method=[...] Method used to convert pre-.92
document dpi, if needed.
([none|scale-viewbox|scale-document])
Help options:
-?, --help Show this help message
--usage Display brief usage message
Inkscape 1.0rc1 --help output:
Usage:
inkscape [OPTION?] file1 [file2 [fileN]]
Process (or open) one or more files.
Help Options:
-?, --help Show help options
--help-all Show all help options
--help-gapplication Show GApplication options
Application Options:
-V, --version Print Inkscape version
--system-data-directory Print system data directory
--user-data-directory Print user data directory
File import:
-p, --pipe Read input file from standard input (stdin)
--pdf-page=PAGE PDF page number to import
--pdf-poppler Use poppler when importing via commandline
--convert-dpi-method=[...] Method used to convert pre-0.92 document dpi, if needed: [none|scale-viewbox|scale-document]
--no-convert-text-baseline-spacing Do not fix pre-0.92 document's text baseline spacing on opening
File export:
-o, --export-filename=EXPORT-FILENAME Output file name (file type is guessed from extension)
--export-overwrite Overwrite input file
--export-type=[...] File type(s) to export: [svg,png,ps,eps,pdf,emf,wmf,xaml]
Export geometry:
-C, --export-area-page Area to export is page
-D, --export-area-drawing Area to export is whole drawing (ignoring page size)
-a, --export-area=x0:y0:x1:y1 Area to export in SVG user units
--export-area-snap Snap the bitmap export area outwards to the nearest integer values
-d, --export-dpi=DPI Resolution for bitmaps and rasterized filters; default is 96
-w, --export-width=WIDTH Bitmap width in pixels (overrides --export-dpi)
-h, --export-height=HEIGHT Bitmap height in pixels (overrides --export-dpi)
--export-margin=MARGIN Margin around export area: units of page size for SVG, mm for PS/EPS/PDF
Export options:
-i, --export-id=OBJECT-ID[;OBJECT-ID]* ID(s) of object(s) to export
-j, --export-id-only Hide all objects except object with ID selected by export-id
-l, --export-plain-svg Remove Inkscape-specific SVG attributes/properties
--export-ps-level=PS-Level Postscript level (2 or 3); default is 3
--export-pdf-version=PDF-VERSION PDF version (1.4 or 1.5)
-T, --export-text-to-path Convert text to paths (PS/EPS/PDF/SVG)
--export-latex Export text separately to LaTeX file (PS/EPS/PDF)
--export-ignore-filters Render objects without filters instead of rasterizing (PS/EPS/PDF)
-t, --export-use-hints Use stored filename and DPI hints when exporting object selected by --export-id
-b, --export-background=COLOR Background color for exported bitmaps (any SVG color string)
-y, --export-background-opacity=VALUE Background opacity for exported bitmaps (0.0 to 1.0, or 1 to 255)
Query object/document geometry:
-I, --query-id=OBJECT-ID[,OBJECT-ID]* ID(s) of object(s) to be queried
-S, --query-all Print bounding boxes of all objects
-X, --query-x X coordinate of drawing or object (if specified by --query-id)
-Y, --query-y Y coordinate of drawing or object (if specified by --query-id)
-W, --query-width Width of drawing or object (if specified by --query-id)
-H, --query-height Height of drawing or object (if specified by --query-id)
Advanced file processing:
--vacuum-defs Remove unused definitions from the <defs> section(s) of document
--select=OBJECT-ID[,OBJECT-ID]* Select objects: comma-separated list of IDs
--actions=ACTION(:ARG)[;ACTION(:ARG)]* List of actions (with optional arguments) to execute
--action-list List all available actions
--verb=VERB[;VERB]* List of verbs to execute
--verb-list List all available verbs
Interface:
-g, --with-gui With graphical user interface (required by some actions/verbs)
--batch-process Close GUI after executing all actions/verbs
--shell Start Inkscape in interactive shell mode
D-Bus:
--dbus-listen Enter a listening loop for D-Bus messages in console mode
--dbus-name=BUS-NAME Specify the D-Bus name; default is 'org.inkscape'
Examples:
Export input SVG (in.svg) to PDF (out.pdf) format:
inkscape --export-filename=out.pdf in.svg
Export input files (in1.svg, in2.svg) to PNG format keeping original name (in1.png, in2.png):
inkscape --export-type=png in1.svg in2.svg
See 'man inkscape' and http://wiki.inkscape.org/wiki/index.php/Using_the_Command_Line for more details.
Where can one find the actual svg.sty file?
With Inkscape 1.0.1 (3bc2e813f5, 2020-09-07)
the options
--without-gui
--file
export-pdf
become depracted. See as well on TexExchange
Hello,
I tried to use the \includesvg{}
command in Latex (pdfLatex). The creation of the document fails.
My Inkscape version is Inkscape 1.2.2 (732a01da63, 2022-12-09)
Concretely, I use: \includesvg{./path/to/my}
for the conversion from .svg to .png. The following command is executed and appears in the log file:
runsystem(inkscape "./path/to/my.svg" -D --export-dpi=300 --export-filename= "my_svg-raw.png")
I tried running this command in my console. It does not work there as well. After some research, I found out that there is a new syntax.
This command works in the console.
inkscape --export-type="png" --export-filename= ".\path\to\my.svg"
However, how can I change the commands that are used in the package?
I tried the inkscapeopt
option, but it just adds an additional switch and does not change the main command.
Hopefully, this is easy to fix. For now, I just switch to creating the .png files by hand and use \includeinkscape{}
to add them to my Latex file.
Best regards,
CMS
When running latexmk
with xelatex
, the pdf file of the svg keeps being regenerated every run. This causes latexmk
to rerun xelatex
about 5 times every time to finally halt with a
Rule 'pdflatex': File changes, etc:
Changed files, or newly in use since previous run(s):
'svg-inkscape/test_svg-tex.pdf'
Latexmk: Maximum runs of pdflatex reached without getting stable files
or a
Latexmk: Failure in processing file 'test':
'xelatex' needed too many passes
error (depending on the recipe used; see below). Although the pdf file is created, this is quite annoying, as compiling the file takes longer this way.
This should give a reproducible example (let's assume this file is called test.tex
):
\documentclass{article}
\usepackage{graphicx}
\usepackage{svg}
\usepackage{svg-extract}
% same problem when explicitly setting convert and extract to true:
%\usepackage[convert=true,extract=true]{svg-extract}
\begin{document}
\includesvg{test.svg}
\section{Introduction}
\end{document}
run either with
latexmk -pdf -pdflatex="xelatex %O %S" -synctex=1 -interaction=nonstopmode -shell-escape test
or
latexmk -pdf -xelatex -synctex=1 -interaction=nonstopmode -shell-escape test
To reproduce the problem. Is this a bug? or are there any settings I don't know about? Note that the problem does not exists when running latexmk
with the normal pdflatex
.
Thank you a lot.
I created a diagram containing text that is either white or black. The SVG seems to also be correct; viewing it in different browsers results in a correct rendering. However, when I use \includesvg all the text is black in the generated pdf.
In the svg, the tags with text have as part of their style either fill:#ffffff or fill:#000000.
Looking into the generated svg-tex.pdf_tex, each text entry has the option \color[rgb]{0,0,0}, no matter if the text should be white or black
I'm not sure if this is the place to talk about it, in michal-h21/tex4ebook#52, or perhaps a combination.
The EPUB format allows for SVG files to be directly included whereas all other output formats for *TeX do not. As-is, when using tex4ebook
to build an EPUB file which includes SVG files, the SVGs are first converted into PNG files. What should be tweaked where to allow SVGs to be used in the final output instead of PNGs?
When searching for SVG files, the svg package skips the directories from \svgpath
(and \includegraphics
as well) which are matched by the TEXINPUTS environment variable. This happens for example with \svgpath{{../common/img/}}
when TEXINPUTS contains ../common/img/
, or when it contains ../common//
(since //
means to look into all directories recursively).
As TEXINPUTS is apparently not used to find SVG files, this result in SVG files not being found.
By comparison, the graphicx package uses both TEXINPUTS and \graphicspath
to find files.
I am facing an issue in which the command when using the beamer class and the svg package. My preamble looks lie this:
\documentclass[aspectratio=169]{beamer}
\usepackage{svg}
\svgsetup{inkscapearea=page, inkscapelatex=false}
Then I want to place an image:
\begin{frame}{Point process}
\begin{figure}
\centering
\includesvg[width=\textwidth]{assets/spatial-pp-realizations.svg}
\caption{foo}
\end{figure}
\end{frame}
This will cause the generated image to be placed at the top corner of the slide.
However, when placing the file generated by the \includesvg
macro directly on the figure:
\begin{frame}{Point process}
\begin{figure}
\centering
\includegraphics[width=0.7\textwidth]{svg-inkscape/spatial-pp-realizations_svg-raw.pdf}
\caption{foo}
\end{figure}
\end{frame}
The image then appears in the right place:
I think this might be an issue related with the interaction of the svg package and beamer. I have noticed that you define a branch with \if@svgx@beamer
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.