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 具有自动安装缺失包的特点,基本解决了重装带来的后遗症。

        Cloud2016 官方升级文档中没有提 Windows 下的 exe 程序,既然他们没提,我觉得还是不要用的好,尽管你能从他们的老坟里把这个文件刨出来。

        现有的 LaTeX 包可以用 tinytex::tl_pkgs() 提取;我刚提交了一个新的函数让你能自动重装当前装好的包。

        devtools::install_github('yihui/tinytex')
        tinytex::reinstall_tinytex()
          4 个月 后

          搬了新家,有了新电脑,发现装不上 TinyTeX ? 求助。

          故障简述(完整详细信息附后)

          1. tinytex::install_tinytex(),主要的故障信息是:
             'query_ctan_mirror: Programs not set up, trying wget
              cannot contact mirror.ctan.org, returning a backbone server!
          2. 怀疑是网络问题,于是安装 prebuilt 版,tinytex:::install_prebuilt(),成功。
          3. 但是,在用bookdown 编译一份中文文档时,需要用到 ctexbook.cls,貌似 tlmgr search 查找这个文件时失败。很多 .exe 文件无法正常工作。编译失败。
          ! LaTeX Error: File `ctexbook.cls' not found.
          1. 无奈下,去 texlive 官网 下载 texlive 的安装包,但是安装居然失败:运行 'install-tl-windows.bat',死在了 perl.exe这一步:'perl.exe has stopped working'。安装失败。
          2. 于是重新操起旧工具:下载安装 CTeX。倒是安装成功了,但是编译中文文档仍然出错。我想起旧电脑是对所有宏包升了级的,于是去 MiKTeX 的升级管理器里升级,但是怪事发生了:每升级几个包,就会中断退出,错误信息是 'unsupported protocal'。
          3. 最后,我去 MiKTeX 官网下载了最新的 MiKTeX 并安装,然后安装了 xetex 相关的几个包,才算是解决了问题。

          综上,TinyTeX、TeXLive、CTeX 三者的安装目前我都遇见了故障。注意力有点分散。虽然最后能用了,但是还是希望集中解决 TinyTeX 自身的安装问题,以及 TinyTeX 对缺失宏包的安装问题。哪位能帮忙看看?多谢啦!

          完整详细信息

          > devtools::session_info()
          Session info --------------------------------------------------------------------------------------------------------
           setting  value                                              
           version  R version 3.5.1 (2018-07-02)                       
           system   x86_64, mingw32                                    
           ui       RStudio (1.1.456)                                  
           language (EN)                                               
           collate  Chinese (Simplified)_People's Republic of China.936
           tz       Europe/Berlin                                      
           date     2018-09-10                                         
          
          Packages ------------------------------------------------------------------------------------------------------------
           package   * version date       source                        
           backports   1.1.2   2017-12-13 CRAN (R 3.5.0)                
           base      * 3.5.1   2018-07-02 local                         
           compiler    3.5.1   2018-07-02 local                         
           datasets  * 3.5.1   2018-07-02 local                         
           devtools    1.13.6  2018-06-27 CRAN (R 3.5.1)                
           digest      0.6.16  2018-08-22 CRAN (R 3.5.1)                
           evaluate    0.11    2018-07-17 CRAN (R 3.5.1)                
           graphics  * 3.5.1   2018-07-02 local                         
           grDevices * 3.5.1   2018-07-02 local                         
           htmltools   0.3.6   2017-04-28 CRAN (R 3.5.1)                
           knitr       1.20    2018-02-20 CRAN (R 3.5.1)                
           magrittr    1.5     2014-11-22 CRAN (R 3.5.1)                
           memoise     1.1.0   2017-04-21 CRAN (R 3.5.1)                
           methods   * 3.5.1   2018-07-02 local                         
           Rcpp        0.12.18 2018-07-23 CRAN (R 3.5.1)                
           rmarkdown   1.10    2018-06-11 CRAN (R 3.5.1)                
           rprojroot   1.3-2   2018-01-03 CRAN (R 3.5.1)                
           stats     * 3.5.1   2018-07-02 local                         
           stringi     1.1.7   2018-03-12 CRAN (R 3.5.0)                
           stringr     1.3.1   2018-05-10 CRAN (R 3.5.1)                
           tinytex     0.8.1   2018-09-09 Github (yihui/tinytex@e5c65c5)
           tools       3.5.1   2018-07-02 local                         
           utils     * 3.5.1   2018-07-02 local                         
           withr       2.1.2   2018-03-15 CRAN (R 3.5.1)                
           xfun        0.3     2018-07-06 CRAN (R 3.5.1)                
           yaml        2.2.0   2018-07-25 CRAN (R 3.5.1)      

          > tinytex::install_tinytex()
          trying URL 'http://mirror.ctan.org/systems/texlive/tlnet/install-tl.zip'
          Content length 355 bytes
          trying URL 'https://github.com/yihui/tinytex/raw/master/tools/pkgs-custom.txt'
          Content length 142 bytes
          downloaded 275 bytes
          
          trying URL 'https://github.com/yihui/tinytex/raw/master/tools/texlive.profile'
          Content length 142 bytes
          downloaded 295 bytes
          
          Starting to install TinyTeX to C:\Users\PengZhao\AppData\Roaming/TinyTeX. It will take a few minutes.
          PATH=C:\Users\PengZhao\AppData\Local\Temp\RtmpeYk32F\install-tl-20180909\tlpkg\tlperl\bin;d:\Program Files\R\bin\x64;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\System32\WindowsPowerShell\v1.0\;c:\Users\PengZhao\AppData\Local\GitHubDesktop\app-1.3.4\resources\app\git\cmd\;D:\Program Files\python364\Scripts\;D:\Program Files\python364\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Users\PengZhao\AppData\Local\GitHubDesktop\bin;D:\Program Files\CTEX\UserData\miktex/bin\;C:\Users\PengZhao\AppData\Roaming\TinyTeX\bin\win32;d:\Program Files\wget;C:\Windows\System32\WindowsPowerShell\v1.0\
          "C:\Users\PengZhao\AppData\Local\Temp\RtmpeYk32F\install-tl-20180909\install-tl" -profile=../texlive.profile
          Use of uninitialized value $ver in scalar chomp at C:/Users/PengZhao/AppData/Local/Temp/RtmpeYk32F/install-tl-20180909/tlpkg/TeXLive/TLWinGoo.pm line 204.
          Use of uninitialized value $ver in substitution (s///) at C:/Users/PengZhao/AppData/Local/Temp/RtmpeYk32F/install-tl-20180909/tlpkg/TeXLive/TLWinGoo.pm line 205.
          Use of uninitialized value $ver in substitution (s///) at C:/Users/PengZhao/AppData/Local/Temp/RtmpeYk32F/install-tl-20180909/tlpkg/TeXLive/TLWinGoo.pm line 205.
          Automated TeX Live installation using profile: ../texlive.profile
          Can't spawn "cmd.exe": No such file or directory at C:/Users/PengZhao/AppData/Local/Temp/RtmpeYk32F/install-tl-20180909/tlpkg/TeXLive/TLUtils.pm line 2481.
          Setting up tar with C:/Users/PengZhao/AppData/Local/Temp/RtmpeYk32F/install-tl-20180909/tlpkg/installer/tar.exe as C:\Users\PengZhao\AppData\Local\Temp\RtmpeYk32F\install-tl-20180909\tlpkg\installer\tar.exe didn't work
          GNU tar 1.11.8 + 2.2(WIN32)
          Can't spawn "cmd.exe": No such file or directory at C:/Users/PengZhao/AppData/Local/Temp/RtmpeYk32F/install-tl-20180909/tlpkg/TeXLive/TLUtils.pm line 2464.
          Can't spawn "cmd.exe": No such file or directory at C:/Users/PengZhao/AppData/Local/Temp/RtmpeYk32F/install-tl-20180909/tlpkg/TeXLive/TLUtils.pm line 2464.
          Can't spawn "cmd.exe": No such file or directory at C:/Users/PengZhao/AppData/Local/Temp/RtmpeYk32F/install-tl-20180909/tlpkg/TeXLive/TLUtils.pm line 2464.
          Can't spawn "cmd.exe": No such file or directory at C:/Users/PengZhao/AppData/Local/Temp/RtmpeYk32F/install-tl-20180909/tlpkg/TeXLive/TLUtils.pm line 2481.
          Setting up wget with C:/Users/PengZhao/AppData/Local/Temp/RtmpeYk32F/install-tl-20180909/tlpkg/installer/wget/wget.exe as C:\Users\PengZhao\AppData\Local\Temp\RtmpeYk32F\install-tl-20180909\tlpkg\installer\wget\wget.exe didn't work
          GNU Wget 1.19.1 built on mingw32.
          
          -cares +digest -gpgme +https +ipv6 -iri +large-file -metalink -nls 
          -ntlm +opie -psl +ssl/gnutls 
          
          Wgetrc: 
              C:/usr/anothermsys/local/etc/wgetrc (system)
          Compile: 
              gcc -DHAVE_CONFIG_H -DSYSTEM_WGETRC="/usr/local/etc/wgetrc" 
              -DLOCALEDIR="/usr/local/share/locale" -I. -I../lib -I../lib 
              -I/usr/local/include -DNDEBUG -static 
          Link: 
              gcc -DNDEBUG -static /usr/local/lib/libgnutls.a -lz -lws2_32 
              /usr/local/lib/libnettle.a /usr/local/lib/libhogweed.a 
              /usr/local/lib/libgmp.a -lcrypt32 -lz -lws2_32 ftp-opie.o 
              mswindows.o gnutls.o ../lib/libgnu.a -lws2_32 -lws2_32 -lws2_32 
              -lws2_32 /usr/local/lib/libiconv.a -lws2_32 
          
          Copyright (C) 2015 Free Software Foundation, Inc.
          License GPLv3+: GNU GPL version 3 or later
          <http://www.gnu.org/licenses/gpl.html>.
          This is free software: you are free to change and redistribute it.
          There is NO WARRANTY, to the extent permitted by law.
          
          Originally written by Hrvoje Niksic <hniksic@xemacs.org>.
          Please send bug reports and questions to <bug-wget@gnu.org>.
          Can't spawn "cmd.exe": No such file or directory at C:/Users/PengZhao/AppData/Local/Temp/RtmpeYk32F/install-tl-20180909/tlpkg/TeXLive/TLUtils.pm line 2464.
          Can't spawn "cmd.exe": No such file or directory at C:/Users/PengZhao/AppData/Local/Temp/RtmpeYk32F/install-tl-20180909/tlpkg/TeXLive/TLUtils.pm line 2464.
          Can't spawn "cmd.exe": No such file or directory at C:/Users/PengZhao/AppData/Local/Temp/RtmpeYk32F/install-tl-20180909/tlpkg/TeXLive/TLUtils.pm line 2464.
          Can't spawn "cmd.exe": No such file or directory at C:/Users/PengZhao/AppData/Local/Temp/RtmpeYk32F/install-tl-20180909/tlpkg/TeXLive/TLUtils.pm line 2481.
          Setting up xz with C:/Users/PengZhao/AppData/Local/Temp/RtmpeYk32F/install-tl-20180909/tlpkg/installer/xz/xz.exe as C:\Users\PengZhao\AppData\Local\Temp\RtmpeYk32F\install-tl-20180909\tlpkg\installer\xz\xz.exe didn't work
          xz (XZ Utils) 5.2.3
          liblzma 5.2.3
          query_ctan_mirror: Programs not set up, trying wget
          cannot contact mirror.ctan.org, returning a backbone server!
          C:\Users\PengZhao\AppData\Local\Temp\RtmpeYk32F\install-tl-20180909\install-tl: TLPDB::from_file could not download http://www.tex.ac.uk/tex-archive/systems/texlive/tlnet/tlpkg/texlive.tlpdb;
          C:\Users\PengZhao\AppData\Local\Temp\RtmpeYk32F\install-tl-20180909\install-tl: maybe the repository setting should be changed.
          Loading http://www.tex.ac.uk/tex-archive/systems/texlive/tlnet/tlpkg/texlive.tlpdb
          TinyTeX installed to C:\Users\PengZhao\AppData\Roaming/TinyTeX
          Please restart your R session and IDE (if you are using one, such as RStudio or Emacs) and check if tinytex:::is_tinytex() is TRUE.
          Warning message:
          In file.remove("TinyTeX/install-tl.log") :
            cannot remove file 'TinyTeX/install-tl.log', reason 'No such file or directory'

          > tinytex:::install_prebuilt()
          trying URL 'https://ci.appveyor.com/api/projects/yihui/tinytex/artifacts/TinyTeX.zip'
           length 93989978 bytes (89.6 MB)
          downloaded 89.6 MB
          
          tlmgr path add
          Use of uninitialized value $ver in scalar chomp at C:/Users/PengZhao/AppData/Roaming/TinyTeX/tlpkg/TeXLive/TLWinGoo.pm line 204.
          Use of uninitialized value $ver in substitution (s///) at C:/Users/PengZhao/AppData/Roaming/TinyTeX/tlpkg/TeXLive/TLWinGoo.pm line 205.
          Use of uninitialized value $ver in substitution (s///) at C:/Users/PengZhao/AppData/Roaming/TinyTeX/tlpkg/TeXLive/TLWinGoo.pm line 205.
          Can't spawn "cmd.exe": No such file or directory at C:/Users/PengZhao/AppData/Roaming/TinyTeX/tlpkg/TeXLive/TLUtils.pm line 2481.
          Setting up tar with C:/Users/PengZhao/AppData/Roaming/TinyTeX/tlpkg/installer/tar.exe as C:\Users\PengZhao\AppData\Roaming\TinyTeX\tlpkg\installer\tar.exe didn't work
          GNU tar 1.11.8 + 2.2(WIN32)
          Can't spawn "cmd.exe": No such file or directory at C:/Users/PengZhao/AppData/Roaming/TinyTeX/tlpkg/TeXLive/TLUtils.pm line 2464.
          Can't spawn "cmd.exe": No such file or directory at C:/Users/PengZhao/AppData/Roaming/TinyTeX/tlpkg/TeXLive/TLUtils.pm line 2464.
          Can't spawn "cmd.exe": No such file or directory at C:/Users/PengZhao/AppData/Roaming/TinyTeX/tlpkg/TeXLive/TLUtils.pm line 2464.
          Can't spawn "cmd.exe": No such file or directory at C:/Users/PengZhao/AppData/Roaming/TinyTeX/tlpkg/TeXLive/TLUtils.pm line 2481.
          Setting up wget with C:/Users/PengZhao/AppData/Roaming/TinyTeX/tlpkg/installer/wget/wget.exe as C:\Users\PengZhao\AppData\Roaming\TinyTeX\tlpkg\installer\wget\wget.exe didn't work
          GNU Wget 1.19.1 built on mingw32.
          
          -cares +digest -gpgme +https +ipv6 -iri +large-file -metalink -nls 
          -ntlm +opie -psl +ssl/gnutls 
          
          Wgetrc: 
              C:/usr/anothermsys/local/etc/wgetrc (system)
          Compile: 
              gcc -DHAVE_CONFIG_H -DSYSTEM_WGETRC="/usr/local/etc/wgetrc" 
              -DLOCALEDIR="/usr/local/share/locale" -I. -I../lib -I../lib 
              -I/usr/local/include -DNDEBUG -static 
          Link: 
              gcc -DNDEBUG -static /usr/local/lib/libgnutls.a -lz -lws2_32 
              /usr/local/lib/libnettle.a /usr/local/lib/libhogweed.a 
              /usr/local/lib/libgmp.a -lcrypt32 -lz -lws2_32 ftp-opie.o 
              mswindows.o gnutls.o ../lib/libgnu.a -lws2_32 -lws2_32 -lws2_32 
              -lws2_32 /usr/local/lib/libiconv.a -lws2_32 
          
          Copyright (C) 2015 Free Software Foundation, Inc.
          License GPLv3+: GNU GPL version 3 or later
          <http://www.gnu.org/licenses/gpl.html>.
          This is free software: you are free to change and redistribute it.
          There is NO WARRANTY, to the extent permitted by law.
          
          Originally written by Hrvoje Niksic <hniksic@xemacs.org>.
          Please send bug reports and questions to <bug-wget@gnu.org>.
          Can't spawn "cmd.exe": No such file or directory at C:/Users/PengZhao/AppData/Roaming/TinyTeX/tlpkg/TeXLive/TLUtils.pm line 2464.
          Can't spawn "cmd.exe": No such file or directory at C:/Users/PengZhao/AppData/Roaming/TinyTeX/tlpkg/TeXLive/TLUtils.pm line 2481.
          Setting up lz4 with C:/Users/PengZhao/AppData/Roaming/TinyTeX/tlpkg/installer/lz4/lz4.exe as C:\Users\PengZhao\AppData\Roaming\TinyTeX\tlpkg\installer\lz4\lz4.exe didn't work
          *** LZ4 command line interface 32-bits v1.8.2, by Yann Collet ***
          Can't spawn "cmd.exe": No such file or directory at C:/Users/PengZhao/AppData/Roaming/TinyTeX/tlpkg/TeXLive/TLUtils.pm line 2464.
          Can't spawn "cmd.exe": No such file or directory at C:/Users/PengZhao/AppData/Roaming/TinyTeX/tlpkg/TeXLive/TLUtils.pm line 2464.
          Can't spawn "cmd.exe": No such file or directory at C:/Users/PengZhao/AppData/Roaming/TinyTeX/tlpkg/TeXLive/TLUtils.pm line 2481.
          Setting up xz with C:/Users/PengZhao/AppData/Roaming/TinyTeX/tlpkg/installer/xz/xz.exe as C:\Users\PengZhao\AppData\Roaming\TinyTeX\tlpkg\installer\xz\xz.exe didn't work
          xz (XZ Utils) 5.2.3
          liblzma 5.2.3
          Use of uninitialized value in bitwise or (|) at C:\Users\PengZhao\AppData\Roaming\TinyTeX\texmf-dist\scripts\texlive\tlmgr.pl line 1482.
          texhash: Updating C:/Users/PengZhao/AppData/Roaming/TinyTeX/texmf-local/ls-R...
          texhash: Updated C:/Users/PengZhao/AppData/Roaming/TinyTeX/texmf-local/ls-R.
          texhash: Updating C:/Users/PengZhao/AppData/Roaming/TinyTeX/texmf-config/ls-R...
          texhash: Updated C:/Users/PengZhao/AppData/Roaming/TinyTeX/texmf-config/ls-R.
          texhash: Updating C:/Users/PengZhao/AppData/Roaming/TinyTeX/texmf-var/ls-R...
          texhash: Updated C:/Users/PengZhao/AppData/Roaming/TinyTeX/texmf-var/ls-R.
          texhash: Updating C:/Users/PengZhao/AppData/Roaming/TinyTeX/texmf-dist/ls-R...
          texhash: Updated C:/Users/PengZhao/AppData/Roaming/TinyTeX/texmf-dist/ls-R.
          texhash: Done.
          ...PengZhao\AppData\Roaming\TinyTeX\bin\win32\runscript.tlu:824: ...PengZhao\AppData\Roaming\TinyTeX\bin\win32\runscript.tlu:779: no appropriate script or program found: fmtuti~1
          ...PengZhao\AppData\Roaming\TinyTeX\bin\win32\runscript.tlu:824: ...PengZhao\AppData\Roaming\TinyTeX\bin\win32\runscript.tlu:779: no appropriate script or program found: updmap~1
          Note that it needs some time to create caches,
          especially if there are many large font files.
          Wait with patience.
          
          C:/windows/fonts: caching, new cache contents: 1063 fonts, 0 dirs
          C:/Users/appveyor/AppData/Roaming/TinyTeX/texmf-dist/fonts/opentype: skipping, no such directory
          C:/Users/appveyor/AppData/Roaming/TinyTeX/texmf-dist/fonts/truetype: skipping, no such directory
          C:/Users/PengZhao/AppData/Roaming/TinyTeX/texmf-var/fonts/cache: cleaning cache directory
          C:\Users\PengZhao\AppData\Roaming\TinyTeX\bin\win32\fc-cache.exe: succeeded

          > tinytex::tlmgr_search('ctexbook.cls')
          tlmgr search --file --global "ctexbook.cls"
          Use of uninitialized value $ver in scalar chomp at C:/Users/PengZhao/AppData/Roaming/TinyTeX/tlpkg/TeXLive/TLWinGoo.pm line 204.
          Use of uninitialized value $ver in substitution (s///) at C:/Users/PengZhao/AppData/Roaming/TinyTeX/tlpkg/TeXLive/TLWinGoo.pm line 205.
          Use of uninitialized value $ver in substitution (s///) at C:/Users/PengZhao/AppData/Roaming/TinyTeX/tlpkg/TeXLive/TLWinGoo.pm line 205.
          Can't spawn "cmd.exe": No such file or directory at C:/Users/PengZhao/AppData/Roaming/TinyTeX/tlpkg/TeXLive/TLUtils.pm line 2481.
          Setting up tar with C:/Users/PengZhao/AppData/Roaming/TinyTeX/tlpkg/installer/tar.exe as C:\Users\PengZhao\AppData\Roaming\TinyTeX\tlpkg\installer\tar.exe didn't work
          GNU tar 1.11.8 + 2.2(WIN32)
          Can't spawn "cmd.exe": No such file or directory at C:/Users/PengZhao/AppData/Roaming/TinyTeX/tlpkg/TeXLive/TLUtils.pm line 2464.
          Can't spawn "cmd.exe": No such file or directory at C:/Users/PengZhao/AppData/Roaming/TinyTeX/tlpkg/TeXLive/TLUtils.pm line 2464.
          Can't spawn "cmd.exe": No such file or directory at C:/Users/PengZhao/AppData/Roaming/TinyTeX/tlpkg/TeXLive/TLUtils.pm line 2464.
          Can't spawn "cmd.exe": No such file or directory at C:/Users/PengZhao/AppData/Roaming/TinyTeX/tlpkg/TeXLive/TLUtils.pm line 2481.
          Setting up wget with C:/Users/PengZhao/AppData/Roaming/TinyTeX/tlpkg/installer/wget/wget.exe as C:\Users\PengZhao\AppData\Roaming\TinyTeX\tlpkg\installer\wget\wget.exe didn't work
          GNU Wget 1.19.1 built on mingw32.
          
          -cares +digest -gpgme +https +ipv6 -iri +large-file -metalink -nls 
          -ntlm +opie -psl +ssl/gnutls 
          
          Wgetrc: 
              C:/usr/anothermsys/local/etc/wgetrc (system)
          Compile: 
              gcc -DHAVE_CONFIG_H -DSYSTEM_WGETRC="/usr/local/etc/wgetrc" 
              -DLOCALEDIR="/usr/local/share/locale" -I. -I../lib -I../lib 
              -I/usr/local/include -DNDEBUG -static 
          Link: 
              gcc -DNDEBUG -static /usr/local/lib/libgnutls.a -lz -lws2_32 
              /usr/local/lib/libnettle.a /usr/local/lib/libhogweed.a 
              /usr/local/lib/libgmp.a -lcrypt32 -lz -lws2_32 ftp-opie.o 
              mswindows.o gnutls.o ../lib/libgnu.a -lws2_32 -lws2_32 -lws2_32 
              -lws2_32 /usr/local/lib/libiconv.a -lws2_32 
          
          Copyright (C) 2015 Free Software Foundation, Inc.
          License GPLv3+: GNU GPL version 3 or later
          <http://www.gnu.org/licenses/gpl.html>.
          This is free software: you are free to change and redistribute it.
          There is NO WARRANTY, to the extent permitted by law.
          
          Originally written by Hrvoje Niksic <hniksic@xemacs.org>.
          Please send bug reports and questions to <bug-wget@gnu.org>.
          Can't spawn "cmd.exe": No such file or directory at C:/Users/PengZhao/AppData/Roaming/TinyTeX/tlpkg/TeXLive/TLUtils.pm line 2464.
          Can't spawn "cmd.exe": No such file or directory at C:/Users/PengZhao/AppData/Roaming/TinyTeX/tlpkg/TeXLive/TLUtils.pm line 2481.
          Setting up lz4 with C:/Users/PengZhao/AppData/Roaming/TinyTeX/tlpkg/installer/lz4/lz4.exe as C:\Users\PengZhao\AppData\Roaming\TinyTeX\tlpkg\installer\lz4\lz4.exe didn't work
          *** LZ4 command line interface 32-bits v1.8.2, by Yann Collet ***
          Can't spawn "cmd.exe": No such file or directory at C:/Users/PengZhao/AppData/Roaming/TinyTeX/tlpkg/TeXLive/TLUtils.pm line 2464.
          Can't spawn "cmd.exe": No such file or directory at C:/Users/PengZhao/AppData/Roaming/TinyTeX/tlpkg/TeXLive/TLUtils.pm line 2464.
          Can't spawn "cmd.exe": No such file or directory at C:/Users/PengZhao/AppData/Roaming/TinyTeX/tlpkg/TeXLive/TLUtils.pm line 2481.
          Setting up xz with C:/Users/PengZhao/AppData/Roaming/TinyTeX/tlpkg/installer/xz/xz.exe as C:\Users\PengZhao\AppData\Roaming\TinyTeX\tlpkg\installer\xz\xz.exe didn't work
          xz (XZ Utils) 5.2.3
          liblzma 5.2.3
          tlmgr.pl: package repository http://mirror.las.iastate.edu/tex-archive/systems/texlive/tlnet (not verified: gpg unavailable)
          ctex:
          	texmf-dist/tex/latex/ctex/ctexbook.cls

            dapengde 这我也不知道是怎么回事。我在云端设置了每天自动编译一遍,但并没有发现最近几天有失败的记录:https://ci.appveyor.com/project/yihui/tinytex/history 我刚在自己的 Windows 上试了一下,也可以成功安装。可能是临时的网络问题,或者是开发者恰好在某个时段把什么东西搞砸了?

              yihui 最近几天我在不同的时段和不同的网络环境(家,办公室)试过多次,都失败。我觉得可能是我新电脑的问题,怀疑是哪个端口被什么东西屏蔽了。改天换台电脑试试。

              网上搜 'cannot contact mirror.ctan.org, returning a backbone server!',得到一大堆结果,但是没有发现好用的办法。累觉不爱,暂用 MiKTeX 了。

              yihui 经过了多种努力,终于从这个安装失败的坑里爬出来了!

              解决方法很简单: windows 操作系统的环境变量里添加 PATH:c:\Windows\System32?

              操作系统是 windows 7。

              故障原因,我猜可能是某次折腾时某个软件把这个路径环境变量里覆盖了。

              网上提供的多个解决办法,例如安装 strawberryperl,例如查看防火墙或杀毒软件是不是在作祟……这些都不是我这次故障的原因。

              现在,TinyTex 成功安装了。不过,新问题来了:

              我参加 bookdown 大赛制作的两个中文模板(北京大学学位论文中科院大学学位论文),都无法编译成 pdf。后者说是 \CJKunderlinecolor undefined.。前者比较诡异,没有任何故障信息,貌似成功编译了,但就是没有生成 pdf 文件。

              此外,我在编译一个英文的 bookdown 项目时,通过点击 RStudio 的 build 按钮,第一次生成的 pdf 里的参考文献都显示的是问号。后来重新编译一次就好了。

              为了对比,我卸载了 TinyTeX,安装 MikTeX,升级到最新,安装 xetex 宏包和 pkuthss 包,然后编译 上面说的两个中文 bookdown 项目,都成功了。这是不是因为 MikTeX 里有些包在 TeX Live 里不存在?

                dapengde 我暂时没空检查这个问题。先看别的壮士(如 @Cloud2016 @yufree @tctcab 等)是否可以重现你的问题吧,如果问题在别人那里也可以重现,我再研究一下。

                还有,你这 c:\Windows\System32 坑太深了。

                  dapengde

                  在ubuntu下试了一下你的模板,发现没有windows的simsun字体就跪了…高贵的ubuntu用户怎么会拉下脸找人拷windows字体

                  是不是这个模板就限定windows only了?

                    tctcab LaTeX 模板是别人做的,我只是搬运到 bookdown 而已,没想过字体的问题? 这属于另外一个问题。

                    我现在的问题是即便是在 windows 里,用 TinyTeX 也搞不定。

                      tctcab 我原本也是想不要拷贝 Windows 下的字体,可是发现 Linux 下的替代字体竟然差别还比较明显(仔细看的话),当然了这发生在我的 bookdown 论文模板里 ,这个环境对字体格式要求比较高,不敢擅自做主替换字体。https://github.com/XiangyunHuang/Thesis-Template-Bookdown/tree/master/fonts

                      dapengde 别人的 LaTeX 模板维护起来很麻烦,我是不会 LaTeX 编程的,这个字体设置文件看起来懂了,其实似懂非懂, ctex-fontset-pkuthss.def ,早些时候我基于 bookdown 的论文模板,其 LaTeX 模板是学院代代相传的 CCT 中文处理系统, CTeX 除了从师兄师姐那拷贝,别无它法,你可以想象模板得有多老,现在他们还是十年如一届地继续用老模板,我是第一个推倒重来制作 LaTeX 模板,但是包裹了 bookdown,我不会 LaTeX 编程,所以 Thesis-Template-Bookdown 项目的 LaTeX 文件组织起来没有 LaTeX 项目那样标准。此外,我的经历告诉我,对于像论文、书籍模板这种复杂的应用,不建议同时维护那么多格式,我觉得 gitbook 和 pdf 两种格式够用,但是内容应该足够丰富以应对各式各样的图、表排版要求,往往这个才是阻碍推广的地方,因为比较难学,通常的 demo 不会覆盖到这里,初学者拿到模板是希望填公式和图表,而不是去学如何填公式和图表,不然他们又该回去用 Word 或者 LaTeX 了。

                      扯了这么多,回到问题,我试了 北京大学学位论文 除了几个警告没什么问题。

                      首先更新 tlmgr 和安装 pkuthss 宏包

                      tlmgr update --self
                      tlmgr install pkuthss

                      附环境信息

                      xfun::session_info(packages = c("bookdown","rmarkdown"))
                      R version 3.5.1 (2018-07-02)
                      Platform: x86_64-w64-mingw32/x64 (64-bit)
                      Running under: Windows >= 8 x64 (build 9200), RStudio 1.1.456
                      
                      Locale:
                        LC_COLLATE=Chinese (Simplified)_China.936 
                        LC_CTYPE=Chinese (Simplified)_China.936   
                        LC_MONETARY=Chinese (Simplified)_China.936
                        LC_NUMERIC=C                              
                        LC_TIME=Chinese (Simplified)_China.936    
                      
                      Package version:
                        base64enc_0.1.3   bookdown_0.7.18   digest_0.6.16     evaluate_0.11    
                        glue_1.3.0        graphics_3.5.1    grDevices_3.5.1   highr_0.7        
                        htmldeps_0.1.1    htmltools_0.3.6   jsonlite_1.5      knitr_1.20       
                        magrittr_1.5      markdown_0.8      methods_3.5.1     mime_0.5         
                        Rcpp_0.12.18      rmarkdown_1.10.12 stats_3.5.1       stringi_1.2.4    
                        stringr_1.3.1     tinytex_0.8       tools_3.5.1       utils_3.5.1      
                        xfun_0.3.8        yaml_2.2.0       
                      
                      Pandoc version: 2.2.3.2

                      附警告信息

                      ==> rmarkdown::render_site(encoding = 'UTF-8')
                      
                        |.......                                                          |  11%
                         inline R code fragments
                      
                        |..............                                                   |  22%
                      label: set-options (with options) 
                      List of 2
                       $ echo : logi FALSE
                       $ cache: logi FALSE
                      
                        |......................                                           |  33%
                         inline R code fragments
                      
                        |.............................                                    |  44%
                      label: co2 (with options) 
                      List of 4
                       $ echo     : logi FALSE
                       $ out.width: chr "80%"
                       $ fig.cap  : chr "�� R ���Ի���ͼ����"
                       $ fig.align: chr "center"
                      
                        |....................................                             |  56%
                        ordinary text without R code
                      
                        |...........................................                      |  67%
                      label: tabair
                        |...................................................              |  78%
                        ordinary text without R code
                      
                        |..........................................................       |  89%
                      label: unnamed-chunk-1 (with options) 
                      List of 1
                       $ eval: logi FALSE
                      
                        |.................................................................| 100%
                        ordinary text without R code
                      
                      
                      
                      
                      processing file: pku.Rmd
                      output file: pku.knit.md
                      
                      "D:/Program Files (x86)/Pandoc/pandoc" +RTS -K512m -RTS pku.utf8.md --to docx --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash+smart --output pku.docx --highlight-style tango --filter pandoc-citeproc 
                        |.......                                                          |  11%
                         inline R code fragments
                      
                        |..............                                                   |  22%
                      label: set-options (with options) 
                      List of 2
                       $ echo : logi FALSE
                       $ cache: logi FALSE
                      
                        |......................                                           |  33%
                         inline R code fragments
                      
                        |.............................                                    |  44%
                      label: co2 (with options) 
                      List of 4
                       $ echo     : logi FALSE
                       $ out.width: chr "80%"
                       $ fig.cap  : chr "�� R ���Ի���ͼ����"
                       $ fig.align: chr "center"
                      
                        |....................................                             |  56%
                        ordinary text without R code
                      
                        |...........................................                      |  67%
                      label: tabair
                        |...................................................              |  78%
                        ordinary text without R code
                      
                        |..........................................................       |  89%
                      label: unnamed-chunk-1 (with options) 
                      List of 1
                       $ eval: logi FALSE
                      
                        |.................................................................| 100%
                        ordinary text without R code
                      
                      
                      
                      Output created: _book/pku.docx
                      
                      
                      processing file: pku.Rmd
                      output file: pku.knit.md
                      
                      "D:/Program Files (x86)/Pandoc/pandoc" +RTS -K512m -RTS pku.utf8.md --to epub3 --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output pku.epub --number-sections --filter pandoc-citeproc 
                        |.......                                                          |  11%
                         inline R code fragments
                      
                        |..............                                                   |  22%
                      label: set-options (with options) 
                      List of 2
                       $ echo : logi FALSE
                       $ cache: logi FALSE
                      
                        |......................                                           |  33%
                         inline R code fragments
                      
                        |.............................                                    |  44%
                      label: co2 (with options) 
                      List of 4
                       $ echo     : logi FALSE
                       $ out.width: chr "80%"
                       $ fig.cap  : chr "�� R ���Ի���ͼ����"
                       $ fig.align: chr "center"
                      
                        |....................................                             |  56%
                        ordinary text without R code
                      
                        |...........................................                      |  67%
                      label: tabair
                        |...................................................              |  78%
                        ordinary text without R code
                      
                        |..........................................................       |  89%
                      label: unnamed-chunk-1 (with options) 
                      List of 1
                       $ eval: logi FALSE
                      
                        |.................................................................| 100%
                        ordinary text without R code
                      
                      
                      
                      Output created: _book/pku.epub
                      
                      
                      processing file: pku.Rmd
                      output file: pku.knit.md
                      
                      "D:/Program Files (x86)/Pandoc/pandoc" +RTS -K512m -RTS pku.utf8.md --to html4 --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash+smart --output pku.html --email-obfuscation none --wrap preserve --standalone --section-divs --table-of-contents --toc-depth 3 --template "D:\site-library\bookdown\templates\gitbook.html" --highlight-style pygments --number-sections --css "style\gitbook.css" --include-in-header "C:\Users\xy-huang\AppData\Local\Temp\Rtmpqq6C5l\rmarkdown-str20e86aac3cc9.html" --mathjax --filter pandoc-citeproc 
                        |.......                                                          |  11%
                         inline R code fragments
                      
                        |..............                                                   |  22%
                      label: set-options (with options) 
                      List of 2
                       $ echo : logi FALSE
                       $ cache: logi FALSE
                      
                        |......................                                           |  33%
                         inline R code fragments
                      
                        |.............................                                    |  44%
                      label: co2 (with options) 
                      List of 4
                       $ echo     : logi FALSE
                       $ out.width: chr "80%"
                       $ fig.cap  : chr "�� R ���Ի���ͼ����"
                       $ fig.align: chr "center"
                      
                        |....................................                             |  56%
                        ordinary text without R code
                      
                        |...........................................                      |  67%
                      label: tabair
                        |...................................................              |  78%
                        ordinary text without R code
                      
                        |..........................................................       |  89%
                      label: unnamed-chunk-1 (with options) 
                      List of 1
                       $ eval: logi FALSE
                      
                        |.................................................................| 100%
                        ordinary text without R code
                      
                      
                      "D:/Program Files (x86)/Pandoc/pandoc" +RTS -K512m -RTS pku.utf8.md --to html4 --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash+smart --output pku.html --email-obfuscation none --self-contained --wrap preserve --standalone --section-divs --template "D:\site-library\rmarkdown\rmd\h\default.html" --no-highlight --variable highlightjs=1 --number-sections --variable "theme:bootstrap" --include-in-header "C:\Users\xy-huang\AppData\Local\Temp\Rtmpqq6C5l\rmarkdown-str20e83bd67914.html" --mathjax --variable "mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" --filter pandoc-citeproc 
                      
                      Output created: _book/preface.html
                      
                      
                      processing file: pku.Rmd
                      output file: pku.knit.md
                      
                        |.......                                                          |  11%
                         inline R code fragments
                      
                        |..............                                                   |  22%
                      label: set-options (with options) 
                      List of 2
                       $ echo : logi FALSE
                       $ cache: logi FALSE
                      
                        |......................                                           |  33%
                         inline R code fragments
                      
                        |.............................                                    |  44%
                      label: co2 (with options) 
                      List of 4
                       $ echo     : logi FALSE
                       $ out.width: chr "80%"
                       $ fig.cap  : chr "�� R ���Ի���ͼ����"
                       $ fig.align: chr "center"
                      
                      
                      Output created: pku.html
                      
                      
                      processing file: pku.Rmd
                        |....................................                             |  56%
                        ordinary text without R code
                      
                        |...........................................                      |  67%
                      label: tabair
                        |...................................................              |  78%
                        ordinary text without R code
                      
                        |..........................................................       |  89%
                      label: unnamed-chunk-1 (with options) 
                      List of 1
                       $ eval: logi FALSE
                      
                        |.................................................................| 100%
                        ordinary text without R code
                      
                      
                      "D:/Program Files (x86)/Pandoc/pandoc" +RTS -K512m -RTS pku.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output pku.tex --table-of-contents --toc-depth 2 --template "tex\template_pku.tex" --number-sections --highlight-style tango --pdf-engine xelatex --natbib --top-level-division=chapter --variable tables=yes --standalone 
                      output file: pku.knit.md
                      
                      
                      Output created: _book/pku.pdf
                      Warning messages:
                      1: In (knit_hooks$get("plot"))(file, reduce_plot_opts(options)) :
                        Chunk options fig.align, out.width, out.height, out.extra are not supported for Word output
                      2: In xfun::prose_index(content) : Code fences are not balanced
                      3: In xfun::prose_index(content) : Code fences are not balanced

                      附 LaTeX 信息

                      XeTeX 3.14159265-2.6-0.99999 (TeX Live 2018/W32TeX)
                      kpathsea version 6.3.0
                      Copyright 2018 SIL International, Jonathan Kew and Khaled Hosny.
                      There is NO warranty.  Redistribution of this software is
                      covered by the terms of both the XeTeX copyright and
                      the Lesser GNU General Public License.
                      For more information about these matters, see the file
                      named COPYING and the XeTeX source.
                      Primary author of XeTeX: Jonathan Kew.
                      Compiled with ICU version 61.1; using 61.1
                      Compiled with zlib version 1.2.11; using 1.2.11
                      Compiled with FreeType2 version 2.9.1; using 2.9.1
                      Compiled with Graphite2 version 1.3.11; using 1.3.11
                      Compiled with HarfBuzz version 1.7.6; using 1.7.6
                      Compiled with libpng version 1.6.34; using 1.6.34
                      Compiled with poppler version 0.64.0
                      Compiled with fontconfig version 2.13.0; using 2.13.0

                        字体问题 ctex 包应该早已经可以根据操作系统自动选择了,瘟到死和苹果都有自带中文字体,Linux 下也有保底的 Fandol 字体,所以现在完全没必要写死为宋体。当然这问题如 @Cloud2016 所说,历史的惯性太大了。LaTeX 这种东西大家都不敢随便动(问你惊喜不惊喜、敢动不敢动?不敢动不敢动),宁愿用十年前的模板和软件吊死在 Windows 上,也不敢轻易尝试新版本,因为一旦搞砸,这会是一个吸收时间的黑洞,代价太大。

                        所以我已经开始启程走 CSS 排版之路,直接从浏览器生成高质量 PDF。

                          Cloud2016 yihui 有点诡异。tlmgr 的升级我没有做,改天试试是不是这个问题。

                          话说人们对 pdf 和 doc 格式的依赖也是属于历史惯性吧,因为看上去就像打印出来的。现在无纸化越来越成熟,根本不需要打印,慢慢也就淘汰了吧。

                          我们痛苦地制作出适合打印的pdf,然后痛苦地在kindle上读pdf……何苦……

                            dapengde 核心问题在于需不需要“页”的概念。对短文档来说无所谓,是不是分成两三页都可以很快看完。问题只是长文档,如果分页的话,读起来让人不那么绝望,随时知道进度条。至于是否打印,与阅读习惯有关,而且翻一本纸书比翻一本电子书稍微容易一点。当然,我也觉得分页排版主要还是历史惯性的原因。

                            dapengde

                            windows下测了一下,pdf通过tinytex装了一堆库之后编译成功,
                            一开始是缺ctex库自动安装失败,后来tinytex::tlmgr_update()升级之后就可以了。
                            当然我还升级rmarkdown到github的最新版本不知道有木有关系…

                            @Cloud2016 @tctcab 我把 tlmgr, rmakrdown, bookdown 全都升级了,故障依旧:

                            • bookdown-ucas 不能成功编译,显示 ! LaTeX Error: \CJKunderlinecolor undefined.log 文件)。

                            • bookdown-pku 貌似编译完了,但没有生成 pdf 文件(log 文件)。我留意到出现了个 missfont.log 文件,不明白是不是缺少了什么字体。

                            看大家用的系统比较新,怀疑是不是我的 windows 7 的问题?

                            > devtools::session_info()
                            Session info ------------------------------------------------------------------------------------
                             setting  value                                              
                             version  R version 3.5.1 (2018-07-02)                       
                             system   x86_64, mingw32                                    
                             ui       RStudio (1.1.456)                                  
                             language (EN)                                               
                             collate  Chinese (Simplified)_People's Republic of China.936
                             tz       Europe/Berlin                                      
                             date     2018-09-15                                         
                            
                            Packages ----------------------------------------------------------------------------------------
                             package    * version date       source                            
                             backports    1.1.2   2017-12-13 CRAN (R 3.5.0)                    
                             base       * 3.5.1   2018-07-02 local                             
                             bookdown   * 0.7.18  2018-09-15 Github (rstudio/bookdown@b657ab3) 
                             compiler     3.5.1   2018-07-02 local                             
                             curl         3.2     2018-03-28 CRAN (R 3.5.1)                    
                             datasets   * 3.5.1   2018-07-02 local                             
                             devtools     1.13.6  2018-06-27 CRAN (R 3.5.1)                    
                             digest       0.6.17  2018-09-12 CRAN (R 3.5.1)                    
                             evaluate     0.11    2018-07-17 CRAN (R 3.5.1)                    
                             git2r        0.23.0  2018-07-17 CRAN (R 3.5.1)                    
                             graphics   * 3.5.1   2018-07-02 local                             
                             grDevices  * 3.5.1   2018-07-02 local                             
                             htmltools    0.3.6   2017-04-28 CRAN (R 3.5.1)                    
                             httr         1.3.1   2017-08-20 CRAN (R 3.5.1)                    
                             knitr        1.20    2018-02-20 CRAN (R 3.5.1)                    
                             magrittr     1.5     2014-11-22 CRAN (R 3.5.1)                    
                             memoise      1.1.0   2017-04-21 CRAN (R 3.5.1)                    
                             methods    * 3.5.1   2018-07-02 local                             
                             R6           2.2.2   2017-06-17 CRAN (R 3.5.1)                    
                             Rcpp         0.12.18 2018-07-23 CRAN (R 3.5.1)                    
                             rmarkdown    1.10.13 2018-09-15 Github (rstudio/rmarkdown@df4ec91)
                             rprojroot    1.3-2   2018-01-03 CRAN (R 3.5.1)                    
                             rstudioapi   0.7     2017-09-07 CRAN (R 3.5.1)                    
                             stats      * 3.5.1   2018-07-02 local                             
                             stringi      1.2.4   2018-07-20 CRAN (R 3.5.1)                    
                             stringr      1.3.1   2018-05-10 CRAN (R 3.5.1)                    
                             tools        3.5.1   2018-07-02 local                             
                             utils      * 3.5.1   2018-07-02 local                             
                             withr        2.1.2   2018-03-15 CRAN (R 3.5.1)                    
                             xfun         0.3     2018-07-06 CRAN (R 3.5.1)                    
                             yaml         2.2.0   2018-07-25 CRAN (R 3.5.1)