yufree 刚看了一下这个 psyr 问题,是我的自动搜索代码考虑不周,已经在 R 包 tinytex 中修正,谢谢。前面提到的 ptmr7t.mf 字体问题我得看一眼具体的错误日志是什么。

    yihui 我当时装了 timesrsfs 这两个包后 ptmr7t 的问题就解决了,然后卡在 psyr上了,错误信息如下

    ! Font OT1/ptm/m/n/12=ptmr7t at 12.0pt not loadable: Metric (TFM) file not foun
    d.
    <to be read again> 
                       relax 
    l.46 \begin{document}
    pandoc.exe: Error producing PDF
    Error: pandoc document conversion failed with error 43
    In addition: Warning message:
    running command '"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS Untitled.utf8.md --to latex --from markdown+ascii_identifiers+tex_math_single_backslash-autolink_bare_uris --output Untitled.pdf --template "C:\PROGRA~1\R\R-34~1.3\library\rticles\RMARKD~1\TEMPLA~1\AMS_AR~1\RESOUR~1\template.tex" --highlight-style tango --latex-engine pdflatex --csl "C:\PROGRA~1\R\R-34~1.3\library\rticles\RMARKD~1\TEMPLA~1\AMS_AR~1\RESOUR~1\AMERIC~1.CSL" --filter pandoc-citeproc' had status 43 

    更新包后尝试 rticles 包里 American Meteorological Society 的那个模版,出现如下错误

    render("Untitled.Rmd")
    !pdfTeX error: pdflatex (file 8r.enc): cannot open encoding file for reading
     ==> Fatal error occurred, no output PDF file produced!
    
    pandoc: Error producing PDF
    Error: pandoc document conversion failed with error 43

    额,这是log文件里的内容

    This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017) (preloaded format=pdflatex 2017.12.4)  4 DEC 2017 16:08
    entering extended mode
     restricted \write18 enabled.
     %&-line parsing enabled.
    **Untitled.tex
    (./Untitled.tex
    LaTeX2e <2017-04-15>
    Babel <3.15> and hyphenation patterns for 3 language(s) loaded.
    (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/ametsoc/ametsoc.cls
    \c@section=\count79
    \c@subsection=\count80
    \c@subsubsection=\count81
    \c@paragraph=\count82
    \c@subparagraph=\count83
    \c@figure=\count84
    \c@table=\count85
    \abovecaptionskip=\skip41
    \belowcaptionskip=\skip42
    \bibindent=\dimen102
    (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/graphics/graphicx.sty
    Package: graphicx 2017/06/01 v1.1a Enhanced LaTeX Graphics (DPC,SPQR)
    (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/graphics/keyval.sty
    Package: keyval 2014/10/28 v1.15 key=value parser (DPC)
    \KV@toks@=\toks14
    ) (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/graphics/graphics.sty
    Package: graphics 2017/06/25 v1.2c Standard LaTeX Graphics (DPC,SPQR)
    (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/graphics/trig.sty
    Package: trig 2016/01/03 v1.10 sin cos tan (DPC)
    ) (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/graphics-cfg/graphics.cfg
    File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration
    )
    Package graphics Info: Driver file: pdftex.def on input line 99.
    (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/graphics-def/pdftex.def
    File: pdftex.def 2017/06/24 v1.0g Graphics/color driver for pdftex
    ))
    \Gin@req@height=\dimen103
    \Gin@req@width=\dimen104
    ) (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/amsmath/amsmath.sty
    Package: amsmath 2017/09/02 v2.17a AMS math features
    \@mathmargin=\skip43
    For additional information on amsmath, use the `?' option.
    (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/amsmath/amstext.sty
    Package: amstext 2000/06/29 v2.01 AMS text
    (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/amsmath/amsgen.sty
    File: amsgen.sty 1999/11/30 v2.0 generic functions
    \@emptytoks=\toks15
    \ex@=\dimen105
    )) (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/amsmath/amsbsy.sty
    Package: amsbsy 1999/11/29 v1.2d Bold Symbols
    \pmbraise@=\dimen106
    ) (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/amsmath/amsopn.sty
    Package: amsopn 2016/03/08 v2.02 operator names
    )
    \inf@bad=\count86
    LaTeX Info: Redefining \frac on input line 213.
    \uproot@=\count87
    \leftroot@=\count88
    LaTeX Info: Redefining \overline on input line 375.
    \classnum@=\count89
    \DOTSCASE@=\count90
    LaTeX Info: Redefining \ldots on input line 472.
    LaTeX Info: Redefining \dots on input line 475.
    LaTeX Info: Redefining \cdots on input line 596.
    \Mathstrutbox@=\box26
    \strutbox@=\box27
    \big@size=\dimen107
    LaTeX Font Info:    Redeclaring font encoding OML on input line 712.
    LaTeX Font Info:    Redeclaring font encoding OMS on input line 713.
    \macc@depth=\count91
    \c@MaxMatrixCols=\count92
    \dotsspace@=\muskip10
    \c@parentequation=\count93
    \dspbrk@lvl=\count94
    \tag@help=\toks16
    \row@=\count95
    \column@=\count96
    \maxfields@=\count97
    \andhelp@=\toks17
    \eqnshift@=\dimen108
    \alignsep@=\dimen109
    \tagshift@=\dimen110
    \tagwidth@=\dimen111
    \totwidth@=\dimen112
    \lineht@=\dimen113
    \@envbody=\toks18
    \multlinegap=\skip44
    \multlinetaggap=\skip45
    \mathdisplay@stack=\toks19
    LaTeX Info: Redefining \[ on input line 2817.
    LaTeX Info: Redefining \] on input line 2818.
    ) (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/amsfonts/amsfonts.sty
    Package: amsfonts 2013/01/14 v3.01 Basic AMSFonts support
    \symAMSa=\mathgroup4
    \symAMSb=\mathgroup5
    LaTeX Font Info:    Overwriting math alphabet `\mathfrak' in version `bold'
    (Font)                  U/euf/m/n --> U/euf/b/n on input line 106.
    ) (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/amsfonts/amssymb.sty
    Package: amssymb 2013/01/14 v3.01 AMS font symbols
    ) (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/tools/bm.sty
    Package: bm 2017/01/16 v1.2c Bold Symbol Support (DPC/FMi)
    \symboldoperators=\mathgroup6
    \symboldletters=\mathgroup7
    \symboldsymbols=\mathgroup8
    LaTeX Font Info:    Redeclaring math alphabet \mathbf on input line 141.
    LaTeX Info: Redefining \bm on input line 207.
    ) (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/psnfss/helvet.sty
    Package: helvet 2005/04/12 PSNFSS-v9.2a (WaS) 
    ) (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/psnfss/mathptmx.sty
    Package: mathptmx 2005/04/12 PSNFSS-v9.2a Times w/ Math, improved (SPQR, WaS) 
    LaTeX Font Info:    Redeclaring symbol font `operators' on input line 28.
    LaTeX Font Info:    Overwriting symbol font `operators' in version `normal'
    (Font)                  OT1/cmr/m/n --> OT1/ztmcm/m/n on input line 28.
    LaTeX Font Info:    Overwriting symbol font `operators' in version `bold'
    (Font)                  OT1/cmr/bx/n --> OT1/ztmcm/m/n on input line 28.
    LaTeX Font Info:    Redeclaring symbol font `letters' on input line 29.
    LaTeX Font Info:    Overwriting symbol font `letters' in version `normal'
    (Font)                  OML/cmm/m/it --> OML/ztmcm/m/it on input line 29.
    LaTeX Font Info:    Overwriting symbol font `letters' in version `bold'
    (Font)                  OML/cmm/b/it --> OML/ztmcm/m/it on input line 29.
    LaTeX Font Info:    Redeclaring symbol font `symbols' on input line 30.
    LaTeX Font Info:    Overwriting symbol font `symbols' in version `normal'
    (Font)                  OMS/cmsy/m/n --> OMS/ztmcm/m/n on input line 30.
    LaTeX Font Info:    Overwriting symbol font `symbols' in version `bold'
    (Font)                  OMS/cmsy/b/n --> OMS/ztmcm/m/n on input line 30.
    LaTeX Font Info:    Redeclaring symbol font `largesymbols' on input line 31.
    LaTeX Font Info:    Overwriting symbol font `largesymbols' in version `normal'
    (Font)                  OMX/cmex/m/n --> OMX/ztmcm/m/n on input line 31.
    LaTeX Font Info:    Overwriting symbol font `largesymbols' in version `bold'
    (Font)                  OMX/cmex/m/n --> OMX/ztmcm/m/n on input line 31.
    \symbold=\mathgroup9
    \symitalic=\mathgroup10
    LaTeX Font Info:    Redeclaring math alphabet \mathbf on input line 34.
    LaTeX Font Info:    Redeclaring math alphabet \mathit on input line 35.
    LaTeX Font Info:    Overwriting math alphabet `\mathit' in version `normal'
    (Font)                  OT1/cmr/m/it --> OT1/ptm/m/it on input line 35.
    LaTeX Font Info:    Overwriting math alphabet `\mathit' in version `bold'
    (Font)                  OT1/cmr/bx/it --> OT1/ptm/m/it on input line 35.
    LaTeX Info: Redefining \hbar on input line 50.
    ) (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/natbib/natbib.sty
    Package: natbib 2010/09/13 8.31b (PWD, AO)
    \bibhang=\skip46
    \bibsep=\skip47
    LaTeX Info: Redefining \cite on input line 694.
    \c@NAT@ctr=\count98
    ) (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/url/url.sty
    \Urlmuskip=\muskip11
    Package: url 2013/09/16  ver 3.4  Verb mode for urls, etc.
    ) (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/xcolor/xcolor.sty
    Package: xcolor 2016/05/11 v2.12 LaTeX color extensions (UK)
    (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/graphics-cfg/color.cfg
    File: color.cfg 2016/01/02 v1.6 sample color configuration
    )
    Package xcolor Info: Driver file: pdftex.def on input line 225.
    Package xcolor Info: Model `cmy' substituted by `cmy0' on input line 1348.
    Package xcolor Info: Model `hsb' substituted by `rgb' on input line 1352.
    Package xcolor Info: Model `RGB' extended on input line 1364.
    Package xcolor Info: Model `HTML' substituted by `rgb' on input line 1366.
    Package xcolor Info: Model `Hsb' substituted by `hsb' on input line 1367.
    Package xcolor Info: Model `tHsb' substituted by `hsb' on input line 1368.
    Package xcolor Info: Model `HSB' substituted by `hsb' on input line 1369.
    Package xcolor Info: Model `Gray' substituted by `gray' on input line 1370.
    Package xcolor Info: Model `wave' substituted by `hsb' on input line 1371.
    ) (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/tools/indentfirst.sty
    Package: indentfirst 1995/11/23 v1.03 Indent first paragraph (DPC)
    ) (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/tools/multicol.sty
    Package: multicol 2017/04/11 v1.8q multicolumn formatting (FMi)
    \c@tracingmulticols=\count99
    \mult@box=\box28
    \multicol@leftmargin=\dimen114
    \c@unbalance=\count100
    \c@collectmore=\count101
    \doublecol@number=\count102
    \multicoltolerance=\count103
    \multicolpretolerance=\count104
    \full@width=\dimen115
    \page@free=\dimen116
    \premulticols=\dimen117
    \postmulticols=\dimen118
    \multicolsep=\skip48
    \multicolbaselineskip=\skip49
    \partial@page=\box29
    \last@line=\box30
    \maxbalancingoverflow=\dimen119
    \mult@rightbox=\box31
    \mult@grightbox=\box32
    \mult@gfirstbox=\box33
    \mult@firstbox=\box34
    \@tempa=\box35
    \@tempa=\box36
    \@tempa=\box37
    \@tempa=\box38
    \@tempa=\box39
    \@tempa=\box40
    \@tempa=\box41
    \@tempa=\box42
    \@tempa=\box43
    \@tempa=\box44
    \@tempa=\box45
    \@tempa=\box46
    \@tempa=\box47
    \@tempa=\box48
    \@tempa=\box49
    \@tempa=\box50
    \@tempa=\box51
    \c@columnbadness=\count105
    \c@finalcolumnbadness=\count106
    \last@try=\dimen120
    \multicolovershoot=\dimen121
    \multicolundershoot=\dimen122
    \mult@nat@firstbox=\box52
    \colbreak@box=\box53
    \mc@col@check@num=\count107
    ) (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/base/ifthen.sty
    Package: ifthen 2014/09/29 v1.1c Standard LaTeX ifthen package (DPC)
    ) (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/graphics/rotating.sty
    Package: rotating 2016/08/11 v2.16d rotated objects in LaTeX
    \c@r@tfl@t=\count108
    \rotFPtop=\skip50
    \rotFPbot=\skip51
    \rot@float@box=\box54
    \rot@mess@toks=\toks20
    ) (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/endfloat/endfloat.sty
    Package: endfloat 2011/12/25 v2.5d LaTeX2e package puts figures and tables at e
    nd (jdm)
    \c@posttable=\count109
    \efloat@postttt=\write3
    \@ef@tttopen=\count110
    \c@postfigure=\count111
    \efloat@postfff=\write4
    \@ef@fffopen=\count112
    ) (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/lineno/lineno.sty
    Package: lineno 2005/11/02 line numbers on paragraphs v4.41
    \linenopenalty=\count113
    \output=\toks21
    \linenoprevgraf=\count114
    \linenumbersep=\dimen123
    \linenumberwidth=\dimen124
    \c@linenumber=\count115
    \c@pagewiselinenumber=\count116
    \c@LN@truepage=\count117
    \c@internallinenumber=\count118
    \c@internallinenumbers=\count119
    \quotelinenumbersep=\dimen125
    \bframerule=\dimen126
    \bframesep=\dimen127
    \bframebox=\box55
    LaTeX Info: Redefining \\ on input line 3056.
    )
    \c@extraauth=\count120
    \c@loopnum=\count121
    \thanksnum=\count122
    \savethanksnum=\count123
    ) (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/hyperref/hyperref.sty
    Package: hyperref 2017/03/14 v6.85a Hypertext links for LaTeX
    
    (/Users/yufree/Library/TinyTeX/texmf-dist/tex/generic/oberdiek/hobsub-hyperref.
    sty
    Package: hobsub-hyperref 2016/05/16 v1.14 Bundle oberdiek, subset hyperref (HO)
    
    
    (/Users/yufree/Library/TinyTeX/texmf-dist/tex/generic/oberdiek/hobsub-generic.s
    ty
    Package: hobsub-generic 2016/05/16 v1.14 Bundle oberdiek, subset generic (HO)
    Package: hobsub 2016/05/16 v1.14 Construct package bundles (HO)
    Package: infwarerr 2016/05/16 v1.4 Providing info/warning/error messages (HO)
    Package: ltxcmds 2016/05/16 v1.23 LaTeX kernel commands for general use (HO)
    Package: ifluatex 2016/05/16 v1.4 Provides the ifluatex switch (HO)
    Package ifluatex Info: LuaTeX not detected.
    Package: ifvtex 2016/05/16 v1.6 Detect VTeX and its facilities (HO)
    Package ifvtex Info: VTeX not detected.
    Package: intcalc 2016/05/16 v1.2 Expandable calculations with integers (HO)
    Package: ifpdf 2017/03/15 v3.2 Provides the ifpdf switch
    Package: etexcmds 2016/05/16 v1.6 Avoid name clashes with e-TeX commands (HO)
    Package etexcmds Info: Could not find \expanded.
    (etexcmds)             That can mean that you are not using pdfTeX 1.50 or
    (etexcmds)             that some package has redefined \expanded.
    (etexcmds)             In the latter case, load this package earlier.
    Package: kvsetkeys 2016/05/16 v1.17 Key value parser (HO)
    Package: kvdefinekeys 2016/05/16 v1.4 Define keys (HO)
    Package: pdftexcmds 2017/03/19 v0.25 Utility functions of pdfTeX for LuaTeX (HO
    )
    Package pdftexcmds Info: LuaTeX not detected.
    Package pdftexcmds Info: \pdf@primitive is available.
    Package pdftexcmds Info: \pdf@ifprimitive is available.
    Package pdftexcmds Info: \pdfdraftmode found.
    Package: pdfescape 2016/05/16 v1.14 Implements pdfTeX's escape features (HO)
    Package: bigintcalc 2016/05/16 v1.4 Expandable calculations on big integers (HO
    )
    Package: bitset 2016/05/16 v1.2 Handle bit-vector datatype (HO)
    Package: uniquecounter 2016/05/16 v1.3 Provide unlimited unique counter (HO)
    )
    Package hobsub Info: Skipping package `hobsub' (already loaded).
    Package: letltxmacro 2016/05/16 v1.5 Let assignment for LaTeX macros (HO)
    Package: hopatch 2016/05/16 v1.3 Wrapper for package hooks (HO)
    Package: xcolor-patch 2016/05/16 xcolor patch
    Package: atveryend 2016/05/16 v1.9 Hooks at the very end of document (HO)
    Package atveryend Info: \enddocument detected (standard20110627).
    Package: atbegshi 2016/06/09 v1.18 At begin shipout hook (HO)
    Package: refcount 2016/05/16 v3.5 Data extraction from label references (HO)
    Package: hycolor 2016/05/16 v1.8 Color options for hyperref/bookmark (HO)
    ) (/Users/yufree/Library/TinyTeX/texmf-dist/tex/generic/ifxetex/ifxetex.sty
    Package: ifxetex 2010/09/12 v0.6 Provides ifxetex conditional
    ) (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/oberdiek/auxhook.sty
    Package: auxhook 2016/05/16 v1.4 Hooks for auxiliary files (HO)
    ) (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/oberdiek/kvoptions.sty
    Package: kvoptions 2016/05/16 v3.12 Key value format for package options (HO)
    )
    \@linkdim=\dimen128
    \Hy@linkcounter=\count124
    \Hy@pagecounter=\count125
    (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/hyperref/pd1enc.def
    File: pd1enc.def 2017/03/14 v6.85a Hyperref: PDFDocEncoding definition (HO)
    )
    \Hy@SavedSpaceFactor=\count126
    (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/latexconfig/hyperref.cfg
    File: hyperref.cfg 2002/06/06 v1.2 hyperref configuration of TeXLive
    )
    Package hyperref Info: Option `draft' set `true' on input line 4374.
    Package hyperref Info: Hyper figures OFF on input line 4498.
    Package hyperref Info: Link nesting OFF on input line 4503.
    Package hyperref Info: Hyper index ON on input line 4506.
    Package hyperref Info: Plain pages OFF on input line 4513.
    Package hyperref Info: Backreferencing OFF on input line 4518.
    Package hyperref Info: Implicit mode ON; LaTeX internals redefined.
    Package hyperref Info: Bookmarks ON on input line 4751.
    \c@Hy@tempcnt=\count127
    LaTeX Info: Redefining \url on input line 5104.
    \XeTeXLinkMargin=\dimen129
    \Fld@menulength=\count128
    \Field@Width=\dimen130
    \Fld@charsize=\dimen131
    Package hyperref Info: Hyper figures OFF on input line 6358.
    Package hyperref Info: Link nesting OFF on input line 6363.
    Package hyperref Info: Hyper index ON on input line 6366.
    Package hyperref Info: backreferencing OFF on input line 6373.
    Package hyperref Info: Link coloring OFF on input line 6378.
    Package hyperref Info: Link coloring with OCG OFF on input line 6383.
    Package hyperref Info: PDF/A mode OFF on input line 6388.
    LaTeX Info: Redefining \ref on input line 6428.
    LaTeX Info: Redefining \pageref on input line 6432.
    \Hy@abspage=\count129
    \c@Item=\count130
    \c@Hfootnote=\count131
    )
    
    Package hyperref Message: Driver (autodetected): hpdftex.
    
    (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/hyperref/hpdftex.def
    File: hpdftex.def 2017/03/14 v6.85a Hyperref driver for pdfTeX
    \Fld@listcount=\count132
    \c@bookmark@seq@number=\count133
    
    (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/oberdiek/rerunfilecheck.sty
    Package: rerunfilecheck 2016/05/16 v1.8 Rerun checks for auxiliary files (HO)
    Package uniquecounter Info: New unique counter `rerunfilecheck' on input line 2
    82.
    )
    \Hy@SectionHShift=\skip52
    ) (./Untitled.aux)
    \openout1 = `Untitled.aux'.
    
    LaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line 46.
    LaTeX Font Info:    ... okay on input line 46.
    LaTeX Font Info:    Checking defaults for T1/cmr/m/n on input line 46.
    LaTeX Font Info:    ... okay on input line 46.
    LaTeX Font Info:    Checking defaults for OT1/cmr/m/n on input line 46.
    LaTeX Font Info:    ... okay on input line 46.
    LaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line 46.
    LaTeX Font Info:    ... okay on input line 46.
    LaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line 46.
    LaTeX Font Info:    ... okay on input line 46.
    LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line 46.
    LaTeX Font Info:    ... okay on input line 46.
    LaTeX Font Info:    Checking defaults for PD1/pdf/m/n on input line 46.
    LaTeX Font Info:    ... okay on input line 46.
    LaTeX Font Info:    Try loading font information for OT1+ptm on input line 46.
    (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/psnfss/ot1ptm.fd
    File: ot1ptm.fd 2001/06/04 font definitions for OT1/ptm.
    ) (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/oberdiek/epstopdf-base.st
    y
    Package: epstopdf-base 2016/05/15 v2.6 Base part for package epstopdf
    (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/oberdiek/grfext.sty
    Package: grfext 2016/05/16 v1.2 Manage graphics extensions (HO)
    )
    Package epstopdf-base Info: Redefining graphics rule for `.eps' on input line 4
    38.
    Package grfext Info: Graphics extension search list:
    (grfext)             [.pdf,.png,.jpg,.mps,.jpeg,.jbig2,.jb2,.PDF,.PNG,.JPG,.JPE
    G,.JBIG2,.JB2,.eps]
    (grfext)             \AppendGraphicsExtensions on input line 456.
    
    (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cf
    g
    File: epstopdf-sys.cfg 2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Liv
    e
    ))
    \AtBeginShipoutBox=\box56
    
    Package hyperref Warning: Height of page (\paperheight) is invalid (0.0pt),
    (hyperref)                using 11in.
    
    
    Package hyperref Warning: Draft mode on.
    
    Package hyperref Info: Link coloring OFF on input line 46.
    (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/hyperref/nameref.sty
    Package: nameref 2016/05/21 v2.44 Cross-referencing by name of section
    
    (/Users/yufree/Library/TinyTeX/texmf-dist/tex/generic/oberdiek/gettitlestring.s
    ty
    Package: gettitlestring 2016/05/16 v1.5 Cleanup title references (HO)
    )
    \c@section@level=\count134
    )
    LaTeX Info: Redefining \ref on input line 46.
    LaTeX Info: Redefining \pageref on input line 46.
    LaTeX Info: Redefining \nameref on input line 46.
    LaTeX Font Info:    Font shape `OT1/ptm/bx/n' in size <14.4> not available
    (Font)              Font shape `OT1/ptm/b/n' tried instead on input line 48.
    LaTeX Font Info:    Try loading font information for OT1+phv on input line 48.
    (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/psnfss/ot1phv.fd
    File: ot1phv.fd 2001/06/04 scalable font definitions for OT1/phv.
    )
    LaTeX Font Info:    Font shape `OT1/phv/m/n' will be
    (Font)              scaled to size 4.85pt on input line 48.
    LaTeX Font Info:    Try loading font information for OT1+ztmcm on input line 48
    .
    (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/psnfss/ot1ztmcm.fd
    File: ot1ztmcm.fd 2000/01/03 Fontinst v1.801 font definitions for OT1/ztmcm.
    )
    LaTeX Font Info:    Try loading font information for OML+ztmcm on input line 48
    .
    (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/psnfss/omlztmcm.fd
    File: omlztmcm.fd 2000/01/03 Fontinst v1.801 font definitions for OML/ztmcm.
    )
    LaTeX Font Info:    Try loading font information for OMS+ztmcm on input line 48
    .
    (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/psnfss/omsztmcm.fd
    File: omsztmcm.fd 2000/01/03 Fontinst v1.801 font definitions for OMS/ztmcm.
    )
    LaTeX Font Info:    Try loading font information for OMX+ztmcm on input line 48
    .
    (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/psnfss/omxztmcm.fd
    File: omxztmcm.fd 2000/01/03 Fontinst v1.801 font definitions for OMX/ztmcm.
    )
    LaTeX Font Info:    Font shape `OT1/ptm/bx/n' in size <12> not available
    (Font)              Font shape `OT1/ptm/b/n' tried instead on input line 48.
    LaTeX Font Info:    Font shape `OT1/ptm/bx/n' in size <9> not available
    (Font)              Font shape `OT1/ptm/b/n' tried instead on input line 48.
    LaTeX Font Info:    Font shape `OT1/ptm/bx/n' in size <7> not available
    (Font)              Font shape `OT1/ptm/b/n' tried instead on input line 48.
    
    Underfull \hbox (badness 10000) has occurred while \output is active
    []
     []
    
    LaTeX Font Info:    Font shape `OT1/ptm/bx/n' in size <5> not available
    (Font)              Font shape `OT1/ptm/b/n' tried instead on input line 48.
    [1{/Users/yufree/Library/TinyTeX/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
    [2]
    LaTeX Font Info:    Try loading font information for OMS+ptm on input line 64.
    (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/psnfss/omsptm.fd
    File: omsptm.fd 
    )
    LaTeX Font Info:    Font shape `OMS/ptm/m/n' in size <12> not available
    (Font)              Font shape `OMS/cmsy/m/n' tried instead on input line 64.
    LaTeX Font Info:    Try loading font information for OMS+cmtt on input line 80.
    
    LaTeX Font Info:    No file OMScmtt.fd. on input line 80.
    
    LaTeX Font Warning: Font shape `OMS/cmtt/m/n' undefined
    (Font)              using `OMS/cmsy/m/n' instead
    (Font)              for symbol `textbraceleft' on input line 80.
    
    
    Underfull \vbox (badness 2961) has occurred while \output is active []
    
    [3]
    Underfull \hbox (badness 2435) in paragraph at lines 94--99
    \OT1/cmtt/m/n/12 headings\OMS/cmtt/m/n/12 g \OT1/ptm/m/n/12 for a sin-gle para-
    graph within a sub-sub-sec-tion or \OMS/cmtt/m/n/12 n\OT1/cmtt/m/n/12 paragraph
    \OMS/cmtt/m/n/12 f\OT1/cmtt/m/n/12 Quaternary
     []
    
    Missing character: There is no ? in font ptmr7t!
    Missing character: There is no ? in font ptmr7t!
    Missing character: There is no ? in font ptmr7t!
    Missing character: There is no ? in font ptmr7t!
    
    Underfull \vbox (badness 3780) has occurred while \output is active []
    
    [4] [5]
    Underfull \vbox (badness 2359) has occurred while \output is active []
    
    [6]
    \openout4 = `Untitled.fff'.
    
    (Untitled.fff)
    \openout3 = `Untitled.ttt'.
    
    (Untitled.ttt)
    LaTeX Font Info:    Font shape `OT1/phv/m/n' will be
    (Font)              scaled to size 11.64001pt on input line 265.
    [7] [8]
    Underfull \hbox (badness 10000) in paragraph at lines 335--340
    \OT1/cmtt/m/n/12 index . cfm / publications / authors / journal-[]and-[]bams-[]
    authors / author-[]resources /
     []
    
    [9]
    No file Untitled.bbl.
    Missing character: There is no ? in font ptmr7t!
    Missing character: There is no ? in font ptmr7t!
    LaTeX Font Info:    Try loading font information for OML+ptm on input line 410.
    
    (/Users/yufree/Library/TinyTeX/texmf-dist/tex/latex/psnfss/omlptm.fd
    File: omlptm.fd 
    )
    LaTeX Font Info:    Font shape `OML/ptm/m/n' in size <12> not available
    (Font)              Font shape `OML/cmm/m/it' tried instead on input line 410.
    Missing character: There is no ? in font ptmr7t!
    Missing character: There is no ? in font ptmr7t!
    AED endfloat: Processing end Figures and Tables [10] (./Untitled.lot
    LaTeX Font Info:    Font shape `OT1/ptm/bx/n' in size <10.5> not available
    (Font)              Font shape `OT1/ptm/b/n' tried instead on input line 1.
    )
    \tf@lot=\write5
    \openout5 = `Untitled.lot'.
    
    [11
    
    
    ] (./Untitled.ttt
    LaTeX Font Info:    Font shape `OT1/ptm/bx/n' in size <8> not available
    (Font)              Font shape `OT1/ptm/b/n' tried instead on input line 4.
    LaTeX Font Info:    Font shape `OT1/ptm/bx/n' in size <6> not available
    (Font)              Font shape `OT1/ptm/b/n' tried instead on input line 4.
    [12
    
    ] [13]) (./Untitled.lof)
    \tf@lof=\write6
    \openout6 = `Untitled.lof'.
    
    [14
    
    
    
    ] (./Untitled.fff
    
    pdfTeX warning: pdflatex (file ./figure01.pdf): PDF inclusion: found PDF versio
    n <1.6>, but at most version <1.5> allowed
    <figure01.pdf, id=58, pagebox=cropbox, 663.47874pt x 853.1875pt>
    [15
    
    ]
    <Untitled_files/figure-latex/unnamed-chunk-1-1.pdf, id=62, pagebox=cropbox, 228
    .855pt x 325.215pt>
    [16] [17] [18])
    Package atveryend Info: Empty hook `BeforeClearDocument' on input line 421.
    Package atveryend Info: Empty hook `AfterLastShipout' on input line 421.
    (./Untitled.aux)
    Package atveryend Info: Executing hook `AtVeryEndDocument' on input line 421.
    Package atveryend Info: Empty hook `AtEndAfterFileList' on input line 421.
    
    LaTeX Font Warning: Some font shapes were not available, defaults substituted.
    
    Package atveryend Info: Empty hook `AtVeryVeryEnd' on input line 421.
     ) 
    Here is how much of TeX's memory you used:
     7438 strings out of 494926
     106095 string characters out of 6178028
     196800 words of memory out of 5000000
     10591 multiletter control sequences out of 15000+600000
     61266 words of font info for 136 fonts, out of 8000000 for 9000
     14 hyphenation exceptions out of 8191
     34i,10n,37p,279b,397s stack positions out of 5000i,500n,10000p,200000b,80000s
    
    !pdfTeX error: pdflatex (file 8r.enc): cannot open encoding file for reading
     ==> Fatal error occurred, no output PDF file produced!

      yufree 好了,现在我已经更新了 tinytex::parse_packages()rmarkdown::render(),你重装一下应该就可以全自动了。看看还有没有我漏考虑的情况:

      devtools::install_github(
        c("yihui/tinytex", "rstudio/rmarkdown@feature/tinytex")
      )

      现在 @dapengde 的 fandol 问题应该也能自动解决了。

        yihui 最新进展:powershell 在我的 win7 里是安装了的,不知怎的,在环境变量里没有它的路径。手动添加路径,就可以在 cmd 里运行 powershell 了。但是,安装仍然出错,说 The term 'Invoke-WebRequest' is not recognized,貌似仍然是 powershell 版本太低的问题:

        
        C:\Users\dapeng\AppData\Local\Temp\RtmpczicSz>where /q powershell   || echo powershell not found   && exit /b 
        
        C:\Users\dapeng\AppData\Local\Temp\RtmpczicSz>rem switch to a temp directory, whichever works 
        
        C:\Users\dapeng\AppData\Local\Temp\RtmpczicSz>cd /d "C:\Users\dapeng\AppData\Local\Temp" 
        
        C:\Users\dapeng\AppData\Local\Temp>cd /d "C:\Users\dapeng\AppData\Local\Temp" 
        
        C:\Users\dapeng\AppData\Local\Temp>cd /d "" 
        The filename, directory name, or volume label syntax is incorrect.
        
        C:\Users\dapeng\AppData\Local\Temp>rem in case there is a leftover install-tl-* dir, delete it 
        
        C:\Users\dapeng\AppData\Local\Temp>for / %G in ("install-tl-*") do rd /s /q "%~G" 
        
        C:\Users\dapeng\AppData\Local\Temp>rem download install-tl.zip and unzip it 
        
        C:\Users\dapeng\AppData\Local\Temp>powershell -Command "Invoke-WebRequest http://mirror.ctan.org/systems/texlive/tlnet/install-tl.zip -OutFile install-tl.zip" 
        The term 'Invoke-WebRequest' is not recognized as the name of a cmdlet, functio
        n, script file, or operable program. Check the spelling of the name, or if a pa
        th was included, verify that the path is correct and try again.
        At line:1 char:18
        + Invoke-WebRequest <<<<  http://mirror.ctan.org/systems/texlive/tlnet/install-
        tl.zip -OutFile install-tl.zip
            + CategoryInfo          : ObjectNotFound: (Invoke-WebRequest:String) [], C 
           ommandNotFoundException
            + FullyQualifiedErrorId : CommandNotFoundException
         
        
        C:\Users\dapeng\AppData\Local\Temp>powershell -Command "& { Add-Type -A 'System.IO.Compression.FileSystem'; [IO.Compression.ZipFile]::ExtractToDirectory('install-tl.zip', '.'); }" 
        Add-Type : Cannot add type. The assembly 'System.IO.Compression.FileSystem' cou
        ld not be found.
        At line:1 char:13
        + & { Add-Type <<<<  -A 'System.IO.Compression.FileSystem'; [IO.Compression.Zip
        File]::ExtractToDirectory('install-tl.zip', '.'); }
            + CategoryInfo          : ObjectNotFound: (System.IO.Compression.FileSyste 
           m:String) [Add-Type], Exception
            + FullyQualifiedErrorId : ASSEMBLY_NOT_FOUND,Microsoft.PowerShell.Commands 
           .AddTypeCommand
         
        Add-Type : Cannot add type. One or more required assemblies are missing.
        At line:1 char:13
        + & { Add-Type <<<<  -A 'System.IO.Compression.FileSystem'; [IO.Compression.Zip
        File]::ExtractToDirectory('install-tl.zip', '.'); }
            + CategoryInfo          : InvalidData: (:) [Add-Type], InvalidOperationExc 
           eption
            + FullyQualifiedErrorId : ASSEMBLY_LOAD_ERRORS,Microsoft.PowerShell.Comman 
           ds.AddTypeCommand
         
        Unable to find type [IO.Compression.ZipFile]: make sure that the assembly conta
        ining this type is loaded.
        At line:1 char:77
        + & { Add-Type -A 'System.IO.Compression.FileSystem'; [IO.Compression.ZipFile] 
        <<<< ::ExtractToDirectory('install-tl.zip', '.'); }
            + CategoryInfo          : InvalidOperation: (IO.Compression.ZipFile:String 
           ) [], RuntimeException
            + FullyQualifiedErrorId : TypeNotFound
         
        
        C:\Users\dapeng\AppData\Local\Temp>del install-tl.zip 
        Could Not Find C:\Users\dapeng\AppData\Local\Temp\install-tl.zip
        
        C:\Users\dapeng\AppData\Local\Temp>rem download texlive.profile and modify it (set texdir to ./TinyTeX) 
        
        C:\Users\dapeng\AppData\Local\Temp>powershell -Command "Invoke-WebRequest https://github.com/yihui/tinytex/raw/master/tools/texlive.profile -OutFile texlive.profile" 
        The term 'Invoke-WebRequest' is not recognized as the name of a cmdlet, functio
        n, script file, or operable program. Check the spelling of the name, or if a pa
        th was included, verify that the path is correct and try again.
        At line:1 char:18
        + Invoke-WebRequest <<<<  https://github.com/yihui/tinytex/raw/master/tools/tex
        live.profile -OutFile texlive.profile
            + CategoryInfo          : ObjectNotFound: (Invoke-WebRequest:String) [], C 
           ommandNotFoundException
            + FullyQualifiedErrorId : CommandNotFoundException
         
        
        C:\Users\dapeng\AppData\Local\Temp>powershell -Command "(gc texlive.profile) -replace './', './TinyTex/' | Out-File -encoding ASCII texlive.profile" 
        Get-Content : Cannot find path 'C:\Users\dapeng\AppData\Local\Temp\texlive.pr
        ofile' because it does not exist.
        At line:1 char:4
        + (gc <<<<  texlive.profile) -replace './', './TinyTex/' | Out-File -encoding A
        SCII texlive.profile
            + CategoryInfo          : ObjectNotFound: (C:\Users\c77011...texlive.profi 
           le:String) [Get-Content], ItemNotFoundException
            + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetCo 
           ntentCommand
         
        
        C:\Users\dapeng\AppData\Local\Temp>rem download the custom package list 
        
        C:\Users\dapeng\AppData\Local\Temp>powershell -Command "Invoke-WebRequest https://github.com/yihui/tinytex/raw/master/tools/pkgs-custom.txt -OutFile pkgs-custom.txt" 
        The term 'Invoke-WebRequest' is not recognized as the name of a cmdlet, functio
        n, script file, or operable program. Check the spelling of the name, or if a pa
        th was included, verify that the path is correct and try again.
        At line:1 char:18
        + Invoke-WebRequest <<<<  https://github.com/yihui/tinytex/raw/master/tools/pkg
        s-custom.txt -OutFile pkgs-custom.txt
            + CategoryInfo          : ObjectNotFound: (Invoke-WebRequest:String) [], C 
           ommandNotFoundException
            + FullyQualifiedErrorId : CommandNotFoundException
         
        
        C:\Users\dapeng\AppData\Local\Temp>rem an automated installation of TeXLive (infrastructure only) 
        
        C:\Users\dapeng\AppData\Local\Temp>cd install-tl-* 
        The filename, directory name, or volume label syntax is incorrect.
        'install-tl-windows.bat' is not recognized as an internal or external command,
        operable program or batch file.

          dapengde 嗯,应该是 PowerShell 版本太低了。我花了两天时间写这个脚本,写之前我犹豫了好一阵子是写 .bat 脚本还是为了 Windows 用户我来自学 Go 语言写一个可执行程序,最终还是偷懒写了 BAT 脚本,学习新语言不是我的强项,但看样子是要逼着我学 Go 语言了。

          dapengde 你的德语模板问题我已经解决了,安装最新的 tinytex 包和 rmarkdown 分支应该会自动安装相应的 babel 语言包。

            yihui

            我这次直接偷懒用 testthat 去测 rticles 包的模版了,目前只有4个模版有问题,目测前三个原因应该一致,可能跟路径设置有关,最后一个比较吊诡,信息如下:

            1. Error: asa_article format (@test_formats.R#30) ------------------------------
            file 'testdoc.pdf' does not exist
            1: rmarkdown::render(testdoc) at C:\Users\SPMESUPERCPU\Downloads\rticles/tests/testthat/test_formats.R:30
            2: tools::file_path_as_absolute(output_file)
            3: stop(gettextf("file '%s' does not exist", x), domain = NA)
            2. Error: jss_article format (@test_formats.R#30) ------------------------------
            file 'testdoc.pdf' does not exist
            1: rmarkdown::render(testdoc) at C:\Users\SPMESUPERCPU\Downloads\rticles/tests/testthat/test_formats.R:30
            2: tools::file_path_as_absolute(output_file)
            3: stop(gettextf("file '%s' does not exist", x), domain = NA)
            3. Error: pnas_article format (@test_formats.R#30) -----------------------------
            file 'testdoc.pdf' does not exist
            1: rmarkdown::render(testdoc) at C:\Users\SPMESUPERCPU\Downloads\rticles/tests/testthat/test_formats.R:30
            2: tools::file_path_as_absolute(output_file)
            3: stop(gettextf("file '%s' does not exist", x), domain = NA)
            4. Error: rjournal_article format (@test_formats.R#30) -------------------------
            unable to run 'pdflatex' on 'RJwrapper.tex'
            1: rmarkdown::render(testdoc) at C:\Users\SPMESUPERCPU\Downloads\rticles/tests/testthat/test_formats.R:30
            2: output_format$post_processor(yaml_front_matter, utf8_input, output_file, clean, !quiet)
            3: tools::texi2pdf("RJwrapper.tex", clean = clean) at C:\Users\SPMESUPERCPU\Downloads\rticles/R/rjournal_article.R:39
            4: texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, texi2dvi = texi2dvi, 
                   texinputs = texinputs, index = index)
            5: stop(gettextf("unable to run '%s' on '%s'", latex, file), domain = NA)
            DONE ===========================================================================

              yihui 你这是神的效率啊。

              Windows 下初步测试报告

              总结一下上面的测试。我的操作系统是 windows 7,安装有点麻烦。

              首先出现的安装错误是:

              'install-tl-windows.bat' is not recognized as an internal or external command,
              operable program or batch file.

              原因:安装要使用 powershell。如果环境变量里没有 powershell 的路径,则出错。

              解决办法:环境变量添加 path:%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\,重启。

              然后,出现的错误是:

              The term 'Invoke-WebRequest' is not recognized as ....

              原因:powershell 版本过低。查看 powershell 版本的方法:在命令行运行

              powershell
              $PSVersionTable.PSVersion

              如果主版本是2,那就是版本太低。下载安装新版,重启。

              解决这些问题之后,R 里尝试 bookdownplus 里的三个模板:

              bookdownplus::bookdownplus(template = 'yihui_mini')
              bookdownplus::bookdownplus(template = 'yihui_demo')
              bookdownplus::bookdownplus(template = 'yihui_zh`)

              前两个编译顺利。第三个失败,因为缺少 latex 宏包。只需运行:

              latexmk('yihui_zh.tex', engine = 'xelatex')

              就自动安装了所有缺少包(和字体)。顺利通过。

              调用 babel 包的模板bookdownplus::bookdownplus(template = 'thesis_classic') 仍然编译失败,同 Ubuntu 下的错误。装 rmarkdown 的分支失败,错误信息:

              ERROR: dependency 'yaml' is not available for package 'rmarkdown'

              暂时折腾到这里,洗脚睡觉去了。

              又及:欢迎大家用 bookdownplus 里的 30 个模板来调戏 tinytex,同时也算是调戏 bookdownplu 了。安装方法:

              devtools::install_github("pzhaonet/bookdownplus")

              使用方法见 bookdownplus 主页

                dapengde 你的 template_thesis_classic.tex 模板有问题,里面没有设置 babel 选项。


                第一次用狗语言写程序,写了半天才写完解压缩。实在是没兴趣写下去了,谁有兴趣谁继续吧,对照我的 Windows 批处理脚本翻译就好了。我还是老老实实用 R 语言翻译它吧,估计十五分钟能写完,狗语言里啥都得从头写起,好麻烦。

                package main
                
                import (
                  "io"
                  "io/ioutil"
                  "log"
                  "os"
                  "net/http"
                  "archive/zip"
                )
                
                func main() {
                  dir, err := ioutil.TempDir("", "tinytex")
                  if err != nil {
                    log.Fatal(err)
                  }
                  defer os.RemoveAll(dir)
                  println(dir)
                
                  os.Chdir(dir)
                
                  zipname := "install-tl.zip"
                  out, err := os.Create(zipname)
                  if err != nil {
                    log.Fatal(err)
                  }
                  defer out.Close()
                
                  resp, err := http.Get("http://mirror.ctan.org/systems/texlive/tlnet/install-tl.zip")
                  if err != nil {
                    println("Faled to download the TeX Live installer")
                    log.Fatal(err)
                  }
                  defer resp.Body.Close()
                
                  println("Downloading the TeX Live installer (this may take a few seconds)...")
                  if err := io.Copy(out, resp.Body); err != nil {
                    log.Fatal(err)
                  }
                
                  unzip(zipname)
                }
                
                func unzip(archive) error {
                  reader, err := zip.OpenReader(archive)
                  if err != nil {
                    return err
                  }
                
                  for _, file := range reader.File {
                    path := file.Name
                    println(path)
                
                    if file.FileInfo().IsDir() {
                      os.MkdirAll(path, file.Mode())
                      continue
                    }
                
                    fileReader, err := file.Open()
                    if err != nil {
                      return err
                    }
                    defer fileReader.Close()
                
                    targetFile, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, file.Mode())
                    if err != nil {
                      return err
                    }
                    defer targetFile.Close()
                
                    if _, err := io.Copy(targetFile, fileReader); err != nil {
                      return err
                    }
                  }
                
                  return nil
                }

                  yihui 迟些我再研究一下 thesis_classic 模板。不光是这个模板,bookdownplus 里好几个 tex 模板我都没法在 Ubuntu 下正常编译,也不知道是模板本身的问题,还是别的问题,只能暂时搁置。有个模板("thesis_zju_zh")在用 latexmk() 编译时自动去找 'booktabs-de.sty',没找到:

                  ## tlmgr search --file --global '/booktabs-de.sty'
                  ## ! LaTeX Error: File `booktabs-de.sty' not found.

                  于是我去看这个文件在 windows 下的安装路径,是:

                  d:\Program Files\CTEX\MiKTeX\tex\latex\booktabs-de\

                  那么说明是在'booktabs-de' 包里咯?直接安装:

                  tlmgr_install('booktabs-de')

                  装上去了,但是编译同一个 tex 文件仍然说找不到`booktabs-de.sty'。暂时搁置了。

                  此外,我 Ubuntu 里的 bookdown 在编译 pdf 时突然能自动下载 latex 宏包了,不知是不是因为装了 rmarkdown 分支。

                  下面是卸载 tinytex 的测试。

                  Ubuntu 下卸载 tinytex

                  比较顺利。第一次卸载时出了个错,但是再次运行卸载命令时显示已经卸载了。

                  tinytex::uninstall_tinytex()
                  ## tlmgr path remove
                  ## man symlink destination (/usr/local/share/man) not writable, cannot remove symlinks.
                  ## tlmgr: An error has occurred. See above messages. Exiting.
                  ## remove of symlinks had 1 error(s), see messages above.
                  tinytex::uninstall_tinytex()
                  ## tlmgr path remove
                  ## sh: 1: tlmgr: not found
                  ## Warning message:
                  ## In tlmgr(c("path", match.arg(action))) :
                  ##  TeX Live does not seem to be installed. See https://yihui.name/tinytex/.

                  Windows 下卸载 tinytex

                  首先是卸载出错:

                  tinytex::uninstall_tinytex()
                  ## Error in Sys.getenv("APPDATA", stop("Environment variable \"APPDATA\" not set.")) : 
                  ##   Environment variable "APPDATA" not set.

                  手动往环境变量里添加 PATH 为 %APPDATA%,重启,卸载,错误依旧。

                  试了试微软提供的方案:Environment variable may not expand %APPDATA% to the Application folder,重启,卸载,错误依旧。

                  看了看 uninstall_tinytex()的源代码,问题出在这里:

                  file.path(Sys.getenv("APPDATA",  stop("Environment variable \"APPDATA\" not set.")), "TinyTeX")
                  ## Error in Sys.getenv("APPDATA", stop("Environment variable \"APPDATA\" not set.")) : 
                  ##   Environment variable "APPDATA" not set.

                  系统找不到 "APPDATA"。我不明白是怎么回事,于是重写了卸载代码,手动输入了我的安装路径:

                  target = file.path("c:/Users/dapeng/AppData/Roaming", "TinyTeX")
                  tlmgr_path("remove")
                  unlink(target, recursive = TRUE)

                  卸载成功!

                    yihui

                    今天折腾 tinytex 跟 bookdownplus 模板。大概是有点欠扁,我卸载了 Windows 里的 tinytex 重装 CTeX,并且把 MiKTeX 里的包全部升级,就发现 bookdownplus 所有模板的参考文献引用都成了问号,连 RStudio 的默认 bookdown 模板也是。折腾了两个小时没解决,索性卸载 CTeX 重装,装完不升级,参考文献居然好了!

                    不是说出现问题就升级吗……

                    比较苦闷,我就读了一下是莽撞人就来单挑:还世界一个轻量级 TeXLive,发现两句话,就明白为啥我这么费劲了。第一句话:

                    LaTeX 的安装可以简化是基于一个假设前提的:你不会没事用一些冷门包。

                    为了好玩,我确实在 bookdownplus 里用了很多冷门包,什么画吉他谱的、五线谱的、画中国象棋、国际象棋的.....于是掉进了自己挖的坑里。

                    第二句话:

                    如果用户需要安装包,可以请求在默认安装包中添加这个包(方便后人),或者自己敲一行命令安装,

                    “她”?莫非 tinytex 的初衷为女性用户设计的……

                      dapengde 这个 Windows 下卸载的 APPDATA 问题我昨天已经自己发现并解决了。你重新装一下 R 包 tinytex 即可。

                      你一个浙江大学的中文论文模板 thesis_zju_zh,为何要用到一个德语版的 booktabs 包?真相是世上根本就不存在 booktabs-de 这样一个 LaTeX 包,同名的包只是 booktabs 包的德语文档。正确的用法应该是 \usepackages{booktabs},而不是 \usepackages{booktabs-de}。MiKTeX 在这个问题上作出了很好的误导,它把 booktabs.sty 复制了一份 booktabs-de.sty。深度阅读:

                      所以归根结底,这个锅该 MikTeX 和 thesis_zju_zh LaTeX 模板作者两个人共同来背。

                      dapengde 是有点欠扁,谁叫你不相信我踩过的 LaTeX 坑比你过过的桥都多,还不死心要试一下 CTeX。我对 TinyTeX 有极大的信心,它肯定可以解决多数 LaTeX 安装维护方面的问题,但具体 LaTeX 的用法出错这种问题就不是工具包能解决的问题了,只能谁写的 LaTeX 代码谁自己负责。

                      “你不会没事用一些冷门包”这个假设我需要解释一下:它仅仅指 LaTeX 的安装。也就是,我提供一个默认的小巧安装包,在不额外安装其它包的情况下,应该足够日常使用(但什么是“日常”,各人有个人的习惯,就不好说了)。

                      TinyTeX 第一步是要解决小巧安装的问题,这个问题我认为已经很好解决了,楼上有人为此收拾出十几 G 的硬盘空间,就是我预期的结果。第二步是要解决常见的 LaTeX 错误,最常见的就是缺失包,这个问题我不方便为所有用户解决,但 R Markdown 用户肯定是没问题的,我已经在 rmarkdown 库的 feature/tinytex 分支中解决了。只要安装这个分支,一旦检测到缺失包,就会自动安装。所以就算你用冷门包,也没关系,只要这个包在 CTAN 上能找到,就任你用。

                      至于“她”,只不过是我三天两头同时打两个性别的 TA 字以及打烦了,总是“他/她”、“he/she”一起;干脆只写后一个算了,反正男性不会介意。如果只写男他,我怕惹上政治正确的麻烦以及招惹女权主义者。

                        yihui 唉,白天不懂夜的黑,你是不懂一个半吊子 latex 用户的辛酸。比如,一个不成熟的 latex 模板,以前明明在 CTeX 下编译没问题,现在在测试版的 tinytex 下出问题,那么到底是出在测试版 tinytex 的兼容性呢,还是 CTeX ,还是模板本身?就像我现在这样。我身边又没有个专家能张嘴就问的。只能自己磕磕碰碰去试,装回 CTeX,先固定一个维度,才有可能找到问题的根源。事实上,tinytex 给我最大的惊喜是在 Ubuntu 上轻松安装通过了——此前我的 Ubuntu 装 LaTeX 就一直没成功过。现在终于可以在 Ubuntu下测试 bookdownplus 的模板了。

                        那个 MiKTeX 包全部升级后导致 RStudio 的默认 bookdown 模板引用文献都成了问号的事儿,可能得留意一下。感觉这些宏包的管理是个灾难。鬼知道 bookdown 的用户电脑上装了哪些宏包,都是什么版本,哪些 latex 模板能直接用,哪次升级又突然不能用了。前不久,不知道哪个升级,你的那个中文 bookdown 模板的段首空两格突然没了,还得自己往模板里加一条。今天,重装 CTeX 不知是哪个问题,导致 bookdown.org 上那本 Lokal lagring og bruk av sensitive data 的源代码突然编译失败了。以后真不知道会有多少这种问题。看来这事儿就得指望 tiny 了。要不然我就对 bookdownplus 模板的维护绝望了。

                        再说“她”,我特意查了新华字典,明明“他”字就是第三人称泛指,不分性别,是人字旁又不是男字旁,什么时候出现他/她或者 TA 这种怪风气的……

                          dapengde 吼住,这是黎明前的黑暗。

                          参考文献变成问号表明后台 LaTeX 引擎编译次数不够多,或者 bibtex 命令失败了。这两个问题都是 tinytex::latexmk() 要解决的问题。如果解决不了,那就是 tinytex 的缺陷,只要你把 LaTeX 日志文件给我看看,应该能找出办法。在这个测试中,LaTeX 错误日志对我最有用。

                          我用“她”字是受英语写作的影响。其实你说的对,中文中“他”是可以泛指的。

                            yufree 最后一个的错误应该是由于 rjournal_article() 格式调用了不智能的 tools::texi2pdf() 而不是智能的 tinytex::pdflatex()。其它几个的原因类似,需要安装 devtools::install_github(('rstudio/rmarkdown@feature/tinytex'))

                              yihui 嗯,最后那个估计得更新 rticles 包的模版,不过装了最新分支后这四个模版还是报错,这次我还是直接贴 tex 那边的错误日志吧,感觉并不是找不到包,还是字体问题(asa、jss模版)还有包的依赖问题(pnas模版)

                              额...错误日志内容过大,我把他们扔这里了,tex里的各式花样深坑实在太多了...

                                yihui 参考文献变问号的问题跟 tinytex 没啥关系。我重新描述一下问题:Windows 7 下装了 CTeX,用 RStudio 新建 bookdown 项目得到的 Mini 模板,编译得到的 pdf 里参考文献都是问号。

                                我看了一下中间生成的 bbl 文件,里面的项目是空的。经过了多次重装和升级 CTeX 和 bibtex 未果,即将放弃的时候,我发现了一条警告信息,说“I cann't find book.bib.bib”!不知道这条工具链中间哪个货为 book.bib 又增添了个扩展名!

                                这就好办了。把 Mini 模板 index.Rmd 里 yaml 声明里的文献库文件扩展名 '.bib' 去掉,就好了!

                                奇怪,我记得以前在yaml 声明里 '.bib' 这个扩展名是可有可无的呀。莫非哪里升级了?

                                  yufree

                                  字体问题大概是这样,需要改 latex.R

                                  r = c(
                                      ".*! Font [^=]+=([^ ]+).+ not loadable.*",
                                      '.*! The font "([^"]+)" cannot be found.*',
                                      ".*! LaTeX Error: File `([^']+)' not found.*",
                                      '.*the language definition file ([^ ]+) .*',
                                      '.* \\(file ([^)]+)\\): cannot open .*',
                                      ".*! CTeX fontset `([^']+)' is unavailable.*",
                                      ".*: ([^:]+): command not found.*"
                                    )

                                  去适配这样的错误信息

                                  !pdfTeX error: pdflatex (file tcrm1095): Font tcrm1095 at 600 not found

                                  我猜测是后面那个 at 600 搞出得问题

                                  包依赖的关键错误信息是这个

                                  Package widetext error: Install the flushend package which is a part of sttools
                                   bundle. Available from CTAN.

                                  也需要修改正则表达适配,不过我的正则表达水平属于小学生入门,怕又引入新问题就不pr了…

                                  yufree 很好,谢谢!前三个的问题现在最新的 tinytex 包应该自动解决了。asa 和 jss 的问题都容易解决;pnas 那个问题是在是很恶心,最讨厌这种不按正常方式出牌的包了。一般情况下 LaTeX 错误消息都以感叹号开头,它偏偏自己写一个错误消息,这还不是最讨厌的,真正讨厌的是为什么不用正常方式声明依赖(即依赖 sttools,而是直接用 sttools 里面的一个样式文件)。

                                    dapengde 这个的确是我前段时间在 rmarkdown 中修改过的,如果你用最新版的 rmarkdown,应该是不会出问题的,因为我对这个问题专门打了补丁:https://github.com/rstudio/rmarkdown/commit/1a0db722 但还是存在出问题的可能,就是你不幸安装了 latexmk 包(LaTeX 包)。不要装这个包。 latexmk 包不如 tinytex::latexmk() 这个模拟函数聪明,貌似它的作者并不在意这个 .bib 扩展名的大坑。