如果我将以下文件渲染为html,则一切正常。 如果我渲染为pdf,则会引发错误
输出文件:test.knit.md ! LaTeX错误:未知图形扩展名:.png?raw = true。 Fehler:无法编译test.tex。有关更多信息,请参见test.log。
原因是Rmd被翻译为
\begin{figure}
\centering
\includegraphics[width=4.16667in]{pics/myimage.png?raw=true}
\caption{Some text here.}
\end{figure}
在test.tex及以上代码中的毫无意义。
示例:
---
title: "Untitled"
author: "Myname"
date: "5 April 2019"
output:
pdf_document:
number_sections: yes
toc: yes
toc_depth: '2'
html_document:
keep_md: yes
number_sections: yes
toc: yes
toc_depth: 2
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
text
![Some text here.](pics/myimage.png?raw=true){width=400px}
text
我需要?raw=TRUE
用于github,请参阅here。
您还可以从here克隆示例!
编辑:我还问开发者here,因为我有感觉keep_md: yes
出了点问题...
答案 0 :(得分:2)
您可以通过for (auto it = v1.cbegin(); it != v1.end(); ++it)
{
std::cout << v1[i];
}
for (auto i = 0u; i < v2.size(); ++i)
{
std::cout << v1[i];
}
for (auto const i: v3)
{
std::cout << i;
}
(例如,
knitr::is_html_output()
答案 1 :(得分:1)
我将使用以下解决方法:
.rmd
中删除部分?raw=true
。.png
替换为.png?raw=true
并再次存储:您可以使用以下代码:
html <- readLines("your-file.html")
html <- sapply(html, function(x) gsub(".png", ".png?raw=true", x))
writeLines(html, "your-file.html")
就像您在html文件(它们所属的位置)中有?raw=true
注释,而不是在.tex
文件(以及.pdf
)中没有含义的{{1}}注释一样