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不适用于此语言环境
                停止执行

                这是什么鬼啊

                  19 天 后

                  yihui 我发现 tinytex::tlmgr_update 不能升级 TinyTeX,考虑写个函数 tlmgr_upgrade 怎么样?

                  我查看了 TeXLive 的官方升级指南 <https://tug.org/texlive/upgrade.html> 强推大家卸载重装,不喜欢!不喜欢!

                  1. 手动下载 update-tlmgr-latest.sh(exe)
                  2. 升级
                  sudo sh update-tlmgr-latest.sh  -- --upgrade
                  tlmgr option repository yourrepo (这个可以省,之前安装过 TinyTeX,如果设置过)
                  tlmgr update --self --all

                  在 Windows 命令行窗口操作,

                  update-tlmgr-latest.exe  -- --upgrade 
                  tlmgr option repository yourrepo (这个可以省,之前安装过 TinyTeX,如果设置过)
                  tlmgr update --self --all

                  注意 windows 下 执行第一行有个弹窗,点击安装就好

                  然后就升级完成了。

                  附升级日志

                  sudo sh update-tlmgr-latest.sh -- --upgrade
                  Verifying archive integrity... All good.
                  Uncompressing TeX Live Manager Updater  100%
                  ./runme.sh: updating in /opt/TinyTeX...
                  ./runme.sh: tlmgr version says this is TeX Live 2018
                  ./runme.sh: have TL 2018, new version also 2018;
                  ./runme.sh: using --upgrade doesn't make sense; terminating.
                  tlmgr update --self --all
                  tlmgr: package repository https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet (verified)
                  [1/1, ??:??/??:??] update: texlive.infra [204k] (46470 -> 47457) ... done
                  Restarting tlmgr to complete update ...
                  tlmgr: package repository https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet (verified)
                  [ 1/35, ??:??/??:??] update: amsmath [30k] (45246 -> 47349) ... done
                  [ 2/35, 00:00/00:00] update: bibtex.x86_64-linux [72k] (43804 -> 47063) ... done
                  [ 3/35, 00:00/00:00] update: bibtex [15k] (44166 -> 47198) ... done
                  [ 4/35, 00:00/00:00] update: dvipdfmx [27k] (44224 -> 47198) ... done
                  [ 5/35, 00:01/02:06] update: geometry [9k] (19716 -> 47106) ... done
                  [ 6/35, 00:01/01:59] update: graphics [15k] (44703 -> 47350) ... done
                  [ 7/35, 00:01/01:48] update: gsftopk.x86_64-linux [40k] (43804 -> 47063) ... done
                  [ 8/35, 00:01/01:27] update: gsftopk [4k] (44166 -> 47198) ... done
                  [ 9/35, 00:01/01:26] update: hyphen-base [22k] (45751 -> 47260) ... done
                  [10/35, 00:01/01:17] update: ifluatex [3k] (46447 -> 47293) ... done
                  [11/35, 00:01/01:17] update: kpathsea.x86_64-linux [47k] (43804 -> 47063) ... done
                  [12/35, 00:01/01:04] update: kpathsea [31k] (46655 -> 47198) ... done
                  [13/35, 00:02/01:55] update: l3kernel [125k] (46720 -> 46875) ... done
                  [14/35, 00:02/01:22] update: latex [163k] (43813 -> 47377) ... done
                  [15/35, 00:02/00:59] update: latex-bin [1k] (45751 -> 47198) ... done
                  [16/35, 00:02/00:59] update: luaotfload [432k] (43194 -> 47444) ... done
                  [17/35, 00:03/00:52] update: luatex.x86_64-linux [7301k] (44582 -> 47245) ... done
                  [18/35, 00:07/00:14] update: luatex [13k] (46508 -> 47235) ... done
                  [19/35, 00:07/00:14] update: makeindex.x86_64-linux [49k] (43804 -> 47063) ... done
                  [20/35, 00:08/00:17] update: makeindex [5k] (44166 -> 47198) ... done
                  [21/35, 00:08/00:16] update: metafont.x86_64-linux [189k] (44013 -> 47063) ... done
                  [22/35, 00:08/00:16] update: metafont [33k] (45678 -> 47198) ... done
                  [23/35, 00:08/00:16] update: mfware.x86_64-linux [120k] (43804 -> 47063) ... done
                  [24/35, 00:08/00:16] update: mfware [4k] (44166 -> 47198) ... done
                  [25/35, 00:08/00:16] update: oberdiek [222k] (46447 -> 47293) ... done
                  [26/35, 00:09/00:17] update: pdftex.x86_64-linux [795k] (44065 -> 47140) ... done
                  [27/35, 00:09/00:16] update: pdftex [36k] (44166 -> 47199) ... done
                  [28/35, 00:09/00:16] update: tetex [70k] (46595 -> 47198) ... done
                  [29/35, 00:09/00:16] update: tex.x86_64-linux [172k] (44013 -> 47063) ... done
                  [30/35, 00:10/00:17] update: tex [1k] (44166 -> 47198) ... done
                  [31/35, 00:10/00:17] update: tools [39k] (43813 -> 47377) ... done
                  [32/35, 00:10/00:17] update: ttfutils.x86_64-linux [410k] (43804 -> 47063) ... done
                  [33/35, 00:10/00:17] update: ttfutils [106k] (45845 -> 47198) ... done
                  [34/35, 00:10/00:16] update: xecjk [126k] (46756 -> 47362) ... done
                  [35/35, 00:11/00:18] update: xetex.x86_64-linux [7123k] (44328 -> 47245) ... done
                  running mktexlsr ...
                  done running mktexlsr.
                  running updmap-sys ...
                  done running updmap-sys.
                  regenerating fmtutil.cnf in /opt/TinyTeX/texmf-dist
                  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 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 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.
                  running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --no-error-if-no-format --byengine tex ...
                  done running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --no-error-if-no-format --byengine tex.
                  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: /opt/TinyTeX/texmf-var/web2c/tlmgr.log

                  测试环境
                  Windows 8.1
                  R 3.5.0

                  sessionInfo()
                  R version 3.5.0 (2018-04-23)
                  Platform: x86_64-w64-mingw32/x64 (64-bit)
                  Running under: Windows 8.1 x64 (build 9600)
                  
                  Matrix products: default
                  
                  locale:
                  [1] LC_COLLATE=Chinese (Simplified)_China.936 
                  [2] LC_CTYPE=Chinese (Simplified)_China.936   
                  [3] LC_MONETARY=Chinese (Simplified)_China.936
                  [4] LC_NUMERIC=C                              
                  [5] LC_TIME=Chinese (Simplified)_China.936    
                  
                  attached base packages:
                  [1] stats     graphics  grDevices utils     datasets  methods   base     
                  
                  loaded via a namespace (and not attached):
                  [1] compiler_3.5.0 tools_3.5.0    tinytex_0.5  

                  Linux 即带 TinyTeX 的 rocker 镜像

                  sessionInfo()
                  R version 3.4.4 (2018-03-15)
                  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.4 tools_3.4.4    yaml_2.1.18   

                  吊诡的是 tlmgr update --self --all 竟然不能升级,虽然能更新包管理器和 TeX 包,目前的方案是,如果 执行tlmgr_upgrade 就根据系统类型下载 update-tlmgr-latest.sh (update-tlmgr-latest.exe),并执行

                    Cloud2016 算了,我看官方的描述如此复杂以及强烈不推荐升级,那还是按官方说的删了重装新的好了,反正就是几分钟的事儿。

                    tinytex::uninstall_tinytex()
                    tinytex::install_tinytex()

                    另外,官方文档中已经没有 update-tlmgr-latest.exe 了。

                      yihui <https://tug.org/texlive/upgrade.html> 这里的指南是给 TeX Live 2017 to 2018,所以搞得那么复杂,我是意识到 TinyTeX 不像 TeXLive 有版本号(比如 2017,2018等年份),升级过程其实是简化成两行了(如果用管道就是一行)

                      wget http://mirrors.rit.edu/CTAN/systems/texlive/tlnet/update-tlmgr-latest.sh
                      sudo sh update-tlmgr-latest.sh  -- --upgrade

                      其中 <http://mirrors.rit.edu/CTAN/> 可以拿离自己最近的镜像站代替如 <https://mirrors.tuna.tsinghua.edu.cn/CTAN/>

                      类似地,Windows 下

                      wget http://mirrors.rit.edu/CTAN/systems/texlive/tlnet/update-tlmgr-latest.exe
                      update-tlmgr-latest.exe  -- --upgrade 

                      exe 文件是有的,打开 <http://mirrors.rit.edu/CTAN/systems/texlive/tlnet/> 可以看到

                      最后,卸载重装的办法,主要是我嫌麻烦,之前装过的又得再装一遍,另一方面不全记得装过哪些包。幸好 rmarkdown 具有自动安装缺失包的特点,基本解决了重装带来的后遗症。