【问题标题】:rmakrdown latex display equationmarkdown 乳胶显示方程
【发布时间】:2015-05-31 07:15:05
【问题描述】:

我无法让 rmarkdown 在 .docx 输出中生成乳胶显示公式,即使相同的代码生成正确的 .pdf(带有公式)。

这是一些产生问题的示例 .Rmd 代码:

# Stuff
Blah blah blah.

```{r blurb_1}
test.xy <- matrix(c(runif(10,10,30),runif(10,70,90)),ncol=2,byrow=T)
plot(test.xy)
```

As the data are a set of points 
$p_{1 \cdots n}=(x_{1} \cdots x_{n},y_{1} \cdots
y_{n})$, a measure of difference is the distance 
between any two points,$p_{i},p_{j}$,

\begin{equation}
\sqrt{(x_{i}-x_{j})^2+(y_{i}-y_{j})^2} 
\end{equation}

```{r blurb_2}
di <- dist.mat(test.xy[,1],test.xy[,2]) # a distance matrix
dim(di)
```
Of course, blah blah.

在 R 中运行时

rmarkdown::render(file.choose(),"pdf_document")

生成方程但是

rmarkdown::render(file.choose(),"word_document")

没有!谁能指导我如何使乳胶方程出现在 .docx 输出中?

任何解决我必须是基本错误的帮助将不胜感激! (我使用的是 R 3.1.1,rmarkdown 包 0.5.1 和 pandoc 1.13.2,例如,所有都是最新的。)

【问题讨论】:

  • word 使用自己的公式编辑器。 google 上有几个在 word 中使用 latex 的资源,但它并不完全支持 tex out-of-the-box afaik。

标签: r latex equation r-markdown


【解决方案1】:

只需使用 $$ 代替 \begin 和 \end 方程:

$$\sqrt{(x_{i}-x_{j})^2+(y_{i}-y_{j})^2}$$

【讨论】:

  • 我的声望不够高,无法给你投票,但感谢澄清了我对 $$ 的误解。
  • 如果您是提出问题的人,关键是接受最佳答案。单击赞成/反对票附近的复选标记以“接受”答案作为解决方案。
  • 有什么办法可以用方程式编号来实现这个吗?
猜你喜欢
  • 1970-01-01
  • 2023-03-26
  • 1970-01-01
  • 1970-01-01
  • 2010-11-29
  • 1970-01-01
  • 2019-04-14
  • 1970-01-01
  • 2019-10-07
相关资源
最近更新 更多