召集壮士帮忙测试 TinyTeX
我原本以为三天能解决的问题,最终花了两整周时间,这就是理想和现实的差距。其实这里面花的暗时间更多,这两周用了好多我以前积攒的经验,要是没有这些年踩坑的经验,恐怕两个月都搞不定。
dapengde 投向 Linux 要慎重。建议还是先用虚拟机玩一年再说,看适不适应。Linux 对 R 用户来说最大的不便就是有些包需要从源码编译,得寻找相应的头文件包(什么 libcurl4-dev 之类的),这个有点烦。对普通用户来说,Linux 娱乐功能可能差一点。我已经退出这个江湖四年,但就 R 包开发者而言,Linux 应该比 Windows 还是方便更多,macOS 本质是 Unix,所以对开发者来说也不错,就是贵,而且被苹果的屏幕惯坏眼睛之后,看别的电脑屏幕总觉得线条不够清晰。
fedora 27,今天测试报错
错误: Functions that produce HTML output found in document targeting latex output.
Please change the output type of this document to HTML. Alternatively, you can allow
HTML output in non-HTML formats by adding this option to the YAML front-matter of
your rmarkdown file:
always_allow_html: yes
Note however that the HTML output will not be visible in non-HTML formats.
停止执行
但我的头文件是这样的
output:
pdf_document:
latex_engine: xelatex
documentclass: ctexart
所以这个
always_allow_html: yes
怎么换成 no
lovebluesky 错误消息说你的 R Markdown 文档中包含 HTML 元素。在 PDF 输出中是不能有 HTML 元素的。
yihui 明白了,大概因为我这两天正在弄 leaflet吧,但是还有报错:
!LaTeX Error: File `ctexart.cls' not found.
Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: cls)
Enter file name:
! Emergency stop.
<read *>
l.2 \usepackage
pandoc: Error producing PDF
错误: pandoc document conversion failed with error 43
停止执行
> library(tinytex)
> tlmgr_search('ctexart.cls')
tlmgr search --file --global 'ctexart.cls'
sh: tlmgr: 未找到命令
Warning message:
In tlmgr(c("search", if (file) "--file", if (all) "--all", if (global) "--global", :
TeX Live does not seem to be installed. See https://yihui.name/tinytex/.
> tlmgr_install('ctex')
tlmgr install ctex
sh: tlmgr: 未找到命令
tlmgr path add
sh: tlmgr: 未找到命令
Warning messages:
1: In tlmgr(c("install", pkgs), usermode) :
TeX Live does not seem to be installed. See https://yihui.name/tinytex/.
2: In tlmgr(c("path", match.arg(action))) :
TeX Live does not seem to be installed. See https://yihui.name/tinytex/.
lovebluesky 请根据警告信息的提示看网页并安装 TinyTeX。
yihui 我已经按照你中文文档安装过了,并且没报错,所以很奇怪为什么没有安装,而且我 'library(tinytex)' 并没有报错,是不是说明我已经安装好了tinytex了?回家再重新安装一下看看吧。
lovebluesky 你有没有运行过 tinytex::install_tinytex()
来安装 TinyTex? tinytex 的 r 包是安装 TinyTex 这个 tex 发行版的必要不充分条件
yufree 这个印象里是直接从谢老大的中文文档里复制运行过了,但既然你的回复谢老大都点赞了,那基本可以确定是我漏掉了,sorry,我只是比较喜欢 Rmarkdown 编辑文档的方式,但很多东西都不太懂,给大家添麻烦了,感谢回复。
lovebluesky
还是命名的问题造成误解,全小写的tinytex是你装的r package, TinyTeX这种坑坑洼洼佶屈聱牙一波未平一波又起的名字指的是latex库。
话说是不是可以把这个库塞进r包里,就像rstudio自带pandoc一样。
tctcab 我之所以不想打包,就是因为 LaTeX 世界的许可证实在是很奇葩,我没见过哪个别的社区的开源许可证如此模糊。参见 FAQ 2:https://yihui.name/tinytex/faq/ TeX Live 自己的许可证说不清,CTAN 上的包也不能保证全部免费开源,加上 LaTeX 社区还有自己独特的 LPPL:https://www.latex-project.org/lppl/ 所以我只敢提供安装脚本。
在安装 TeX 包的过程中,运行很久(如下),我估计主要是网速问题,以前使用 TeXlive 或 MikTeX 时候,都自己先设定就近的仓库,如 <https://mirrors.tuna.tsinghua.edu.cn/CTAN/>,再安装都是很快的,在 tinytex 包中是否实现了这个?
library(tinytex)
tlmgr_search('/framed.sty') # search for framed.sty
tlmgr_install('framed')
- 已编辑
dapengde CTeX 和 TinyTeX 二者如果都安装了,那么只能有一者在 PATH 环境变量上。你可以检查一下 Sys.getenv('PATH')
。如果你只安装了 CTeX 而没装 TinyTeX 而跑不出参考文献来,那么这问题就诡异了,因为我无法重现,你只能自己排错(例如 debug(tinytex::: tweak_aux)
然后在交互式环境下跑 tinytex::latexmk()
),相关的扩展名自动处理在这一行:
https://github.com/yihui/tinytex/blob/ad2e0fa6b/R/latex.R#L161