我在tex.stackexchange.com
不到两周前发布了这个问题,没有人能够提出解决方案,所以我希望我在这里复制问题不是问题。
我想使用tikz在我的文档中包含R图。我想将绝对所有字体,fontsizes,fontweights设置为TeX文档字体。我查看了tikzDevice和par()的文档,但是我找不到这样做的方法。附件是一个示例R脚本,生成一些需要治愈的数字:
library(tikzDevice)
tikz("/home/marius/Dokumenter/stk1110/oblig2/fig1.tex", width = 6, height = 5, pointsize=11)
# some data
menn = c(36.1,36.3,36.4,36.6,36.6,36.7,36.7,37.0,36.5,37.1)
kvinner = c(36.6,36.7,36.8,36.8,36.7,37.0,37.1,37.3,36.9,37.4)
par(mfrow=c(2,3))
# first row
boxplot(menn)
qqnorm(menn)
qqline(menn)
hist(menn, freq=FALSE)
x = seq(36,37.4,0.01)
lines(x, 1/(2*pi*var(menn))^0.5*exp(-(x-mean(menn))^2/(2*var(menn))))
# second row
boxplot(kvinner)
qqnorm(kvinner)
qqline(kvinner)
hist(kvinner, freq=FALSE)
lines(x, 1/(2*pi*var(kvinner))^0.5*exp(-(x-mean(kvinner))^2/(2*var(kvinner))))
par(ps=1, cex=1, cex.main=111, cex.lab=111, cex.axis=111, cex.sub=111, font.main=1)
dev.off()
和TeX文件:
\documentclass[11pt,norsk,a4paper]{article}
\usepackage[norsk]{babel}
\usepackage[paper=a4paper, top=1in,bottom=1.1in,right=0.9in,left=0.9in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[makeroom]{cancel}
\usepackage{amsmath,amsthm}
\usepackage{newtxtext}
\usepackage[T1]{fontenc}
\usepackage{pgf, pgfplots}
\usepackage{textcomp}
\date{\normalsize \today}
\begin{document}
I want all fonts in R plots to be exactly like this one.
\begin{figure}[!htbp]
\begin{center}
\input{fig1.tex}
\end{center}
\end{figure}
\end{document}
我希望这对R中的大多数不同图表(如果不是全部)都有效,这样我就可以拥有与文档正文完全相同的字体。即使是人物头衔。你能提出解决方案吗?