yihui

code.tex 文件内容如下:

\documentclass{ctexart}
\usepackage{minted}

\title{R语言}
\author{某某}

\begin{document}
\maketitle
\section{数据描述}

\begin{minted}{c}
int main() {
	printf("hello, world");
	return 0;
}
\end{minted}

\begin{minted}{python}
def boring(args = None):
	pass
\end{minted}

\begin{minted}{r}
require(stats) # for lowess, rpois, rnorm
plot(cars)
lines(lowess(cars))
plot(sin, -pi, 2*pi) # see ?plot.function
## Discrete Distribution Plot:
plot(table(rpois(100, 5)), type = "h", col = "red", lwd = 10,
     main = "rpois(100, lambda = 5)")
## Simple quantiles/ECDF, see ecdf() {library(stats)} for a better one:
plot(x <- sort(rnorm(47)), type = "s", main = "plot(x, type = \"s\")")
points(x, cex = .5, col = "dark red")
\end{minted}

\mint{python}|import this|

\end{document}

使用 minted 包的tex文件,需要在编译的时候使用-shell-escape参数,如果使用 tinytex::xelatex,不知道如何传这个参数?如果不能传递,谢大大是否可以再添加 args 选项让用户自己传递类似上述 -shell-escape 参数?

system2('xelatex', args = '-shell-escape code') # 没问题,但是要运行几遍才有目录索引

tinytex::xelatex(file = 'code.tex') 

