我正在使用Tikz在R中制作一个人物。我使用mtext添加跨越两行的文本到边距。如何减少mtext生成的两行文本之间的距离?
以下是R脚本的示例:
library("tikzDevice")
outfn<-"LineSpaceingExample.tex"
mydim <- 4
tikz(outfn,standAlone=TRUE,width=mydim,height=mydim)
mytext<- "This is some\nexample text"
x<-c(0, 1)
y<-x
plot(x, y, type = "n")
mtext(text=mytext, side=3,line=0.1)
dev.off()
为了澄清,我想控制“这是一些”和“示例文本”之间的垂直距离。
答案 0 :(得分:0)
另一轮谷歌搜索a solution:在调用par()$lheight
之前减少了mtext
。
以下脚本可以解决问题:
library("tikzDevice")
outfn<-"LineSpaceingExample.tex"
mydim<-4
tikz(outfn,standAlone=TRUE,width=mydim,height=mydim)
mytext1<- "This is the default\nline spacing"
mytext2<- "This is modified\nline spacing"
x<-c(0, 1)
y<-x
plot(x, y, type = "n")
mtext(text=mytext1, side=3,line=0.1, at=0.2)
par(lheight=0.8)
mtext(text=mytext2, side=3,line=0.1, at=0.8)
dev.off()