Inline code and inline LaTeX, R Markdown Pandoc error 43

情到浓时终转凉″ 提交于 2019-12-11 07:36:46

问题


I've run into this issue a couple times now, but whenever I try to include both inline LaTeX and inline R code in my Rmd file, I get Pandoc error 43. Never been able to find a workaround other than just manually adding in what the R code would have been.

---
title: "HW4"
date: "2/23/2018"
header-includes:
  - \usepackage{amsmath}
  - \usepackage{amsthm}
output: 
  pdf_document
---

```{r}
x_bar <- 4
```

The blue line above is the true $\lambda = 4$, and the red line is our 
$\hat{\lambda}_{MLE} = \bar{x} = $ `r x_bar`.

Error:

l.192 \$ \hat{\lambda}

pandoc: Error producing PDF
Error: pandoc document conversion failed with error 43
Execution halted

回答1:


Move the inline R expression inside the $ symbols:

```{r}
x_bar <- 4
```

$\hat{\lambda}_{MLE} = \bar{x} = `r x_bar`$.

Rmd output:

Source: https://github.com/rstudio/rmarkdown/issues/385#issuecomment-77309571

Alternatively, leave the inline R code outside but delete the trailing space before the second $.



来源:https://stackoverflow.com/questions/48942068/inline-code-and-inline-latex-r-markdown-pandoc-error-43

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!