# I was unable to find any missing LaTeX packages from the error log code.log.
# ! Package minted Error: You must invoke LaTeX with the -shell-escape flag.
# 
# Error: Failed to compile code.tex. See code.log for more info.
# In addition: Warning message:
#   running command '"xelatex" -halt-on-error -interaction=batchmode "code.tex"' had status 1

    Cloud2016 安装 Github 上最新版的 tinytex 包 devtools::install_github('yihui/tinytex'),然后

    tinytex::xelatex('code.tex', engine_args = '-shell-escape')

    应该就可以了。如果懒得每次都敲这个,可以设置全局选项:

    options(tinytex.engine_args = '-shell-escape')

    然后 tinytex::xelatex('code.tex')

    另外我建议你少花点时间折腾 minted 包。据我观察,你正在一步一步重复蹚我年少时蹚过的浑水,LaTeX 真的很浪费时间,投入产出严重不成比例。这种语法高亮的问题还是用 R Markdown 算了,Pandoc 已经把事情都给办好了。如果你真的闲得慌,我可以给你找一堆更有意义的事情来做。

      yihui 你还说!要不是你鼓捣出来个 bookdown,我早就跟 LaTeX 决裂了!

        yihui 我在折腾学校的latex模版,还是先立足做好tex而不是R Markdown或者bookdown之类的模版,其实即使模版出来了,也没几个人会用,可见意义不大,只是自己有点强迫症,既然开始了就想做完做到自己满意。

        谢大大可以列一个有意义的事件表,闲得慌的时候可以看看,如果力所能及还可以动动手

          dapengde 没办法,你是包的开发者,所以你注定要下地狱啃这块硬骨头,目的是为了让你的用户不必再啃它。

          Cloud2016 如果你能把 R Markdown 套在学校的 LaTeX 模板上,那将会是一件非常有意义的事情,这事要是能办成,我愿意给你连续发一个星期的红包。单纯只是做出一个 LaTeX 模板并没有太大意义,因为那是把事情复杂化(疯狂自定义环境和命令);更有意义的事情是把事情简单化,让用户一个 LaTeX 命令都看不到,还能站在 LaTeX 肩膀上把论文给写了。打倒学术界的排版(包括学校论文的排版)是我的人生目标之一。做这件事就是在 R Markdown 的强约束条件下求最优解(只有有限可用的元素),也就要求你克制自定义 LaTeX 命令和环境;“要做什么”不难,“不做什么”才难。

          yihui 问题能重现,可是我不会修复,谢大大太瞧得起我啦

          只要不用R Notebook输出html就没关系,警告信息不随html/PDF文件走

          学校的模板比较奇葩,如参考文献格式还是国标2005版(现在是2015版),模板风格都是很多年前的,还有很多细节要调整 <https://github.com/XiangyunHuang/CUMTB-Master-Thesis>

          最近尝试了下 docker 发现 cboettig 大人已经在 rocker 里整合了 tinytex,一个完整的 verse 镜像 915.6MB,而没有 tex 支持的 tidyverse 镜像是 666MB ,解压后可能大些,但作为包含IDE的完整数据分析环境来分发做可重复性研究已经没什么问题了,甚至可以把 rticles 写的论文都包进去分发,后续看要不要也把 xaringan 包进去,这样就从分析到写作到演讲一条龙服务了。

          ps: 一个临时的小问题是 rmarkdown 的 CRAN 版本还没更新,直接用服务器版 RStudio 上的 knit 按钮编不出来,要么在 Dockerfile 里装 rmarkdown 的 github 版本,要么就是不用按钮,用 tinytex::pdflatex('asdf.tex') 直接去编译 tex 文件,或者就是等 CRAN 上的更新

            yufree 我计划下周把 rmarkdown 发 CRAN,到时候就可以正式昭告天下了:至少对 R 用户来说,LaTeX 问题至此基本全剧终。

            yihui 我试了下科大的镜像似乎 https 也可以,但有个小问题,帮助文件里 uninstall_tinytex(force = FALSE, dir = texlive_root())texlive_root() 函数没有导出,得用 tinytex:::texlive_root() 才能用

              yihui 我试了清华的镜像,也可以(速度飞快),下面是测试日志

              sessionInfo()
              R version 3.4.3 (2017-11-30)
              Platform: x86_64-pc-linux-gnu (64-bit)
              Running under: Debian GNU/Linux 9 (stretch)
              
              Matrix products: default
              BLAS: /usr/lib/openblas-base/libblas.so.3
              LAPACK: /usr/lib/libopenblasp-r0.2.19.so
              
              locale:
               [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8       
               [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=C             
               [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
              [10] LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
              
              attached base packages:
              [1] stats     graphics  grDevices utils     datasets  methods   base     
              
              loaded via a namespace (and not attached):
              [1] compiler_3.4.3 tools_3.4.3    yaml_2.1.16   
              > 
              > 
              > 
              > packageVersion('tinytex')
              [1] ‘0.2.13’
              > library(help=tinytex)
              > devtools::install_github('yihui/tinytex')
              Downloading GitHub repo yihui/tinytex@master
              from URL https://api.github.com/repos/yihui/tinytex/zipball/master
              Installing tinytex
              '/usr/local/lib/R/bin/R' --no-site-file --no-environ --no-save --no-restore --quiet CMD INSTALL  \
                '/tmp/RtmpY1WNSp/devtoolsa213ee4536/yihui-tinytex-3798627'  \
                --library='/usr/local/lib/R/site-library' --install-tests 
              
              * installing *source* package ‘tinytex’ ...
              ** R
              ** tests
              ** preparing package for lazy loading
              ** help
              *** installing help indices
              ** building package indices
              ** testing if installed package can be loaded
              * DONE (tinytex)
              > tinytex::install_tinytex(TRUE, repository = 'http://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet')
              trying URL 'https://github.com/yihui/tinytex/raw/master/tools/install-unx.sh'
              Content type 'text/plain; charset=utf-8' length 604 bytes
              ==================================================
              downloaded 604 bytes
              
              Downloading install-tl-unx.tar.gz to /tmp ...
              --2018-01-20 07:11:52--  http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz
              Resolving mirror.ctan.org (mirror.ctan.org)... 176.28.54.184, 2a01:488:67:1000:b01c:36b8:0:1
              Connecting to mirror.ctan.org (mirror.ctan.org)|176.28.54.184|:80... connected.
              HTTP request sent, awaiting response... 302 Found
              Location: http://mirror.lzu.edu.cn/CTAN/systems/texlive/tlnet/install-tl-unx.tar.gz [following]
              --2018-01-20 07:11:52--  http://mirror.lzu.edu.cn/CTAN/systems/texlive/tlnet/install-tl-unx.tar.gz
              Resolving mirror.lzu.edu.cn (mirror.lzu.edu.cn)... 202.201.0.160, 2001:da8:c000::160
              Connecting to mirror.lzu.edu.cn (mirror.lzu.edu.cn)|202.201.0.160|:80... connected.
              HTTP request sent, awaiting response... 200 OK
              Length: 4071742 (3.9M) [application/octet-stream]
              Saving to: ‘install-tl-unx.tar.gz’
              
                   0K .......... .......... .......... .......... ..........  1%  877K 4s
                  50K .......... .......... .......... .......... ..........  2% 1.33M 4s
                 100K .......... .......... .......... .......... ..........  3% 32.7M 2s
                 150K .......... .......... .......... .......... ..........  5%  145M 2s
                 200K .......... .......... .......... .......... ..........  6% 2.61M 2s
                 250K .......... .......... .......... .......... ..........  7% 21.4M 1s
                 300K .......... .......... .......... .......... ..........  8% 2.97M 1s
                 350K .......... .......... .......... .......... .......... 10% 3.35M 1s
                 400K .......... .......... .......... .......... .......... 11% 2.20M 1s
                 450K .......... .......... .......... .......... .......... 12% 1.11M 1s
                 500K .......... .......... .......... .......... .......... 13% 3.04M 1s
                 550K .......... .......... .......... .......... .......... 15% 3.57M 1s
                 600K .......... .......... .......... .......... .......... 16% 2.89M 1s
                 650K .......... .......... .......... .......... .......... 17% 3.25M 1s
                 700K .......... .......... .......... .......... .......... 18% 2.31M 1s
                 750K .......... .......... .......... .......... .......... 20%  932K 1s
                 800K .......... .......... .......... .......... .......... 21% 3.73M 1s
                 850K .......... .......... .......... .......... .......... 22% 3.32M 1s
                 900K .......... .......... .......... .......... .......... 23% 14.7M 1s
                 950K .......... .......... .......... .......... .......... 25% 2.22M 1s
                1000K .......... .......... .......... .......... .......... 26% 2.29M 1s
                1050K .......... .......... .......... .......... .......... 27%  521K 1s
                1100K .......... .......... .......... .......... .......... 28% 46.7M 1s
                1150K .......... .......... .......... .......... .......... 30% 9.53M 1s
                1200K .......... .......... .......... .......... .......... 31%  575M 1s
                1250K .......... .......... .......... .......... .......... 32% 2.12M 1s
                1300K .......... .......... .......... .......... .......... 33% 10.3M 1s
                1350K .......... .......... .......... .......... .......... 35% 2.52M 1s
                1400K .......... .......... .......... .......... .......... 36% 2.22M 1s
                1450K .......... .......... .......... .......... .......... 37% 2.31M 1s
                1500K .......... .......... .......... .......... .......... 38% 2.34M 1s
                1550K .......... .......... .......... .......... .......... 40% 2.33M 1s
                1600K .......... .......... .......... .......... .......... 41% 2.21M 1s
                1650K .......... .......... .......... .......... .......... 42% 2.19M 1s
                1700K .......... .......... .......... .......... .......... 44% 2.49M 1s
                1750K .......... .......... .......... .......... .......... 45% 2.02M 1s
                1800K .......... .......... .......... .......... .......... 46% 2.76M 1s
                1850K .......... .......... .......... .......... .......... 47% 2.22M 1s
                1900K .......... .......... .......... .......... .......... 49% 2.23M 1s
                1950K .......... .......... .......... .......... .......... 50% 2.45M 1s
                2000K .......... .......... .......... .......... .......... 51% 2.20M 1s
                2050K .......... .......... .......... .......... .......... 52% 2.31M 1s
                2100K .......... .......... .......... .......... .......... 54% 2.35M 1s
                2150K .......... .......... .......... .......... .......... 55% 2.23M 1s
                2200K .......... .......... .......... .......... .......... 56% 2.31M 1s
                2250K .......... .......... .......... .......... .......... 57% 2.32M 1s
                2300K .......... .......... .......... .......... .......... 59% 2.05M 1s
                2350K .......... .......... .......... .......... .......... 60% 2.57M 1s
                2400K .......... .......... .......... .......... .......... 61% 2.32M 1s
                2450K .......... .......... .......... .......... .......... 62%  632K 1s
                2500K .......... .......... .......... .......... .......... 64% 17.6M 1s
                2550K .......... .......... .......... .......... .......... 65%  699M 1s
                2600K .......... .......... .......... .......... .......... 66% 1.82M 1s
                2650K .......... .......... .......... .......... .......... 67% 12.2M 1s
                2700K .......... .......... .......... .......... .......... 69% 2.23M 1s
                2750K .......... .......... .......... .......... .......... 70% 3.37M 0s
                2800K .......... .......... .......... .......... .......... 71% 2.31M 0s
                2850K .......... .......... .......... .......... .......... 72% 2.26M 0s
                2900K .......... .......... .......... .......... .......... 74% 2.21M 0s
                2950K .......... .......... .......... .......... .......... 75% 2.43M 0s
                3000K .......... .......... .......... .......... .......... 76% 2.22M 0s
                3050K .......... .......... .......... .......... .......... 77% 2.32M 0s
                3100K .......... .......... .......... .......... .......... 79% 2.20M 0s
                3150K .......... .......... .......... .......... .......... 80% 2.33M 0s
                3200K .......... .......... .......... .......... .......... 81% 2.34M 0s
                3250K .......... .......... .......... .......... .......... 82% 2.33M 0s
                3300K .......... .......... .......... .......... .......... 84% 2.22M 0s
                3350K .......... .......... .......... .......... .......... 85% 2.18M 0s
                3400K .......... .......... .......... .......... .......... 86% 2.47M 0s
                3450K .......... .......... .......... .......... .......... 88% 2.22M 0s
                3500K .......... .......... .......... .......... .......... 89% 2.34M 0s
                3550K .......... .......... .......... .......... .......... 90% 2.31M 0s
                3600K .......... .......... .......... .......... .......... 91% 2.33M 0s
                3650K .......... .......... .......... .......... .......... 93% 2.31M 0s
                3700K .......... .......... .......... .......... .......... 94% 2.01M 0s
                3750K .......... .......... .......... .......... .......... 95% 2.42M 0s
                3800K .......... .......... .......... .......... .......... 96% 2.57M 0s
                3850K .......... .......... .......... .......... .......... 98% 2.20M 0s
                3900K .......... .......... .......... .......... .......... 99% 2.23M 0s
                3950K .......... .......... ......                          100% 2.50M=1.7s
              
              2018-01-20 07:11:54 (2.32 MB/s) - ‘install-tl-unx.tar.gz’ saved [4071742/4071742]
              
              --2018-01-20 07:11:54--  https://github.com/yihui/tinytex/raw/master/tools/texlive.profile
              Resolving github.com (github.com)... 192.30.255.112, 192.30.255.113
              Connecting to github.com (github.com)|192.30.255.112|:443... connected.
              HTTP request sent, awaiting response... 302 Found
              Location: https://raw.githubusercontent.com/yihui/tinytex/master/tools/texlive.profile [following]
              --2018-01-20 07:11:55--  https://raw.githubusercontent.com/yihui/tinytex/master/tools/texlive.profile
              Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.228.133
              Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.228.133|:443... connected.
              HTTP request sent, awaiting response... 200 OK
              Length: 295 [text/plain]
              Saving to: ‘texlive.profile’
              
                   0K                                                       100% 12.3M=0s
              
              2018-01-20 07:11:56 (12.3 MB/s) - ‘texlive.profile’ saved [295/295]
              
              Automated TeX Live installation using profile: ../texlive.profile
              Loading http://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet/tlpkg/texlive.tlpdb
              Installing TeX Live 2017 from: http://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet (not verified)
              Platform: x86_64-linux => 'GNU/Linux on x86_64'
              Distribution: net  (downloading)
              Using URL: http://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet
              Directory for temporary files: /tmp/yKwnP57M0C
              Installing to: ./
              Installing [1/7, time/total: ??:??/??:??]: hyphen-base [22k]
              Installing [2/7, time/total: 00:00/00:00]: kpathsea [31k]
              Installing [3/7, time/total: 00:00/00:00]: kpathsea.x86_64-linux [46k]
              Installing [4/7, time/total: 00:00/00:00]: tetex [70k]
              Installing [5/7, time/total: 00:00/00:00]: tetex.x86_64-linux [1k]
              Installing [6/7, time/total: 00:00/00:00]: texlive.infra [203k]
              Installing [7/7, time/total: 00:00/00:00]: texlive.infra.x86_64-linux [90k]
              Time used for installing the packages: 00:00
              running mktexlsr ./texmf-dist ...
              writing fmtutil.cnf to ./texmf-dist/web2c/fmtutil.cnf
              writing updmap.cfg to ./texmf-dist/web2c/updmap.cfg
              writing language.dat to ./texmf-var/tex/generic/config/language.dat
              writing language.def to ./texmf-var/tex/generic/config/language.def
              writing language.dat.lua to ./texmf-var/tex/generic/config/language.dat.lua
              running mktexlsr ./texmf-var ./texmf-config ./texmf-dist ...
              running updmap-sys --nohash ...done
              re-running mktexlsr ./texmf-var ./texmf-config ...
              pre-generating all format files, be patient...
              running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --no-strict --all ...done
              running package-specific postactions
              finished with package-specific postactions
              
              Logfile: ./install-tl.log
              tlmgr: setting default package repository to http://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet
              tlmgr: package repository http://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet (not verified: gpg unavailable)
              tlmgr: no updates available
              tlmgr: package repository http://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet (not verified: gpg unavailable)
              [1/19, ??:??/??:??] install: babel [134k]
              [2/19, 00:01/01:29] install: cm [233k]
              [3/19, 00:01/00:32] install: etex [12k]
              [4/19, 00:01/00:31] install: knuth-lib [30k]
              [5/19, 00:01/00:29] install: latex [161k]
              [6/19, 00:01/00:21] install: latex-bin.x86_64-linux [1k]
              [7/19, 00:01/00:21] install: latex-bin [1k]
              [8/19, 00:01/00:21] install: latex-fonts [18k]
              [9/19, 00:01/00:20] install: latexconfig [5k]
              [10/19, 00:01/00:20] install: luatex.x86_64-linux [3442k]
              [11/19, 00:03/00:08] install: luatex [13k]
              [12/19, 00:03/00:08] install: pdftex.x86_64-linux [763k]
              [13/19, 00:04/00:09] install: pdftex [36k]
              [14/19, 00:04/00:09] install: plain [60k]
              [15/19, 00:04/00:09] install: tex-ini-files [4k]
              [16/19, 00:04/00:09] install: unicode-data [220k]
              [17/19, 00:04/00:09] install: xetex.x86_64-linux [6880k]
              [18/19, 00:07/00:07] install: xetex [7k]
              [19/19, 00:07/00:07] install: xetexconfig [1k]
              running mktexlsr ...
              done running mktexlsr.
              running updmap-sys ...
              done running updmap-sys.
              regenerating fmtutil.cnf in /tmp/texlive/texmf-dist
              running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --no-error-if-no-format --byengine xetex ...
              done running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --no-error-if-no-format --byengine xetex.
              running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --no-error-if-no-format --byengine luatex ...
              done running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --no-error-if-no-format --byengine luatex.
              running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --no-error-if-no-format --byengine luajittex ...
              done running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --no-error-if-no-format --byengine luajittex.
              running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --no-error-if-no-format --byengine pdftex ...
              done running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --no-error-if-no-format --byengine pdftex.
              tlmgr: package log updated: /tmp/texlive/texmf-var/web2c/tlmgr.log
              tlmgr: package repository http://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet (not verified: gpg unavailable)
              [1/49, ??:??/??:??] install: amscls [32k]
              [2/49, 00:00/00:00] install: amsfonts [3542k]
              [3/49, 00:02/00:11] install: amsmath [30k]
              [4/49, 00:02/00:11] install: bibtex.x86_64-linux [70k]
              [5/49, 00:02/00:10] install: bibtex [15k]
              [6/49, 00:02/00:10] install: booktabs [3k]
              [7/49, 00:02/00:10] install: caption [32k]
              [8/49, 00:02/00:10] install: dvipdfmx.x86_64-linux [2k]
              [9/49, 00:02/00:10] install: dvipdfmx [27k]
              [10/49, 00:02/00:10] install: ec [258k]
              [11/49, 00:03/00:15] install: etoolbox [8k]
              [12/49, 00:03/00:15] install: euenc [4k]
              [13/49, 00:03/00:15] install: fancyvrb [12k]
              [14/49, 00:03/00:15] install: fontspec [26k]
              [15/49, 00:03/00:14] install: framed [8k]
              [16/49, 00:03/00:14] install: geometry [9k]
              [17/49, 00:03/00:14] install: glyphlist [25k]
              [18/49, 00:03/00:14] install: graphics [15k]
              [19/49, 00:03/00:14] install: graphics-cfg [2k]
              [20/49, 00:03/00:14] install: graphics-def [10k]
              [21/49, 00:03/00:14] install: gsftopk.x86_64-linux [40k]
              [22/49, 00:03/00:14] install: gsftopk [4k]
              [23/49, 00:03/00:14] install: hyperref [106k]
              [24/49, 00:03/00:14] install: ifluatex [3k]
              [25/49, 00:03/00:14] install: iftex [2k]
              [26/49, 00:03/00:14] install: ifxetex [2k]
              [27/49, 00:03/00:14] install: l3kernel [125k]
              [28/49, 00:03/00:13] install: l3packages [19k]
              [29/49, 00:03/00:13] install: lm [11651k]
              [30/49, 00:10/00:12] install: lualibs [72k]
              [31/49, 00:12/00:14] install: luaotfload.x86_64-linux [1k]
              [32/49, 00:12/00:14] install: luaotfload [432k]
              [33/49, 00:12/00:14] install: makeindex.x86_64-linux [47k]
              [34/49, 00:12/00:14] install: makeindex [5k]
              [35/49, 00:12/00:14] install: mathspec [10k]
              [36/49, 00:12/00:14] install: metafont.x86_64-linux [186k]
              [37/49, 00:12/00:14] install: metafont [33k]
              [38/49, 00:12/00:14] install: mfware.x86_64-linux [118k]
              [39/49, 00:12/00:14] install: mfware [4k]
              [40/49, 00:12/00:14] install: natbib [17k]
              [41/49, 00:12/00:14] install: oberdiek [221k]
              [42/49, 00:12/00:14] install: tipa [2809k]
              [43/49, 00:14/00:14] install: titling [3k]
              [44/49, 00:14/00:14] install: tools [39k]
              [45/49, 00:14/00:14] install: upquote [2k]
              [46/49, 00:14/00:14] install: url [6k]
              [47/49, 00:14/00:14] install: xkeyval [13k]
              [48/49, 00:14/00:14] install: xunicode [26k]
              [49/49, 00:14/00:14] install: zapfding [46k]
              running mktexlsr ...
              done running mktexlsr.
              running updmap-sys ...
              done running updmap-sys.
              regenerating fmtutil.cnf in /home/xiangyun/.TinyTeX/texmf-dist
              running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --byfmt mf ...
              done running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --byfmt mf.
              tlmgr: package log updated: /home/xiangyun/.TinyTeX/texmf-var/web2c/tlmgr.log
              TinyTeX installed to /home/xiangyun/.TinyTeX
              Warning message:
              In normalizePath("~/bin") :
                path[1]="/home/xiangyun/bin": No such file or directory
              > packageVersion('tinytex')
              [1] ‘0.2.15’

              只是在最后的时候有个警告,不知为什么?事实上,目录 /home/xiangyun/bin 是存在的

                Cloud2016 谢谢!直接在 R 里面运行 normalizePath("~/bin") 也会出警告吗?path.expand("~/bin") 是否成功?(我估计也不行)

                环境变量 Sys.getenv('HOME') 呢?

                  yihui 都能运行正常,但是终端里 tex -v 没有反应,应该是路径没加上,测试环境是拉取 rocker/tidyverse 镜像,里面不包含TeX套件

                  > tinytex::install_tinytex(TRUE, repository = 'http://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet')
                  trying URL 'https://github.com/yihui/tinytex/raw/master/tools/install-unx.sh'
                  Content type 'text/plain; charset=utf-8' length 604 bytes
                  ==================================================
                  downloaded 604 bytes
                  
                  Downloading install-tl-unx.tar.gz to /tmp ...
                  Automated TeX Live installation using profile: ../texlive.profile
                  Loading http://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet/tlpkg/texlive.tlpdb
                  Installing TeX Live 2017 from: http://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet (not verified)
                  Platform: x86_64-linux => 'GNU/Linux on x86_64'
                  Distribution: net  (downloading)
                  Using URL: http://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet
                  Directory for temporary files: /tmp/GQudatKm4j
                  Installing to: ./
                  Installing [1/7, time/total: ??:??/??:??]: hyphen-base [22k]
                  Installing [2/7, time/total: 00:00/00:00]: kpathsea [31k]
                  Installing [3/7, time/total: 00:00/00:00]: kpathsea.x86_64-linux [46k]
                  Installing [4/7, time/total: 00:00/00:00]: tetex [70k]
                  Installing [5/7, time/total: 00:00/00:00]: tetex.x86_64-linux [1k]
                  Installing [6/7, time/total: 00:00/00:00]: texlive.infra [203k]
                  Installing [7/7, time/total: 00:00/00:00]: texlive.infra.x86_64-linux [90k]
                  Time used for installing the packages: 00:01
                  running mktexlsr ./texmf-dist ...
                  writing fmtutil.cnf to ./texmf-dist/web2c/fmtutil.cnf
                  writing updmap.cfg to ./texmf-dist/web2c/updmap.cfg
                  writing language.dat to ./texmf-var/tex/generic/config/language.dat
                  writing language.def to ./texmf-var/tex/generic/config/language.def
                  writing language.dat.lua to ./texmf-var/tex/generic/config/language.dat.lua
                  running mktexlsr ./texmf-var ./texmf-config ./texmf-dist ...
                  running updmap-sys --nohash ...done
                  re-running mktexlsr ./texmf-var ./texmf-config ...
                  pre-generating all format files, be patient...
                  running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --no-strict --all ...done
                  running package-specific postactions
                  finished with package-specific postactions
                  
                  Logfile: ./install-tl.log
                  tlmgr: setting default package repository to http://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet
                  tlmgr: package repository http://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet (not verified: gpg unavailable)
                  tlmgr: no updates available
                  tlmgr: package repository http://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet (not verified: gpg unavailable)
                  [1/19, ??:??/??:??] install: babel [134k]
                  [2/19, 00:00/00:00] install: cm [233k]
                  [3/19, 00:00/00:00] install: etex [12k]
                  [4/19, 00:00/00:00] install: knuth-lib [30k]
                  [5/19, 00:00/00:00] install: latex [161k]
                  [6/19, 00:00/00:00] install: latex-bin.x86_64-linux [1k]
                  [7/19, 00:00/00:00] install: latex-bin [1k]
                  [8/19, 00:00/00:00] install: latex-fonts [18k]
                  [9/19, 00:00/00:00] install: latexconfig [5k]
                  [10/19, 00:00/00:00] install: luatex.x86_64-linux [3442k]
                  [11/19, 00:02/00:05] install: luatex [13k]
                  [12/19, 00:02/00:05] install: pdftex.x86_64-linux [763k]
                  [13/19, 00:02/00:04] install: pdftex [36k]
                  [14/19, 00:02/00:04] install: plain [60k]
                  [15/19, 00:02/00:04] install: tex-ini-files [4k]
                  [16/19, 00:02/00:04] install: unicode-data [220k]
                  [17/19, 00:02/00:04] install: xetex.x86_64-linux [6880k]
                  [18/19, 00:06/00:06] install: xetex [7k]
                  [19/19, 00:06/00:06] install: xetexconfig [1k]
                  running mktexlsr ...
                  done running mktexlsr.
                  running updmap-sys ...
                  done running updmap-sys.
                  regenerating fmtutil.cnf in /tmp/texlive/texmf-dist
                  running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --no-error-if-no-format --byengine pdftex ...
                  done running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --no-error-if-no-format --byengine pdftex.
                  running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --no-error-if-no-format --byengine luatex ...
                  done running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --no-error-if-no-format --byengine luatex.
                  running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --no-error-if-no-format --byengine luajittex ...
                  done running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --no-error-if-no-format --byengine luajittex.
                  running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --no-error-if-no-format --byengine xetex ...
                  done running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --no-error-if-no-format --byengine xetex.
                  tlmgr: package log updated: /tmp/texlive/texmf-var/web2c/tlmgr.log
                  tlmgr: package repository http://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet (not verified: gpg unavailable)
                  [1/49, ??:??/??:??] install: amscls [32k]
                  [2/49, 00:00/00:00] install: amsfonts [3542k]
                  [3/49, 00:02/00:11] install: amsmath [30k]
                  [4/49, 00:02/00:11] install: bibtex.x86_64-linux [70k]
                  [5/49, 00:02/00:10] install: bibtex [15k]
                  [6/49, 00:02/00:10] install: booktabs [3k]
                  [7/49, 00:02/00:10] install: caption [32k]
                  [8/49, 00:02/00:10] install: dvipdfmx.x86_64-linux [2k]
                  [9/49, 00:02/00:10] install: dvipdfmx [27k]
                  [10/49, 00:02/00:10] install: ec [258k]
                  [11/49, 00:02/00:10] install: etoolbox [8k]
                  [12/49, 00:02/00:10] install: euenc [4k]
                  [13/49, 00:02/00:10] install: fancyvrb [12k]
                  [14/49, 00:02/00:10] install: fontspec [26k]
                  [15/49, 00:02/00:09] install: framed [8k]
                  [16/49, 00:02/00:09] install: geometry [9k]
                  [17/49, 00:02/00:09] install: glyphlist [25k]
                  [18/49, 00:02/00:09] install: graphics [15k]
                  [19/49, 00:02/00:09] install: graphics-cfg [2k]
                  [20/49, 00:02/00:09] install: graphics-def [10k]
                  [21/49, 00:02/00:09] install: gsftopk.x86_64-linux [40k]
                  [22/49, 00:02/00:09] install: gsftopk [4k]
                  [23/49, 00:02/00:09] install: hyperref [106k]
                  [24/49, 00:02/00:09] install: ifluatex [3k]
                  [25/49, 00:02/00:09] install: iftex [2k]
                  [26/49, 00:02/00:09] install: ifxetex [2k]
                  [27/49, 00:03/00:14] install: l3kernel [125k]
                  [28/49, 00:03/00:13] install: l3packages [19k]
                  [29/49, 00:03/00:13] install: lm [11651k]
                  [30/49, 00:08/00:10] install: lualibs [72k]
                  [31/49, 00:08/00:09] install: luaotfload.x86_64-linux [1k]
                  [32/49, 00:08/00:09] install: luaotfload [432k]
                  [33/49, 00:09/00:10] install: makeindex.x86_64-linux [47k]
                  [34/49, 00:09/00:10] install: makeindex [5k]
                  [35/49, 00:09/00:10] install: mathspec [10k]
                  [36/49, 00:09/00:10] install: metafont.x86_64-linux [186k]
                  [37/49, 00:09/00:10] install: metafont [33k]
                  [38/49, 00:09/00:10] install: mfware.x86_64-linux [118k]
                  [39/49, 00:09/00:10] install: mfware [4k]
                  [40/49, 00:09/00:10] install: natbib [17k]
                  [41/49, 00:09/00:10] install: oberdiek [221k]
                  [42/49, 00:09/00:10] install: tipa [2809k]
                  [43/49, 00:10/00:10] install: titling [3k]
                  [44/49, 00:11/00:11] install: tools [39k]
                  [45/49, 00:11/00:11] install: upquote [2k]
                  [46/49, 00:11/00:11] install: url [6k]
                  [47/49, 00:11/00:11] install: xkeyval [13k]
                  [48/49, 00:11/00:11] install: xunicode [26k]
                  [49/49, 00:11/00:11] install: zapfding [46k]
                  running mktexlsr ...
                  done running mktexlsr.
                  running updmap-sys ...
                  done running updmap-sys.
                  regenerating fmtutil.cnf in /home/xiangyun/.TinyTeX/texmf-dist
                  running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --byfmt mf ...
                  done running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --byfmt mf.
                  tlmgr: package log updated: /home/xiangyun/.TinyTeX/texmf-var/web2c/tlmgr.log
                  TinyTeX installed to /home/xiangyun/.TinyTeX
                  Warning message:
                  In normalizePath("~/bin") :
                    path[1]="/home/xiangyun/bin": No such file or directory
                  > normalizePath("~/bin")
                  [1] "/home/xiangyun/bin"
                  > path.expand("~/bin")
                  [1] "/home/xiangyun/bin"
                  > Sys.getenv('HOME')
                  [1] "/home/xiangyun"

                  此外,还在 rocker/geospatial 测试,这个docker镜像自带 tinytex,当前目录下本身不带 bin 目录的,发现如下情况,此时感觉警告信息是多余的

                  tinytex::tlmgr(
                  +     c('option', 'repository', 'https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet')
                  + )
                  tlmgr option repository https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet
                  tlmgr: setting default package repository to https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet
                  Warning message:
                  In normalizePath("~/bin") :
                    path[1]="/home/xiangyun/bin": No such file or directory
                  > tinytex::tlmgr_install('fandol')
                  tlmgr install fandol
                  tlmgr: package repository https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet (not verified: gpg unavailable)
                  [1/1, ??:??/??:??] install: fandol [21077k]
                  running mktexlsr ...
                  done running mktexlsr.
                  tlmgr: package log updated: /opt/TinyTeX/texmf-var/web2c/tlmgr.log
                  tlmgr path add
                  Warning messages:
                  1: In normalizePath("~/bin") :
                    path[1]="/home/xiangyun/bin": No such file or directory
                  2: In normalizePath("~/bin") :
                    path[1]="/home/xiangyun/bin": No such file or directory

                    Cloud2016 谢谢,这个警告问题应该在最新版中修正了:devtools::install_github('yihui/tinytex')

                    yufree 这个 texlive_root() 是参数默认取值,不需要导出,你真正使用的时候用 uninstall_tinytex() 就可以了,不用把参数写全。

                      yihui 谢谢!明白了,我当时直接复制了帮助文件中的命令运行提示找不到函数,参数留空反而可以了

                      2 个月 后

                      @yihui 请问能否在lyx中使用TinyTex?没有搜到相关的文档。我从R中直接安装的,也不知道怎么和lyx连接起来,求助。

                        bayeswhu 可以,不用特别的连接,装了就可以用(不管用什么方式装)。

                        貌似看见一个眼熟的 ID,话说你这有几年没来了啊。

                        @yihui 谢谢答复,我再试试。难得你还记得我啊,呵呵。
                        是的,前几年因为主要在用R和lyx写些东西,所以来的比较频繁,之后一段时间,转而用jupyter notebook写python去了,所以这边来得少一些。不过一直在关注你,blog也一直在看,看你有好东西,这不是马上就来了么~~~?

                        大神啊,我试了下中文文档,出现如下错误:
                        output file: test.knit.md

                        "D:/software/Rstudio/bin/pandoc/pandoc" +RTS -K512m -RTS test.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output test.tex --template "D:\software\R\library\rmarkdown\rmd\latex\default-1.17.0.2.tex" --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable "geometry:margin=1in"
                        ! Package inputenc Error: Unicode char 绗?(U+7B2C)
                        (inputenc) not set up for use with LaTeX.

                        错误: Failed to compile test.tex. See test.log for more info.
                        此外: Warning messages:
                        1: 运行命令'"pdflatex" -halt-on-error -interaction=batchmode "test.tex"'的状态是1
                        2: In grepl("==> Fatal error occurred", x, fixed = TRUE) :
                        输入的字符串1不适用于此语言环境
                        停止执行

                        这是什么鬼啊