Jan 4, 2021
<p class="has-text-align-left" value="<amp-fit-text layout="fixed-height" min-font-size="6" max-font-size="72" height="80">本文主要记录了一个为了完成作业的R markdown新手小白的历程本文主要记录了一个为了完成作业的R markdown新手小白的历程目的
运用Rstudio, 通过R markdown实现一次作业的快速PDF展示和输出。
参照的链接
3.3 PDF document | R Markdown: The Definitive Guide
遇到的问题
生成不了PDF文档
! sh: pdflatex: command not found > install.packages("pdflatex")
Warning in install.packages : package ‘pdflatex’ is not available for this version of R
A version of this package for your version of R might be available elsewhere, see the ideas at <https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages>
> tinytex::install_tinytex()versuche URL '<https://yihui.org/tinytex/TinyTeX-1.tgz>'
Content type 'application/octet-stream' length 67952945 bytes (64.8 MB) ================================================== downloaded 64.8 MB - 缺少”pdflatex” 在生成的过程中提示找不到”pdflatex”,然后我去实验安装一下这个包,发现不是,通过查看提供的网址,应该是R调用的默认bash里没有设置latex的问题,我默认用zsh和vim,但是仍然不是答案,最后在https://bookdown.org/yihui/rmarkdown/pdf-document.html#latex-engine这个链接的latex-engine加里找到了答案。因为个人只是想完成作业,对字体什么的没有更高的要求,所以最后选择替代方案tinytex.
- 检查Rstudio设置 在Rstudio的Rstudio-preferences-sweave里会有渲染器和是否Use tinytex的选项,根据实际情况勾选。
模板
解决了上边的问题,就生成了一个实验一下,但打开导出的文件,这个字体和排版的确有点不尽如人意。打开https://bookdown.org/yihui/rmarkdown/document-templates.html?version=1.3.1093&mode=desktop 链接会发现,可以从Github里面选择安装,选项很多,所以果断放弃 😂

留下评论