![打包 SVG:结果缺少一些部分](https://linux22.com/image/386499/%E6%89%93%E5%8C%85%20SVG%EF%BC%9A%E7%BB%93%E6%9E%9C%E7%BC%BA%E5%B0%91%E4%B8%80%E4%BA%9B%E9%83%A8%E5%88%86%20.png)
我设法设置了 SVG 包,以便它可以成功导入 SVG 文件。
完整配置如下:
\RequirePackage[width=\textwidth]{svg} % In my custom package
\PassOptionsToPackage{svgpath={uml/}}{svg} % In the file
然后我将 SVG 文件 ( uml/uml.svg
) 包含以下内容:
\includesvg{uml}
这项工作没有任何错误或警告。
然而,原始的 SVG 文件如下所示:(抱歉,这很糟糕,但您不能直接上传 SVG 文件)。请注意左上角的箭头。
我对此没有异议,只是左上角的三个箭头由于某种原因消失了。
阅读文档时我发现了该lastpage
选项,但它是为了修复 Inkscape 0.91 中的错误,而我正在运行 0.92.1 r15371。
SVG 文件是用 UMLet 生成的(但这不是问题,第一张图片是在生成之后出现的)。但是,缺少的箭头是我在创建图表时添加的第一个箭头,这似乎有点太巧合了——但是我不知道 SVG 是如何工作的,所以我真的不知道这是否有影响。
UMLet 生成的 UXF 文件|UMLet 生成的 SVG 文件|svg
包生成的临时 PDF 文件
最小工作示例:
\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[width=\textwidth]{svg}
\begin{document}
\includesvg{animaux}
\end{document}
您需要将该文件添加uml.svg
到同一文件夹中。
答案1
这似乎是 的一个错误inkscape
。将 svg 转换为 pdf 后,文件中似乎缺少了 25 页以上的所有页面./svg-inkscape/uml_svg-tex.pdf_tex
。您可以编辑文件并像下面的代码一样添加它们。
为了不意外覆盖文件,您可能需要更改名称并将其包含在
\def\svgwidth{\textwidth}
\input{YourNewName.pdf_tex}
代替\includesvg[width=\textwidth]{uml}
%% Creator: Inkscape inkscape 0.91, www.inkscape.org
%% PDF/EPS/PS + LaTeX output extension by Johan Engelen, 2010
%% Accompanies image file 'uml_svg-tex.pdf' (pdf, eps, ps)
%%
%% To include the image in your LaTeX document, write
%% \input{<filename>.pdf_tex}
%% instead of
%% \includegraphics{<filename>.pdf}
%% To scale the image, write
%% \def\svgwidth{<desired width>}
%% \input{<filename>.pdf_tex}
%% instead of
%% \includegraphics[width=<desired width>]{<filename>.pdf}
%%
%% Images with a different path to the parent latex file can
%% be accessed with the `import' package (which may need to be
%% installed) using
%% \usepackage{import}
%% in the preamble, and then including the image with
%% \import{<path to file>}{<filename>.pdf_tex}
%% Alternatively, one can specify
%% \graphicspath{{<path to file>/}}
%%
%% For more information, please see info/svg-inkscape on CTAN:
%% http://tug.ctan.org/tex-archive/info/svg-inkscape
%%
\begingroup%
\makeatletter%
\providecommand\color[2][]{%
\errmessage{(Inkscape) Color is used for the text in Inkscape, but the package 'color.sty' is not loaded}%
\renewcommand\color[2][]{}%
}%
\providecommand\transparent[1]{%
\errmessage{(Inkscape) Transparency is used (non-zero) for the text in Inkscape, but the package 'transparent.sty' is not loaded}%
\renewcommand\transparent[1]{}%
}%
\providecommand\rotatebox[2]{#2}%
\ifx\svgwidth\undefined%
\setlength{\unitlength}{592.8bp}%
\ifx\svgscale\undefined%
\relax%
\else%
\setlength{\unitlength}{\unitlength * \real{\svgscale}}%
\fi%
\else%
\setlength{\unitlength}{\svgwidth}%
\fi%
\global\let\svgwidth\undefined%
\global\let\svgscale\undefined%
\makeatother%
\begin{picture}(1,0.48717949)%
\put(0,0){\includegraphics[width=\unitlength,page=1]{uml_svg-tex.pdf}}%
\put(0.03036437,0.07219973){\makebox(0,0)[lb]{\smash{Maladie}}}%
\put(0,0){\includegraphics[width=\unitlength,page=2]{uml_svg-tex.pdf}}%
\put(0.2780027,0.07137733){\makebox(0,0)[lb]{\smash{Médicament}}}%
\put(0,0){\includegraphics[width=\unitlength,page=3]{uml_svg-tex.pdf}}%
\put(0.58164642,0.20633009){\makebox(0,0)[lb]{\smash{Matériel}}}%
\put(0,0){\includegraphics[width=\unitlength,page=4]{uml_svg-tex.pdf}}%
\put(0.84075574,0.20633009){\makebox(0,0)[lb]{\smash{Nourriture}}}%
\put(0,0){\includegraphics[width=\unitlength,page=5]{uml_svg-tex.pdf}}%
\put(0.57354926,0.07137733){\makebox(0,0)[lb]{\smash{\textit{Stockable}}}}%
\put(0,0){\includegraphics[width=\unitlength,page=6]{uml_svg-tex.pdf}}%
\put(0.82726046,0.34128286){\makebox(0,0)[lb]{\smash{Classification}}}%
\put(0,0){\includegraphics[width=\unitlength,page=7]{uml_svg-tex.pdf}}%
\put(0.31174089,0.46274035){\makebox(0,0)[lb]{\smash{Rang}}}%
\put(0,0){\includegraphics[width=\unitlength,page=8]{uml_svg-tex.pdf}}%
\put(0.28340081,0.20633009){\makebox(0,0)[lb]{\smash{\textit{Événement}}}}%
\put(0,0){\includegraphics[width=\unitlength,page=9]{uml_svg-tex.pdf}}%
\put(0.03103914,0.34128286){\makebox(0,0)[lb]{\smash{Contrat}}}%
\put(0,0){\includegraphics[width=\unitlength,page=10]{uml_svg-tex.pdf}}%
\put(0.58704453,0.34128286){\makebox(0,0)[lb]{\smash{Animal}}}%
\put(0,0){\includegraphics[width=\unitlength,page=11]{uml_svg-tex.pdf}}%
\put(0.2928475,0.34128286){\makebox(0,0)[lb]{\smash{Personne }}}%
\put(0,0){\includegraphics[width=\unitlength,page=12]{uml_svg-tex.pdf}}%
\put(0.39676113,0.11740891){\makebox(0,0)[lb]{\smash{n}}}%
\put(0,0){\includegraphics[width=\unitlength,page=13]{uml_svg-tex.pdf}}%
\put(0.98380567,0.31969042){\makebox(0,0)[lb]{\smash{1}}}%
\put(0,0){\includegraphics[width=\unitlength,page=14]{uml_svg-tex.pdf}}%
\put(0.07287449,0.11740891){\makebox(0,0)[lb]{\smash{n}}}%
\put(0,0){\includegraphics[width=\unitlength,page=15]{uml_svg-tex.pdf}}%
\put(0.28879892,0.11740891){\makebox(0,0)[lb]{\smash{n}}}%
\put(0,0){\includegraphics[width=\unitlength,page=16]{uml_svg-tex.pdf}}%
\put(0.23424845,0.04978489){\makebox(0,0)[lb]{\smash{n}}}%
\put(0.16059379,0.04978489){\makebox(0,0)[lb]{\smash{n}}}%
\put(0,0){\includegraphics[width=\unitlength,page=17]{uml_svg-tex.pdf}}%
\put(0.89608637,0.27245695){\makebox(0,0)[lb]{\smash{1}}}%
\put(0,0){\includegraphics[width=\unitlength,page=18]{uml_svg-tex.pdf}}%
\put(0.95006748,0.38731444){\makebox(0,0)[lb]{\smash{0..1}}}%
\put(0,0){\includegraphics[width=\unitlength,page=19]{uml_svg-tex.pdf}}%
\put(0.78801876,0.31969042){\makebox(0,0)[lb]{\smash{1}}}%
\put(0,0){\includegraphics[width=\unitlength,page=20]{uml_svg-tex.pdf}}%
\put(0.34278003,0.40740971){\makebox(0,0)[lb]{\smash{1}}}%
\put(0,0){\includegraphics[width=\unitlength,page=21]{uml_svg-tex.pdf}}%
\put(0.42802753,0.2214216){\makebox(0,0)[lb]{\smash{1..n}}}%
\put(0.49573064,0.28300648){\makebox(0,0)[lb]{\smash{0..1}}}%
\put(0,0){\includegraphics[width=\unitlength,page=22]{uml_svg-tex.pdf}}%
\put(0.34278003,0.25236167){\makebox(0,0)[lb]{\smash{1..n}}}%
\put(0.34278003,0.27245695){\makebox(0,0)[lb]{\smash{n}}}%
\put(0,0){\includegraphics[width=\unitlength,page=23]{uml_svg-tex.pdf}}%
\put(0.15770904,0.28228502){\makebox(0,0)[lb]{\smash{1}}}%
\put(0,0){\includegraphics[width=\unitlength,page=24]{uml_svg-tex.pdf}}%
\put(0.23471241,0.31969042){\makebox(0,0)[lb]{\smash{1}}}%
\put(0.16059379,0.31969042){\makebox(0,0)[lb]{\smash{0..1}}}%
\put(0,0){\includegraphics[width=\unitlength,page=25]{uml_svg-tex.pdf}}%
\put(0.43049933,0.31969042){\makebox(0,0)[lb]{\smash{1}}}%
\put(0.51764926,0.31969042){\makebox(0,0)[lb]{\smash{n}}}%
\put(0,0){\includegraphics[width=\unitlength,page=26]{uml_svg-tex.pdf}}%
\put(0,0){\includegraphics[width=\unitlength,page=27]{uml_svg-tex.pdf}}%
\put(0,0){\includegraphics[width=\unitlength,page=28]{uml_svg-tex.pdf}}%
\put(0,0){\includegraphics[width=\unitlength,page=29]{uml_svg-tex.pdf}}%
\put(0,0){\includegraphics[width=\unitlength,page=30]{uml_svg-tex.pdf}}%
\put(0,0){\includegraphics[width=\unitlength,page=31]{uml_svg-tex.pdf}}%
\end{picture}%
\endgroup%
或者,您可以自己将 .svg 转换为 .pdf,并防止创建单独的图层,例如https://tex.stackexchange.com/a/350175/36296