我正在尝试在从 Inkscape 导出的 tex 文件中获取不同大小的字体。我的想法是,我的图可能包含应该比其他文本更大的标题文本。例如,我在 Inkscape 中有这个:
最终看起来像这样:
我并不想在导出之前完全控制文本大小,但如果我能得到 2 或 3 个差异,我就可以缩放整个图像来获得我需要的东西。
以下是三个文件(svg、导出的 tex、最小文档):
SVG:
<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="249"
height="128.25"
id="svg4384"
version="1.1"
inkscape:version="0.48.3.1 r9886"
sodipodi:docname="New document 11">
<defs
id="defs4386" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1.6006032"
inkscape:cx="166.8913"
inkscape:cy="76.406645"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:window-width="1366"
inkscape:window-height="709"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1" />
<metadata
id="metadata4389">
<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(-121.4375,-132.9375)">
<g
id="g4406"
transform="translate(18.742934,-6.8724092)">
<text
sodipodi:linespacing="125%"
id="text4392"
y="195.21933"
x="140"
style="font-size:28px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
xml:space="preserve"><tspan
y="195.21933"
x="140"
id="tspan4394"
sodipodi:role="line">Header Text.</tspan></text>
<text
sodipodi:linespacing="125%"
id="text4396"
y="220.1759"
x="198.05034"
style="font-size:14px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
xml:space="preserve"><tspan
y="220.1759"
x="198.05034"
id="tspan4398"
sodipodi:role="line">Smaller text.</tspan></text>
<text
sodipodi:linespacing="125%"
id="text4400"
y="241.41789"
x="237.41049"
style="font-size:14px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
xml:space="preserve"><tspan
style="font-size:8px"
y="241.41789"
x="237.41049"
id="tspan4402"
sodipodi:role="line">Some even smaller.</tspan></text>
<rect
ry="6.6343722"
y="151.45181"
x="121.82908"
height="109.33378"
width="213.04468"
id="rect4404"
style="color:#000000;fill:none;stroke:#000000;stroke-width:0.78299999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:1.56600001, 1.56600001;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
</g>
</g>
</svg>
Inkscape乳胶:
%% Creator: Inkscape inkscape 0.48.3.1, www.inkscape.org
%% PDF/EPS/PS + LaTeX output extension by Johan Engelen, 2010
%% Accompanies image file 'sample.eps' (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}{171.05bp}%
\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.51505408)%
\put(0,0){\includegraphics[width=\unitlength]{sample.eps}}%
\put(0.08681672,0.3085328){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{Header Text.}}}%
\put(0.35831787,0.19181103){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{Smaller text.}}}%
\put(0.54240511,0.09246236){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{Some even smaller.}}}%
\end{picture}%
\endgroup%
样本乳胶文档:
\documentclass{article}
\usepackage{graphicx}
\usepackage{color}
\begin{document}
\begin{figure}
\centering
\def\svgwidth{\columnwidth}
\input{sample.eps_tex}
\end{figure}
\end{document}
答案1
由于 Inkscape 只会按原样移动文本,因此我能够简单地将 Latex 嵌入文本本身。这不是最优雅的解决方案,但确实有效。
唯一的“陷阱”是文本位置取决于文本在 svg 中的起始位置。因此,如果您使用被解释的 latex 命令开始文本,文本将最终位于 latex 的起始位置。这使得块中的文本更难放置。我发现先使用默认大小的文本布局图表,然后再返回添加{\huge Header text}
或会更容易{\footnotesize Smaller text}
。YMMV。