2013-10-28 89 views
2

我剛剛在Inkscape中注意到,您可以將矢量圖形導出爲pdf + latex文件,它基本上將文本與圖形分開。這非常酷,因爲它使數字中的字體與文檔的字體一致。將R圖導出到pdf + latex

然後我看看設備功能的文檔,如postscript(), pdf(),似乎沒有相應的選項。這在R中可能嗎?


在@DWin的要求,我解釋一下什麼進一步的我在尋找:可輸出兩個文件A R功能:x.pdf和x.pdftex,第一個包含了圖形,第二個包含文本(分離可能不完美,但大部分應該是這樣)。下面是從Inkscape的一個例子:

x.pdf:

enter image description here

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% 

編譯你應該得到後:

enter image description here

的好處是你可以指定主乳膠文檔中的字體和數字中的文字字體將自動進行調整。

(Inkscape中支持PS +膠乳和EPS +膠乳也。)

回答

0

R具有三個主要的繪圖框架。您可以使用psFonts()指定postscriot() device的默認字體系列;您可以通過對設備的單獨調用指定字體和家族;並且您可以在使用註釋功能(如text()grid.text())時指定備用字體。你應該指定一個特定的用例,而不是將你的問題留在模糊的形式中,而不是真的要求特定的解決方案

+0

我編輯了我的問題 – qed

+0

需要'knitr'或'Sweave'。 –