问题描述
R Markdown是用于文档创作的好工具.它可以在R Markdown目录中使用LaTeX语句.但是,当我尝试插入Ti k Z图片时,我不知道如何在其中添加前导\usepackage{tikz}
,因此编译将失败.
R Markdown is a good tool for document authoring. It can use LaTeX statement in R Markdown directory. But when I try to insert a TikZ picture, I am lost about how to add preamble \usepackage{tikz}
in it, so compile will fail.
示例代码:
---
title: "R Markdown with tikz picture"
author: "Me"
date: "January 10, 2015"
output: beamer_presentation
---
## TikZ picture
- Here is a TikZ picutre
\begin{tikzpicture}
\draw (0,0) circle (2cm);
\end{tikzpicture}
由于实际上它会生成LaTeX文档,因此可以将其添加到LaTeX中,然后将其编译为PDF,但是我希望我可以在R Markdown中进行处理,然后单击编织为PDF"按钮以生成该文件直接使用PDF文档.
Since actually it will generate a LaTeX document, so it's fine to just add it in LaTeX and then compile it to PDF but I wish I can just do it in R Markdown, then click the "Knit to PDF" button to generate PDF document directly.
推荐答案
在,介绍了如何在R Markdown中使用LaTeX软件包.不确定tikz软件包是否可以与R Markdown一起使用.
In this post it is described how to use LaTeX packages in R Markdown. Not sure if the tikz-package works with R Markdown though.
这篇关于R Markdown中的TikZ的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!