我刚刚注意到在 Inkscape 中,您可以将矢量图形导出为 pdf + Latex 文件,这基本上将文本与图形分开。这真的很酷,因为它使图形中的字体与文档的字体保持一致。
然后我查看了类似设备功能的文档postscript(), pdf()
,似乎没有等效的选项。这在R中可能吗?
应@DWin的要求,我进一步解释了我在寻找什么:一个可以输出两个文件的R函数:x.pdf和x.pdftex,第一个包含图形,第二个包含文本(分离可能并不完美,但大部分情况下应该是这样的)。这是inkscape的一个例子:
x.pdf:
x.pdftex
%% Creator: Inkscape inkscape 0.48.4, www.inkscape.org
%% PDF/EPS/PS + LaTeX output extension by Johan Engelen, 2010
%% Accompanies image file 'drawing.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}{86.275bp}%
\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.86757462)%
\put(0,0){\includegraphics[width=\unitlength]{drawing.pdf}}%
\put(0.15439887,0.382321){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{test}}}%
\end{picture}%
\endgroup%
编译后你应该得到:
优点是您可以在主 Latex 文档中指定字体,并且会自动调整图中文本的字体。
(Inkscape 也支持 ps+latex 和 eps+latex。)