如何使用来将变量替换为字符串latex2expr
?我想在变量d1
中将变量的值四舍五入到小数点后两位吗?以下内容不起作用,但我确定您会明白。
require(latex2exp)
d1 = 0.30523
plot(1, 2)
text(1, 2, TeX('d_1 = {round($d1),2)}'), cex = 4)
诀窍是首先使用该paste0
函数创建正确的字符串。下面的代码应该工作。
require(latex2exp)
d1 = 0.30523
plot(1, 2, type="n")
new_text = paste0("$d_1 = ",round(d1,2),"$")
text(1, 2, TeX(new_text), cex = 4)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句