r - 无法使用相同的 Rmarkdown 输入输出到 pdf、word 和 HTML
问题描述
所以我希望有一个简单HTML
的Word
, 和PDF
输出到静态R
降价文档。它在下面。
该脚本与 Word 和 HTML 很好地结合在一起。但是编织到 pdf 会出现以下错误。
! Package amsmath Error: \begin{align} allowed only in paragraph mode.
Error: LaTeX failed to compile pdfissuesdoubeldollar.tex. See
https://yihui.org/tinytex/r/#debugging for debugging tips. See
pdfissuesdoubeldollar.log for more info
现在,我可以同时取出 $$,它会进行 PDF 和 HTML 编织,但 Word 只是跳过了编写方程式。仅使用一美元也无济于事,而且还存在方程式未在页面上居中的问题。
有一些解决方法,例如制作 word 文件,然后使用 acrobat 或将 word 文件另存为 PDF。但我正在尝试自动编织大约 130 个文件,而不必维护两个单独的文件。不必维护单独的文件是我从 MSWord 迁移到 Rmarkdown 的唯一主要原因。我愿意有一个有条件的 R 脚本,有和没有美元,但我怎样才能捕捉到它正在编织的输出格式以及我该怎么做。任何帮助将不胜感激。
Rmarkdown 脚本如下
output:
pdf_document:
toc: no
toc_depth: '4'
html_document:
toc: yes
toc_depth: 4
toc_float: yes
theme: readable
word_document:
toc: no
toc_depth: '4'
{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
$$\begin{align} \in_{a} &= \frac{\text{Approximate Error}}{\text{Present Approximation}}\\ &= \frac{- 0.3830}{9.8800}\\ &= - 0.0388\end{align}$$
解决方案
通常我总是使用\begin{split}
而不是\begin{align}
用于 LaTeX 方程。
推荐阅读
- angular - 启动 d3-svg-annotation 应用程序
- c++ - 如何在 C++ 中解析 UNC 路径
- python - Python 脚本“生成”“无”值
- sql - 如何理解 Oracle 中跟踪文件的统计信息。如 CPU、经过时间、查询...等
- javascript - 带有 AJAX 的 PHP 邮件()
- javascript - 不可变的 JS 和 redux
- installation - 在 rtems (VB) 上找不到构建集文件 4.11/rtems-sparc
- javascript - 如何进行模态转换?
- sql-server - 如果链接表不包含特定值,则返回计数
- symfony - Symfony,如何显示对象的正常名称而不是实体编号