这是我的 SVG 绘图:
svg
我使用如下包将其包含在我的 LaTeX 文档中:
\documentclass{article}
\usepackage{svg}
\begin{document}
\includesvg{idea.svg}
\end{document}
结果如下:
然后我使用该svg-extract
包将其提取成包含渲染的 LaTeX 数学公式的 PDF:
\documentclass{article}
\usepackage[extractformat=pdf]{svg-extract}
\begin{document}
\includesvg[keepaspectratio]{idea.svg}
\end{document}
我运行latexmk --shell-escape idea.tex
,得到的PDF如下:
看起来文本已被移动以适应比 SVG 最初预期的更小的边界框。
我怎样才能防止这种行为并恢复原始 PDF 中的 SVG?
SVG 文件
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="297mm"
height="210mm"
viewBox="0 0 297 210"
version="1.1"
id="svg5"
inkscape:version="1.2.2 (732a01da63, 2022-12-09)"
sodipodi:docname="idea.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview7"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="mm"
showgrid="false"
inkscape:zoom="2.0000001"
inkscape:cx="324.74999"
inkscape:cy="230.74999"
inkscape:window-width="3200"
inkscape:window-height="1721"
inkscape:window-x="5591"
inkscape:window-y="-9"
inkscape:window-maximized="1"
inkscape:current-layer="layer1" />
<defs
id="defs2">
<inkscape:path-effect
effect="bspline"
id="path-effect1048"
is_visible="true"
lpeversion="1"
weight="33.333333"
steps="2"
helper_size="0"
apply_no_weight="true"
apply_with_weight="true"
only_selected="false" />
<inkscape:path-effect
effect="bspline"
id="path-effect14718"
is_visible="true"
lpeversion="1"
weight="33.333333"
steps="2"
helper_size="0"
apply_no_weight="true"
apply_with_weight="true"
only_selected="false" />
<linearGradient
id="linearGradient12496"
inkscape:swatch="solid">
<stop
style="stop-color:#ededed;stop-opacity:1;"
offset="0"
id="stop12494" />
</linearGradient>
<inkscape:path-effect
effect="bspline"
id="path-effect12378"
is_visible="true"
lpeversion="1"
weight="33.333333"
steps="2"
helper_size="0"
apply_no_weight="true"
apply_with_weight="true"
only_selected="false" />
<inkscape:path-effect
effect="bspline"
id="path-effect12301"
is_visible="true"
lpeversion="1"
weight="33.333333"
steps="2"
helper_size="0"
apply_no_weight="true"
apply_with_weight="true"
only_selected="false" />
<inkscape:path-effect
effect="bspline"
id="path-effect12291"
is_visible="true"
lpeversion="1"
weight="33.333333"
steps="2"
helper_size="0"
apply_no_weight="true"
apply_with_weight="true"
only_selected="false" />
<inkscape:path-effect
effect="bspline"
id="path-effect12281"
is_visible="true"
lpeversion="1"
weight="33.333333"
steps="2"
helper_size="0"
apply_no_weight="true"
apply_with_weight="true"
only_selected="false" />
<inkscape:path-effect
effect="bspline"
id="path-effect7434"
is_visible="true"
lpeversion="1"
weight="33.333333"
steps="2"
helper_size="0"
apply_no_weight="true"
apply_with_weight="true"
only_selected="false" />
<inkscape:path-effect
effect="bspline"
id="path-effect7282"
is_visible="true"
lpeversion="1"
weight="33.333333"
steps="2"
helper_size="0"
apply_no_weight="true"
apply_with_weight="true"
only_selected="false" />
<linearGradient
id="linearGradient6490"
inkscape:swatch="solid">
<stop
style="stop-color:#000000;stop-opacity:1;"
offset="0"
id="stop6488" />
</linearGradient>
<marker
style="overflow:visible"
id="Arrow1"
refX="0"
refY="0"
orient="auto-start-reverse"
inkscape:stockid="Arrow1"
markerWidth="6.0609999"
markerHeight="10.011125"
viewBox="0 0 4.0606602 6.7071068"
inkscape:isstock="true"
inkscape:collect="always"
preserveAspectRatio="xMidYMid">
<path
style="fill:none;stroke:context-stroke;stroke-width:1;stroke-linecap:butt"
d="M 3,-3 0,0 3,3"
id="path5057"
transform="rotate(180,0.125,0)"
sodipodi:nodetypes="ccc" />
</marker>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient12496"
id="linearGradient12498"
x1="182.39424"
y1="65.837943"
x2="245.46962"
y2="65.837943"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.5628514,0,0,1.2624362,65.725835,1.6300776)" />
<inkscape:path-effect
effect="bspline"
id="path-effect14718-0"
is_visible="true"
lpeversion="1"
weight="33.333333"
steps="2"
helper_size="0"
apply_no_weight="true"
apply_with_weight="true"
only_selected="false" />
<inkscape:path-effect
effect="bspline"
id="path-effect14718-0-5"
is_visible="true"
lpeversion="1"
weight="33.333333"
steps="2"
helper_size="0"
apply_no_weight="true"
apply_with_weight="true"
only_selected="false" />
<inkscape:path-effect
effect="bspline"
id="path-effect14718-0-5-7"
is_visible="true"
lpeversion="1"
weight="33.333333"
steps="2"
helper_size="0"
apply_no_weight="true"
apply_with_weight="true"
only_selected="false" />
</defs>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<path
style="fill:none;stroke:#000000;stroke-width:0.586;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#Arrow1)"
d="M 71.590594,50.454786 V 131.46511"
id="path245" />
<path
style="fill:none;stroke:#000000;stroke-width:0.586;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#Arrow1)"
d="M 71.590594,131.46511 H 181.93108"
id="path1275" />
<text
xml:space="preserve"
style="font-size:3.175px;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:0.165;stroke-miterlimit:3.5;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
x="186.05757"
y="132.93013"
id="text10557-1-0"><tspan
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:4.93889px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Italic';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;fill:#000000;fill-opacity:1;stroke-width:0.165;stroke-miterlimit:3.5;stroke-dasharray:none"
x="186.05757"
y="132.93013"
sodipodi:role="line"
id="tspan1108">$t$</tspan></text>
<text
xml:space="preserve"
style="font-size:3.175px;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:0.165;stroke-miterlimit:3.5;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
x="51.640903"
y="45.129822"
id="text10557-1-0-5"><tspan
sodipodi:role="line"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:4.93889px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Italic';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;fill:#000000;fill-opacity:1;stroke-width:0.165;stroke-miterlimit:3.5;stroke-dasharray:none"
x="51.640903"
y="45.129822"
id="tspan10559-9-2-3">$\int{x}$</tspan></text>
<rect
style="fill:url(#linearGradient12498);fill-opacity:1;fill-rule:nonzero;stroke:#000101;stroke-width:0.421474;stroke-miterlimit:3.5;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.550725"
id="rect12492"
width="35.220638"
height="32.770851"
x="168.5274"
y="68.36087" />
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.175px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:#010101;stroke-width:0.165;stroke-miterlimit:3.5;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
x="171.8385"
y="74.420906"
id="text13082"><tspan
sodipodi:role="line"
id="tspan13080"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.175px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;fill:#000000;fill-opacity:1;stroke:#010101;stroke-width:0.165;stroke-dasharray:none;stroke-opacity:1"
x="171.8385"
y="74.420906">Legend</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.175px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:#010101;stroke-width:0.165;stroke-miterlimit:3.5;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
x="181.14133"
y="80.155449"
id="text13082-2"><tspan
sodipodi:role="line"
id="tspan13080-2"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.175px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;fill:#000000;fill-opacity:1;stroke:#010101;stroke-width:0.165;stroke-dasharray:none;stroke-opacity:1"
x="181.14133"
y="80.155449">$p_{max}$</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.175px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:#010101;stroke-width:0.165;stroke-miterlimit:3.5;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
x="181.14133"
y="85.640045"
id="text13082-2-3"><tspan
sodipodi:role="line"
id="tspan13080-2-7"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.175px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;fill:#000000;fill-opacity:1;stroke:#010101;stroke-width:0.165;stroke-dasharray:none;stroke-opacity:1"
x="181.14133"
y="85.640045">$p_{tgt}$</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.175px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:#010101;stroke-width:0.165;stroke-miterlimit:3.5;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
x="181.14133"
y="90.595474"
id="text13082-2-3-4"><tspan
sodipodi:role="line"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.175px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;fill:#000000;fill-opacity:1;stroke:#010101;stroke-width:0.165;stroke-dasharray:none;stroke-opacity:1"
x="181.14133"
y="90.595474"
id="tspan17322">$p_{min}$</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.175px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:#010101;stroke-width:0.165;stroke-miterlimit:3.5;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
x="181.14133"
y="96.14344"
id="text13082-2-3-4-3"><tspan
sodipodi:role="line"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.175px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;fill:#000000;fill-opacity:1;stroke:#010101;stroke-width:0.165;stroke-dasharray:none;stroke-opacity:1"
x="181.14133"
y="96.14344"
id="tspan17322-2">Constraint</tspan></text>
<path
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:#ff0303;stroke-width:0.5;stroke-miterlimit:3.5;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
d="m 172.30655,79.308188 c 0,0 7.37439,0 7.37439,0"
id="path14716"
inkscape:path-effect="#path-effect14718"
inkscape:original-d="m 172.30655,79.308188 h 7.37439" />
<path
style="fill:#000000;fill-opacity:0.946176;fill-rule:nonzero;stroke:#000000;stroke-width:0.5;stroke-miterlimit:3.5;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
d="m 172.30655,84.513643 c 0,0 7.37439,0 7.37439,0"
id="path14716-5"
inkscape:path-effect="#path-effect14718-0"
inkscape:original-d="m 172.30655,84.513643 h 7.37439" />
<path
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:#03d000;stroke-width:0.5;stroke-miterlimit:3.5;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
d="m 172.30655,89.719098 c 0,0 7.37439,0 7.37439,0"
id="path14716-5-0"
inkscape:path-effect="#path-effect14718-0-5"
inkscape:original-d="m 172.30655,89.719098 h 7.37439" />
<path
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:#1100d0;stroke-width:0.5;stroke-miterlimit:3.5;stroke-dasharray:1, 0.5;stroke-dashoffset:0;stroke-opacity:1"
d="m 172.30655,95.235799 c 0,0 7.37439,0 7.37439,0"
id="path14716-5-0-2"
inkscape:path-effect="#path-effect14718-0-5-7"
inkscape:original-d="m 172.30655,95.235799 h 7.37439" />
<path
style="fill:none;stroke:#1100d0;stroke-width:0.600001;stroke-linejoin:bevel;stroke-miterlimit:3.5"
d="M 84.005205,121.44375 C 91.633969,104.68692 99.262789,87.929975 111.76463,76.692785 124.26648,65.455595 141.64044,59.738558 159.01458,54.02146"
id="path1046"
inkscape:path-effect="#path-effect1048"
inkscape:original-d="m 84.005205,121.44375 c 7.629083,-16.75668 15.257904,-33.513629 22.886455,-50.270837 17.37492,-5.717 34.74888,-11.434037 52.12292,-17.151453" />
</g>
</svg>
答案1
如果您想要将 PDF 裁剪为所包含的 SVG 的大小,请使用standalone
文档类而不是article
(PDF 输出):
\documentclass{standalone}
\usepackage{svg}
\begin{document}
\includesvg{idea.svg}
\end{document}