Reputation: 23154
I just noticed in Inkscape you can export vector graphics to pdf + latex file, which basically separates text from graphics. This is really cool because it makes the font in the figures consistent with the font of the document.
Then I look into the documentation of device functions like postscript(), pdf()
, there seems to be no equivalent options. Is this possible in R?
At the request of @DWin, I explain a little bit further what I am looking for: a R function that can output two files: x.pdf and x.pdftex, the first one contains the graphics, the second one contains text (the separation may not be perfect, but for the most part it should be like this). Here is an example from 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%
After compiling you should get:
The advantage is that you can specify the font in the main latex document and the font of text in the figures will automatically be adjusted.
(Inkscape support ps+latex and eps+latex also.)
Upvotes: 2
Views: 1219
Reputation: 263481
R has three major plotting frameworks. You can specify the default font family for the postscriot() device
with psFonts()
; you can specify the fonts and family with indivudual calls to the device; and you can specify alternate fonts when using annotation functions like text()
or grid.text()
. You should specify a particular use case rather than leaving your question in a vague form that doesn't really ask for a particular codong solution
Upvotes: 0