【问题标题】:How to do different things in R in bookdown if output is html or latex如果输出是html或latex,如何在bookdown中的R中做不同的事情
【发布时间】:2017-01-19 15:09:23
【问题描述】:

我正在使用 bookdown 同时生成 html 和 pdf。我想在 html 版本中使用动态表(DT),但在 pdf 文件中使用普通表。有没有办法在降价中做到这一点,而不必将文件作为输入分开并使用 yml 文件。 类似的东西

if (output = html) {
    DT...
}
if (output = "pdf"){
    xlatex ...
}

谢谢 伦格

【问题讨论】:

  • 看起来您可以使用stackoverflow.com/questions/35144130/… 中描述的相同方法。我已将此标记为重复,然后将其收回,因为我不确定bookdown 机制是否相同。但现在我已经调查过了,我相信它是。

标签: r bookdown


【解决方案1】:

感谢一辉的评论编辑:

if( knitr:::is_latex_output() ) {
    xlatex ...
} else {
    DT...
}

【讨论】:

  • 您可以使用knitr:::is_latex_output()
  • Since knitr 1.18,你可以使用knitr::is_latex_output(),用两个冒号代替三个。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-02-01
  • 2018-05-18
相关资源
最近更新 更多