在呈现为 HTML 时,我使用 Tufte 样式定义 newthought() 的颜色没有问题,如下所示:
<font color = "blue">`r newthought('The Lab Supervisor')`</font> ...
但是,当呈现为 pdf 时,它不起作用。
我通过以下代码学会了在渲染为 HTML 和 pdf 时定义颜色:
em <- function(x, color) {
if (knitr::is_latex_output()) {
sprintf("\\textcolor{%s}{%s}", color, x)
} else if (knitr::is_html_output()) {
sprintf("<span style='color: %s;'>%s</span>", color,
x)
} else x
}
然后我应用内联 R 表达式如下:
``` `r em("The Lab Supervisor", "blue")` ```
是否有任何解决方案可以将两者结合起来`r newthought()`
,`r em()`
以便The Lab Supervisor
在渲染为 pdf 时设置为蓝色的小型大写字母?