r-由于更新,编织器中不需要的消毒(溢出)



去年春天,我使用了与下面的最低工作示例(MWE(类似的代码来实现这一点:https://cdn.advocacy.sba.gov/wp-content/uploads/2019/04/23142650/2019-Small-Business-Profiles-MA.pdf

根据knifer文档,表代码不应该被清除。然而,如果你编织MWE,你会看到几个角色确实被消毒(逃脱(了。例如,有时会变成textbackslash{}。因此,当代码被净化时,一些包更新似乎发生了变化。如果您只是简单地从下面复制RMD表代码并将其粘贴到TeX输出中,它编译得很好。

我试着恢复到去年的许多套餐,但都无济于事。

---
title: "MWE"
output:
pdf_document:
keep_tex: yes
---
begin{tabular}{@{}lll}
begin{tabular}{ll}
A & B \
A & B \
end{tabular}
&
begin{tabular}{ll}
A & B \
A & B \
end{tabular}
&
begin{tabular}{ll}
A & B \
A & B \
end{tabular}
end{tabular}

*[在我最初的代码中,它是"asis"块的一部分。你可以尝试一下,发现同样的问题。]

这是一个已知的问题,解决方案是将raw attributes添加到pandoc中,这样可以确保块内的内容不会被转义。

1( 添加md_extensions: +raw_attribute
2(添加乳胶块

对于您的示例,其工作原理如下:

---
title: "MWE"
output:
pdf_document:
md_extensions: +raw_attribute
keep_tex: yes
---
```{=latex}
begin{tabular}{@{}lll}
begin{tabular}{ll}
A & B \
A & B \
end{tabular}
&
begin{tabular}{ll}
A & B \
A & B \
end{tabular}
&
begin{tabular}{ll}
A & B \
A & B \
end{tabular}
end{tabular}
```

或者在代码块中使用时:

```{r, results = "asis"}
cat("```{=latex}")
// your latex code
cat("```")
```

附言:此功能需要pandoc 2.0.0版本

最新更新