Tinytex: Mac 下 Knit 含中文字符 RMarkdown 文件失败

Created on 17 Aug 2018  ·  8Comments  ·  Source: yihui/tinytex

辉大:

您好,我遇到了下面的问题,瞎捣鼓一气,木有搞定。还请赐教~

背景

前提

  • 曾经装过 MacTeX 全家桶,后按照Uninstalling卸载删除,除最后一步Uninstalling Ghostscript未操作;
  • Rstudio 中 tinytex::install_tinytex(),且tinytex:::is_tinytex()TRUE

遭遇问题的步骤复述

  • 新建 Rmd 文件 test_tt.Rmd,选择输出格式为 pdf;
  • Knit 示例模版,编译正常;
  • 在 test_tt.Rmd 文本部分键入“啊啊”;
  • Knit to HTML、Word 均正常;
  • Knit test_tt.Rmd,编译失败。输出如下:
processing file: test_tt.Rmd
List of 1
 $ include: logi FALSE

  |............................                                     |  43%
  ordinary text without R code

  |.....................................                            |  57%
label: cars
  |..............................................                   |  71%
  ordinary text without R code

  |........................................................         |  86%
label: pressure (with options)
List of 1
 $ echo: logi FALSE

  |.................................................................| 100%
  ordinary text without R code


/usr/local/bin/pandoc +RTS -K512m -RTS test_tt.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output test_tt.tex --template /Users/roududu/RAditonalPackages/rmarkdown/rmd/latex/default-1.17.0.2.tex --highlight-style tango --pdf-engine pdflatex --variable graphics=yes --variable 'geometry:margin=1in' --variable 'compact-title:yes'
output file: test_tt.knit.md

! Package inputenc Error: Unicode character 啊 (U+554A)
(inputenc)                not set up for use with LaTeX.

Error: Failed to compile test_tt.tex. See test_tt.log for more info.
Execution halted

R 会话及设备信息

R version 3.5.1 (2018-07-02)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.6

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] tinytex_0.6

loaded via a namespace (and not attached):
[1] compiler_3.5.1 tools_3.5.1    yaml_2.2.0     xfun_0.3  
  • 查 test_tt.log 内容如下:
This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2018) (preloaded format=pdflatex 2018.8.17)  17 AUG 2018 16:40
entering extended mode
 restricted \write18 enabled.
 %&-line parsing enabled.
**test_tt.tex
(./test_tt.tex
LaTeX2e <2018-04-01> patch level 5
(/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/base/size10.clo
File: size10.clo 2014/09/29 v1.4h Standard LaTeX file (size option)
)
\c@part=\count80
\c@section=\count81
\c@subsection=\count82
\c@subsubsection=\count83
\c@paragraph=\count84
\c@subparagraph=\count85
\c@figure=\count86
\c@table=\count87
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\bibindent=\dimen102
) (/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/lm/lmodern.sty
Package: lmodern 2009/10/30 v1.6 Latin Modern Fonts
LaTeX Font Info:    Overwriting symbol font `operators' in version `normal'
(Font)                  OT1/cmr/m/n --> OT1/lmr/m/n on input line 22.
LaTeX Font Info:    Overwriting symbol font `letters' in version `normal'
(Font)                  OML/cmm/m/it --> OML/lmm/m/it on input line 23.
LaTeX Font Info:    Overwriting symbol font `symbols' in version `normal'
(Font)                  OMS/cmsy/m/n --> OMS/lmsy/m/n on input line 24.
LaTeX Font Info:    Overwriting symbol font `largesymbols' in version `normal'
(Font)                  OMX/cmex/m/n --> OMX/lmex/m/n on input line 25.
LaTeX Font Info:    Overwriting symbol font `operators' in version `bold'
(Font)                  OT1/cmr/bx/n --> OT1/lmr/bx/n on input line 26.
LaTeX Font Info:    Overwriting symbol font `letters' in version `bold'
(Font)                  OML/cmm/b/it --> OML/lmm/b/it on input line 27.
LaTeX Font Info:    Overwriting symbol font `symbols' in version `bold'
(Font)                  OMS/cmsy/b/n --> OMS/lmsy/b/n on input line 28.
LaTeX Font Info:    Overwriting symbol font `largesymbols' in version `bold'
(Font)                  OMX/cmex/m/n --> OMX/lmex/m/n on input line 29.
LaTeX Font Info:    Overwriting math alphabet `\mathbf' in version `normal'
(Font)                  OT1/cmr/bx/n --> OT1/lmr/bx/n on input line 31.
LaTeX Font Info:    Overwriting math alphabet `\mathsf' in version `normal'
(Font)                  OT1/cmss/m/n --> OT1/lmss/m/n on input line 32.
LaTeX Font Info:    Overwriting math alphabet `\mathit' in version `normal'
(Font)                  OT1/cmr/m/it --> OT1/lmr/m/it on input line 33.
LaTeX Font Info:    Overwriting math alphabet `\mathtt' in version `normal'
(Font)                  OT1/cmtt/m/n --> OT1/lmtt/m/n on input line 34.
LaTeX Font Info:    Overwriting math alphabet `\mathbf' in version `bold'
(Font)                  OT1/cmr/bx/n --> OT1/lmr/bx/n on input line 35.
LaTeX Font Info:    Overwriting math alphabet `\mathsf' in version `bold'
(Font)                  OT1/cmss/bx/n --> OT1/lmss/bx/n on input line 36.
LaTeX Font Info:    Overwriting math alphabet `\mathit' in version `bold'
(Font)                  OT1/cmr/bx/it --> OT1/lmr/bx/it on input line 37.
LaTeX Font Info:    Overwriting math alphabet `\mathtt' in version `bold'
(Font)                  OT1/cmtt/m/n --> OT1/lmtt/m/n on input line 38.
) (/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/amsfonts/amssymb.sty
Package: amssymb 2013/01/14 v3.01 AMS font symbols
(/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/amsfonts/amsfonts.sty
Package: amsfonts 2013/01/14 v3.01 Basic AMSFonts support
\@emptytoks=\toks14
\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/roududu/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/roududu/Library/TinyTeX/texmf-dist/tex/latex/amsmath/amstext.sty
Package: amstext 2000/06/29 v2.01 AMS text
(/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/amsmath/amsgen.sty
File: amsgen.sty 1999/11/30 v2.0 generic functions
\@emptytoks=\toks15
\ex@=\dimen103
)) (/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/amsmath/amsbsy.sty
Package: amsbsy 1999/11/29 v1.2d Bold Symbols
\pmbraise@=\dimen104
) (/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/amsmath/amsopn.sty
Package: amsopn 2016/03/08 v2.02 operator names
)
\inf@bad=\count88
LaTeX Info: Redefining \frac on input line 213.
\uproot@=\count89
\leftroot@=\count90
LaTeX Info: Redefining \overline on input line 375.
\classnum@=\count91
\DOTSCASE@=\count92
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=\dimen105
LaTeX Font Info:    Redeclaring font encoding OML on input line 712.
LaTeX Font Info:    Redeclaring font encoding OMS on input line 713.
\macc@depth=\count93
\c@MaxMatrixCols=\count94
\dotsspace@=\muskip10
\c@parentequation=\count95
\dspbrk@lvl=\count96
\tag@help=\toks16
\row@=\count97
\column@=\count98
\maxfields@=\count99
\andhelp@=\toks17
\eqnshift@=\dimen106
\alignsep@=\dimen107
\tagshift@=\dimen108
\tagwidth@=\dimen109
\totwidth@=\dimen110
\lineht@=\dimen111
\@envbody=\toks18
\multlinegap=\skip44
\multlinetaggap=\skip45
\mathdisplay@stack=\toks19
LaTeX Info: Redefining \[ on input line 2817.
LaTeX Info: Redefining \] on input line 2818.
) (/Users/roududu/Library/TinyTeX/texmf-dist/tex/generic/ifxetex/ifxetex.sty
Package: ifxetex 2010/09/12 v0.6 Provides ifxetex conditional
) (/Users/roududu/Library/TinyTeX/texmf-dist/tex/generic/oberdiek/ifluatex.sty
Package: ifluatex 2016/05/16 v1.4 Provides the ifluatex switch (HO)
Package ifluatex Info: LuaTeX not detected.
) (/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/base/fixltx2e.sty
Package: fixltx2e 2016/12/29 v2.1a fixes to LaTeX (obsolete)
Applying: [2015/01/01] Old fixltx2e package on input line 46.

Package fixltx2e Warning: fixltx2e is not required with releases after 2015
(fixltx2e)                All fixes are now in the LaTeX kernel.
(fixltx2e)                See the latexrelease package for details.

Already applied: [0000/00/00] Old fixltx2e package on input line 53.
) (/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/base/fontenc.sty
Package: fontenc 2017/04/05 v2.0i Standard LaTeX package
(/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/base/t1enc.def
File: t1enc.def 2017/04/05 v2.0i Standard LaTeX file
LaTeX Font Info:    Redeclaring font encoding T1 on input line 48.
)) (/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/base/inputenc.sty
Package: inputenc 2018/04/06 v1.3b Input encoding file
\inpenc@prehook=\toks20
\inpenc@posthook=\toks21
) (/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/upquote/upquote.sty
Package: upquote 2012/04/19 v1.3 upright-quote and grave-accent glyphs in verba
tim
(/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/base/textcomp.sty
Package: textcomp 2017/04/05 v2.0i Standard LaTeX package
Package textcomp Info: Sub-encoding information:
(textcomp)               5 = only ISO-Adobe without \textcurrency
(textcomp)               4 = 5 + \texteuro
(textcomp)               3 = 4 + \textohm
(textcomp)               2 = 3 + \textestimated + \textcurrency
(textcomp)               1 = TS1 - \textcircled - \t
(textcomp)               0 = TS1 (full)
(textcomp)             Font families with sub-encoding setting implement
(textcomp)             only a restricted character set as indicated.
(textcomp)             Family '?' is the default used for unknown fonts.
(textcomp)             See the documentation for details.
Package textcomp Info: Setting ? sub-encoding to TS1/1 on input line 79.
(/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/base/ts1enc.def
File: ts1enc.def 2001/06/05 v3.0e (jk/car/fm) Standard LaTeX file
Now handling font encoding TS1 ...
... processing UTF-8 mapping file for font encoding TS1
(/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/base/ts1enc.dfu
File: ts1enc.dfu 2018/04/05 v1.2c UTF-8 support for inputenc
   defining Unicode char U+00A2 (decimal 162)
   defining Unicode char U+00A3 (decimal 163)
   defining Unicode char U+00A4 (decimal 164)
   defining Unicode char U+00A5 (decimal 165)
   defining Unicode char U+00A6 (decimal 166)
   defining Unicode char U+00A7 (decimal 167)
   defining Unicode char U+00A8 (decimal 168)
   defining Unicode char U+00A9 (decimal 169)
   defining Unicode char U+00AA (decimal 170)
   defining Unicode char U+00AC (decimal 172)
   defining Unicode char U+00AE (decimal 174)
   defining Unicode char U+00AF (decimal 175)
   defining Unicode char U+00B0 (decimal 176)
   defining Unicode char U+00B1 (decimal 177)
   defining Unicode char U+00B2 (decimal 178)
   defining Unicode char U+00B3 (decimal 179)
   defining Unicode char U+00B4 (decimal 180)
   defining Unicode char U+00B5 (decimal 181)
   defining Unicode char U+00B6 (decimal 182)
   defining Unicode char U+00B7 (decimal 183)
   defining Unicode char U+00B9 (decimal 185)
   defining Unicode char U+00BA (decimal 186)
   defining Unicode char U+00BC (decimal 188)
   defining Unicode char U+00BD (decimal 189)
   defining Unicode char U+00BE (decimal 190)
   defining Unicode char U+00D7 (decimal 215)
   defining Unicode char U+00F7 (decimal 247)
   defining Unicode char U+0192 (decimal 402)
   defining Unicode char U+02C7 (decimal 711)
   defining Unicode char U+02D8 (decimal 728)
   defining Unicode char U+02DD (decimal 733)
   defining Unicode char U+0E3F (decimal 3647)
   defining Unicode char U+2016 (decimal 8214)
   defining Unicode char U+2020 (decimal 8224)
   defining Unicode char U+2021 (decimal 8225)
   defining Unicode char U+2022 (decimal 8226)
   defining Unicode char U+2030 (decimal 8240)
   defining Unicode char U+2031 (decimal 8241)
   defining Unicode char U+203B (decimal 8251)
   defining Unicode char U+203D (decimal 8253)
   defining Unicode char U+2044 (decimal 8260)
   defining Unicode char U+204E (decimal 8270)
   defining Unicode char U+2052 (decimal 8274)
   defining Unicode char U+20A1 (decimal 8353)
   defining Unicode char U+20A4 (decimal 8356)
   defining Unicode char U+20A6 (decimal 8358)
   defining Unicode char U+20A9 (decimal 8361)
   defining Unicode char U+20AB (decimal 8363)
   defining Unicode char U+20AC (decimal 8364)
   defining Unicode char U+20B1 (decimal 8369)
   defining Unicode char U+2103 (decimal 8451)
   defining Unicode char U+2116 (decimal 8470)
   defining Unicode char U+2117 (decimal 8471)
   defining Unicode char U+211E (decimal 8478)
   defining Unicode char U+2120 (decimal 8480)
   defining Unicode char U+2122 (decimal 8482)
   defining Unicode char U+2126 (decimal 8486)
   defining Unicode char U+2127 (decimal 8487)
   defining Unicode char U+212E (decimal 8494)
   defining Unicode char U+2190 (decimal 8592)
   defining Unicode char U+2191 (decimal 8593)
   defining Unicode char U+2192 (decimal 8594)
   defining Unicode char U+2193 (decimal 8595)
   defining Unicode char U+2329 (decimal 9001)
   defining Unicode char U+232A (decimal 9002)
   defining Unicode char U+2422 (decimal 9250)
   defining Unicode char U+25E6 (decimal 9702)
   defining Unicode char U+25EF (decimal 9711)
   defining Unicode char U+266A (decimal 9834)
   defining Unicode char U+FEFF (decimal 65279)
))
LaTeX Info: Redefining \oldstylenums on input line 334.
Package textcomp Info: Setting cmr sub-encoding to TS1/0 on input line 349.
Package textcomp Info: Setting cmss sub-encoding to TS1/0 on input line 350.
Package textcomp Info: Setting cmtt sub-encoding to TS1/0 on input line 351.
Package textcomp Info: Setting cmvtt sub-encoding to TS1/0 on input line 352.
Package textcomp Info: Setting cmbr sub-encoding to TS1/0 on input line 353.
Package textcomp Info: Setting cmtl sub-encoding to TS1/0 on input line 354.
Package textcomp Info: Setting ccr sub-encoding to TS1/0 on input line 355.
Package textcomp Info: Setting ptm sub-encoding to TS1/4 on input line 356.
Package textcomp Info: Setting pcr sub-encoding to TS1/4 on input line 357.
Package textcomp Info: Setting phv sub-encoding to TS1/4 on input line 358.
Package textcomp Info: Setting ppl sub-encoding to TS1/3 on input line 359.
Package textcomp Info: Setting pag sub-encoding to TS1/4 on input line 360.
Package textcomp Info: Setting pbk sub-encoding to TS1/4 on input line 361.
Package textcomp Info: Setting pnc sub-encoding to TS1/4 on input line 362.
Package textcomp Info: Setting pzc sub-encoding to TS1/4 on input line 363.
Package textcomp Info: Setting bch sub-encoding to TS1/4 on input line 364.
Package textcomp Info: Setting put sub-encoding to TS1/5 on input line 365.
Package textcomp Info: Setting uag sub-encoding to TS1/5 on input line 366.
Package textcomp Info: Setting ugq sub-encoding to TS1/5 on input line 367.
Package textcomp Info: Setting ul8 sub-encoding to TS1/4 on input line 368.
Package textcomp Info: Setting ul9 sub-encoding to TS1/4 on input line 369.
Package textcomp Info: Setting augie sub-encoding to TS1/5 on input line 370.
Package textcomp Info: Setting dayrom sub-encoding to TS1/3 on input line 371.
Package textcomp Info: Setting dayroms sub-encoding to TS1/3 on input line 372.

Package textcomp Info: Setting pxr sub-encoding to TS1/0 on input line 373.
Package textcomp Info: Setting pxss sub-encoding to TS1/0 on input line 374.
Package textcomp Info: Setting pxtt sub-encoding to TS1/0 on input line 375.
Package textcomp Info: Setting txr sub-encoding to TS1/0 on input line 376.
Package textcomp Info: Setting txss sub-encoding to TS1/0 on input line 377.
Package textcomp Info: Setting txtt sub-encoding to TS1/0 on input line 378.
Package textcomp Info: Setting lmr sub-encoding to TS1/0 on input line 379.
Package textcomp Info: Setting lmdh sub-encoding to TS1/0 on input line 380.
Package textcomp Info: Setting lmss sub-encoding to TS1/0 on input line 381.
Package textcomp Info: Setting lmssq sub-encoding to TS1/0 on input line 382.
Package textcomp Info: Setting lmvtt sub-encoding to TS1/0 on input line 383.
Package textcomp Info: Setting lmtt sub-encoding to TS1/0 on input line 384.
Package textcomp Info: Setting qhv sub-encoding to TS1/0 on input line 385.
Package textcomp Info: Setting qag sub-encoding to TS1/0 on input line 386.
Package textcomp Info: Setting qbk sub-encoding to TS1/0 on input line 387.
Package textcomp Info: Setting qcr sub-encoding to TS1/0 on input line 388.
Package textcomp Info: Setting qcs sub-encoding to TS1/0 on input line 389.
Package textcomp Info: Setting qpl sub-encoding to TS1/0 on input line 390.
Package textcomp Info: Setting qtm sub-encoding to TS1/0 on input line 391.
Package textcomp Info: Setting qzc sub-encoding to TS1/0 on input line 392.
Package textcomp Info: Setting qhvc sub-encoding to TS1/0 on input line 393.
Package textcomp Info: Setting futs sub-encoding to TS1/4 on input line 394.
Package textcomp Info: Setting futx sub-encoding to TS1/4 on input line 395.
Package textcomp Info: Setting futj sub-encoding to TS1/4 on input line 396.
Package textcomp Info: Setting hlh sub-encoding to TS1/3 on input line 397.
Package textcomp Info: Setting hls sub-encoding to TS1/3 on input line 398.
Package textcomp Info: Setting hlst sub-encoding to TS1/3 on input line 399.
Package textcomp Info: Setting hlct sub-encoding to TS1/5 on input line 400.
Package textcomp Info: Setting hlx sub-encoding to TS1/5 on input line 401.
Package textcomp Info: Setting hlce sub-encoding to TS1/5 on input line 402.
Package textcomp Info: Setting hlcn sub-encoding to TS1/5 on input line 403.
Package textcomp Info: Setting hlcw sub-encoding to TS1/5 on input line 404.
Package textcomp Info: Setting hlcf sub-encoding to TS1/5 on input line 405.
Package textcomp Info: Setting pplx sub-encoding to TS1/3 on input line 406.
Package textcomp Info: Setting pplj sub-encoding to TS1/3 on input line 407.
Package textcomp Info: Setting ptmx sub-encoding to TS1/4 on input line 408.
Package textcomp Info: Setting ptmj sub-encoding to TS1/4 on input line 409.
)) (/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/geometry/geometry.sty
Package: geometry 2018/04/16 v5.8 Page Geometry
(/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/graphics/keyval.sty
Package: keyval 2014/10/28 v1.15 key=value parser (DPC)
\KV@toks@=\toks22
) (/Users/roududu/Library/TinyTeX/texmf-dist/tex/generic/oberdiek/ifpdf.sty
Package: ifpdf 2017/03/15 v3.2 Provides the ifpdf switch
) (/Users/roududu/Library/TinyTeX/texmf-dist/tex/generic/oberdiek/ifvtex.sty
Package: ifvtex 2016/05/16 v1.6 Detect VTeX and its facilities (HO)
Package ifvtex Info: VTeX not detected.
)
\Gm@cnth=\count100
\Gm@cntv=\count101
\c@Gm@tempcnt=\count102
\Gm@bindingoffset=\dimen112
\Gm@wd@mp=\dimen113
\Gm@odd@mp=\dimen114
\Gm@even@mp=\dimen115
\Gm@layoutwidth=\dimen116
\Gm@layoutheight=\dimen117
\Gm@layouthoffset=\dimen118
\Gm@layoutvoffset=\dimen119
\Gm@dimlist=\toks23
) (/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/hyperref/hyperref.sty
Package: hyperref 2018/02/06 v6.86b Hypertext links for LaTeX

(/Users/roududu/Library/TinyTeX/texmf-dist/tex/generic/oberdiek/hobsub-hyperref
.sty
Package: hobsub-hyperref 2016/05/16 v1.14 Bundle oberdiek, subset hyperref (HO)


(/Users/roududu/Library/TinyTeX/texmf-dist/tex/generic/oberdiek/hobsub-generic.
sty
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 hobsub Info: Skipping package `ifluatex' (already loaded).
Package hobsub Info: Skipping package `ifvtex' (already loaded).
Package: intcalc 2016/05/16 v1.2 Expandable calculations with integers (HO)
Package hobsub Info: Skipping package `ifpdf' (already loaded).
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 2018/01/30 v0.27 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/roududu/Library/TinyTeX/texmf-dist/tex/latex/oberdiek/auxhook.sty
Package: auxhook 2016/05/16 v1.4 Hooks for auxiliary files (HO)
) (/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/oberdiek/kvoptions.sty
Package: kvoptions 2016/05/16 v3.12 Key value format for package options (HO)
)
\@linkdim=\dimen120
\Hy@linkcounter=\count103
\Hy@pagecounter=\count104
(/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/hyperref/pd1enc.def
File: pd1enc.def 2018/02/06 v6.86b Hyperref: PDFDocEncoding definition (HO)
Now handling font encoding PD1 ...
... no UTF-8 mapping file for font encoding PD1
)
\Hy@SavedSpaceFactor=\count105
(/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/latexconfig/hyperref.cfg
File: hyperref.cfg 2002/06/06 v1.2 hyperref configuration of TeXLive
)
Package hyperref Info: Hyper figures OFF on input line 4509.
Package hyperref Info: Link nesting OFF on input line 4514.
Package hyperref Info: Hyper index ON on input line 4517.
Package hyperref Info: Plain pages OFF on input line 4524.
Package hyperref Info: Backreferencing OFF on input line 4529.
Package hyperref Info: Implicit mode ON; LaTeX internals redefined.
Package hyperref Info: Bookmarks ON on input line 4762.
\c@Hy@tempcnt=\count106
(/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/url/url.sty
\Urlmuskip=\muskip11
Package: url 2013/09/16  ver 3.4  Verb mode for urls, etc.
)
LaTeX Info: Redefining \url on input line 5115.
\XeTeXLinkMargin=\dimen121
\Fld@menulength=\count107
\Field@Width=\dimen122
\Fld@charsize=\dimen123
Package hyperref Info: Hyper figures OFF on input line 6369.
Package hyperref Info: Link nesting OFF on input line 6374.
Package hyperref Info: Hyper index ON on input line 6377.
Package hyperref Info: backreferencing OFF on input line 6384.
Package hyperref Info: Link coloring OFF on input line 6389.
Package hyperref Info: Link coloring with OCG OFF on input line 6394.
Package hyperref Info: PDF/A mode OFF on input line 6399.
LaTeX Info: Redefining \ref on input line 6439.
LaTeX Info: Redefining \pageref on input line 6443.
\Hy@abspage=\count108
\c@Item=\count109
\c@Hfootnote=\count110
)
Package hyperref Info: Driver (autodetected): hpdftex.
(/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/hyperref/hpdftex.def
File: hpdftex.def 2018/02/06 v6.86b Hyperref driver for pdfTeX
\Fld@listcount=\count111
\c@bookmark@seq@number=\count112

(/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/oberdiek/rerunfilecheck.st
y
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=\skip46
)
Package hyperref Info: Option `unicode' set `true' on input line 30.
(/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/hyperref/puenc.def
File: puenc.def 2018/02/06 v6.86b Hyperref: PDF Unicode definition (HO)
Now handling font encoding PU ...
... no UTF-8 mapping file for font encoding PU
)
Package hyperref Info: Option `breaklinks' set `true' on input line 30.
(/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/graphics/color.sty
Package: color 2016/07/10 v1.1e Standard LaTeX Color (DPC)
(/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/graphics-cfg/color.cfg
File: color.cfg 2016/01/02 v1.6 sample color configuration
)
Package color Info: Driver file: pdftex.def on input line 147.
(/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/graphics-def/pdftex.def
File: pdftex.def 2018/01/08 v1.0l Graphics/color driver for pdftex
)) (/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/fancyvrb/fancyvrb.sty
Package: fancyvrb 2008/02/07

Style option: `fancyvrb' v2.7a, with DG/SPQR fixes, and firstline=lastline fix 
<2008/02/07> (tvz)
\FV@CodeLineNo=\count113
\FV@InFile=\read1
\FV@TabBox=\box28
\c@FancyVerbLine=\count114
\FV@StepNumber=\count115
\FV@OutFile=\write3
) (/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/framed/framed.sty
Package: framed 2011/10/22 v 0.96: framed or shaded text with page breaks
\OuterFrameSep=\skip47
\fb@frw=\dimen124
\fb@frh=\dimen125
\FrameRule=\dimen126
\FrameSep=\dimen127
) (/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/graphics/graphicx.sty
Package: graphicx 2017/06/01 v1.1a Enhanced LaTeX Graphics (DPC,SPQR)
(/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/graphics/graphics.sty
Package: graphics 2017/06/25 v1.2c Standard LaTeX Graphics (DPC,SPQR)
(/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/graphics/trig.sty
Package: trig 2016/01/03 v1.10 sin cos tan (DPC)
) (/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/graphics-cfg/graphics.cf
g
File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration
)
Package graphics Info: Driver file: pdftex.def on input line 99.
)
\Gin@req@height=\dimen128
\Gin@req@width=\dimen129
) (/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/oberdiek/grffile.sty
Package: grffile 2017/06/30 v1.18 Extended file name support for graphics (HO)
Package grffile Info: Option `multidot' is set to `true'.
Package grffile Info: Option `extendedchars' is set to `false'.
Package grffile Info: Option `space' is set to `true'.
Package grffile Info: \Gin@ii of package `graphicx' fixed on input line 494.
) (/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/titling/titling.sty
Package: titling 2009/09/04 v2.1d maketitle typesetting
\thanksmarkwidth=\skip48
\thanksmargin=\skip49
\droptitle=\skip50
)
No file test_tt.aux.
\openout1 = `test_tt.aux'.

LaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line 128.
LaTeX Font Info:    ... okay on input line 128.
LaTeX Font Info:    Checking defaults for T1/cmr/m/n on input line 128.
LaTeX Font Info:    ... okay on input line 128.
LaTeX Font Info:    Checking defaults for OT1/cmr/m/n on input line 128.
LaTeX Font Info:    ... okay on input line 128.
LaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line 128.
LaTeX Font Info:    ... okay on input line 128.
LaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line 128.
LaTeX Font Info:    ... okay on input line 128.
LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line 128.
LaTeX Font Info:    ... okay on input line 128.
LaTeX Font Info:    Checking defaults for TS1/cmr/m/n on input line 128.
LaTeX Font Info:    Try loading font information for TS1+cmr on input line 128.

(/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/base/ts1cmr.fd
File: ts1cmr.fd 2014/09/29 v2.5h Standard LaTeX font definitions
)
LaTeX Font Info:    ... okay on input line 128.
LaTeX Font Info:    Checking defaults for PD1/pdf/m/n on input line 128.
LaTeX Font Info:    ... okay on input line 128.
LaTeX Font Info:    Checking defaults for PU/pdf/m/n on input line 128.
LaTeX Font Info:    ... okay on input line 128.
LaTeX Font Info:    Try loading font information for T1+lmr on input line 128.
(/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/lm/t1lmr.fd
File: t1lmr.fd 2009/10/30 v1.6 Font defs for Latin Modern
)
*geometry* driver: auto-detecting
*geometry* detected driver: pdftex
*geometry* verbose mode - [ preamble ] result:
* driver: pdftex
* paper: <default>
* layout: <same size as paper>
* layoutoffset:(h,v)=(0.0pt,0.0pt)
* modes: 
* h-part:(L,W,R)=(72.26999pt, 469.75502pt, 72.26999pt)
* v-part:(T,H,B)=(72.26999pt, 650.43001pt, 72.26999pt)
* \paperwidth=614.295pt
* \paperheight=794.96999pt
* \textwidth=469.75502pt
* \textheight=650.43001pt
* \oddsidemargin=0.0pt
* \evensidemargin=0.0pt
* \topmargin=-37.0pt
* \headheight=12.0pt
* \headsep=25.0pt
* \topskip=10.0pt
* \footskip=30.0pt
* \marginparwidth=65.0pt
* \marginparsep=11.0pt
* \columnsep=10.0pt
* \skip\footins=9.0pt plus 4.0pt minus 2.0pt
* \hoffset=0.0pt
* \voffset=0.0pt
* \mag=1000
* \@twocolumnfalse
* \@twosidefalse
* \@mparswitchfalse
* \@reversemarginfalse
* (1in=72.27pt=25.4mm, 1cm=28.453pt)

\AtBeginShipoutBox=\box29
Package hyperref Info: Link coloring OFF on input line 128.
(/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/hyperref/nameref.sty
Package: nameref 2016/05/21 v2.44 Cross-referencing by name of section

(/Users/roududu/Library/TinyTeX/texmf-dist/tex/generic/oberdiek/gettitlestring.
sty
Package: gettitlestring 2016/05/16 v1.5 Cleanup title references (HO)
)
\c@section@level=\count116
)
LaTeX Info: Redefining \ref on input line 128.
LaTeX Info: Redefining \pageref on input line 128.
LaTeX Info: Redefining \nameref on input line 128.
\@outlinefile=\write4
\openout4 = `test_tt.out'.


(/Users/roududu/Library/TinyTeX/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty
Package: epstopdf-base 2016/05/15 v2.6 Base part for package epstopdf
(/Users/roududu/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/roududu/Library/TinyTeX/texmf-dist/tex/latex/latexconfig/epstopdf-sys.c
fg
File: epstopdf-sys.cfg 2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Liv
e
))

! Package inputenc Error: Unicode character 啊 (U+554A)
(inputenc)                not set up for use with LaTeX.

See the inputenc package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.132 ...on{R Markdown 啊啊}\label{r-markdown-}}

Here is how much of TeX's memory you used:
 10464 strings out of 494587
 148147 string characters out of 6176955
 214227 words of memory out of 5000000
 14016 multiletter control sequences out of 15000+600000
 20667 words of font info for 20 fonts, out of 8000000 for 9000
 14 hyphenation exceptions out of 8191
 28i,3n,32p,232b,270s stack positions out of 5000i,500n,10000p,200000b,80000s

!  ==> Fatal error occurred, no output PDF file produced!

我的尝试

  • Google 检索:tinytex ! Package inputenc Error: Unicode character 啊 (U+554A) (inputenc) not set up for use with LaTeX 未发现有效信息;
  • Google 检索 ! Package inputenc Error: Unicode character 啊 (U+554A) (inputenc) not set up for use with LaTeX 未发现直接有效信息;
  • 查阅TinyTeX 完整文档

    • 确定 tinytex:::is_tinytex() 为 TRUE

    • 尝试 tinytex::tlmgr_install('inputenc'),部分输出如下

14 preloaded fonts
warning  (pdf backend): no pages of output.
Transcript written on lualatex.log.
fmtutil [INFO]: /Users/roududu/Library/TinyTeX/texmf-var/web2c/luatex/lualatex.fmt installed.
fmtutil [INFO]: Disabled formats: 1
fmtutil [INFO]: Successfully rebuilt formats: 13
fmtutil [INFO]: Total formats: 14
fmtutil [INFO]: exiting with status 0
tlmgr install inputenc
tlmgr install: package inputenc not present in repository.
tlmgr: action install returned an error; continuing.
tlmgr: package repository http://mirror.lzu.edu.cn/CTAN/systems/texlive/tlnet (not verified: gpg unavailable)
tlmgr: An error has occurred. See above messages. Exiting.
tlmgr path add

Most helpful comment

是也乎,( ̄▽ ̄)

补刀: 提问的典范 - Yihui Xie | 谢益辉

专门点赞了 @tanchangde ,
其实, 正是因为在长期 Python/Pythonic 推广过程中发现,
明明大家在高一就早已完备了足够编程思维的训练,
但是, 却难以自学掌握那怕是 Python 这么简洁的脚本语言,
核心原因, 就是被学校训练的忘记了如何提问,

所以: 蟒营®编程思维提高班Python版
专门设计包含了 永远的: 提问的智慧
相关场景;

从根儿上解决无法自学的问题..

是的, @tanchangde 就是课程助教之一, 当初原型班优秀学员.

All 8 comments

@tanchangde 你把文档开头换成我的试试

---
title: "啊啊"
output: 
  pdf_document: 
    toc: yes
    latex_engine: "xelatex"
    extra_dependencies:
      ctexcap: UTF8
---

嗯,关键就是你得用 xelatex 编译。pdflatex 处理中文不是不可以,但有点困难。xelatex 对多字节字符(尤其是中日韩文)要友好得多得多。

https://github.com/rstudio/rticles/blob/master/inst/rmarkdown/templates/ctex/skeleton/skeleton.Rmd

另外,你这个报告很走心、很详细,值得表扬。

跑通了~

感谢 @XiangyunHuang @yihui 指教,感谢 @yihui 鼓励。
按照两位的指引,跑通了~

请问 @XiangyunHuang,是怎样知道需要加 extra_dependencies 及指定 ctexcap: UTF8 的?
我对上述两个参数在 Google 做了组合检索并去 R Markdown: The Definitive Guide 粗略查看检索了下,没有看到直接介绍~

摸索过程中遇到两个点,在此记录分享下:

YAML doesn't allow tabs,it requires spaces

即 RMarkdown 文档开头的 YAML 元数据不允许用 tab 键缩进,需用空格。
否则将有如下报错:

Error in yaml::yaml.load(string, ...) :
  Scanner error: while scanning a plain scalar at line 4, column 10 found a tab character that violate intendation at line 5, column 1
Calls: <Anonymous> ... parse_yaml_front_matter -> yaml_load_utf8 -> <Anonymous>
Execution halted

编译含多字节字符 Rmd 文件,需在 YAML 元数据中指定 ctexcap

若不进行如下指定,编译仍将通过,且不会报错。但在编译为 PDF 格式后,查看文件,多字节字符内容丢失。

---
title: "test_latex_engine"
output:
  pdf_document:
    latex_engine: xelatex
    extra_dependencies:
      ctexcap: UTF8
---

@tanchangde
pdf_documentrmarkdown 包内的函数, extra_dependencies 就是其中一个参数,你可以输入如下命令,看各参数的详细解释,

?rmarkdown::pdf_document

ctexcap 是处理中文需要加载的 sty 文件,它来自 ctex 这个宏集,在 .tex 文件中常常这样加载 \usepackage[UTF8]{ctexcap}UTF8 是这个宏包的选项

tinytex::tlmgr_search('ctexcap.sty')
tlmgr search --file --global 'ctexcap.sty'
tlmgr: package repository http://mirror.lzu.edu.cn/CTAN/systems/texlive/tlnet (verified)
ctex:
    texmf-dist/tex/latex/ctex/ctexcap.sty

@XiangyunHuang,谢谢您的解答。

在 Google 检索您提及的 extra_dependencies 时,得到一些关于 rmarkdown pdf_document 函数的文档。让我意识到,YAML 元数据其实是在向相应函数提供入参。

根据您的提示,我仔细了看了看 rmarkdown::pdf_documentextra_dependencies 说明。我们采用 YAML 指定包的用法,应适用如下说明:

A LaTeX dependency latex_dependency()...

再查 rmarkdown::latex_dependency 确实如我们上面指定有 LaTeX 包名及选项两个参数。
为此,我放狗搜索了 rmarkdwon yaml load latex package,但提及的加载 LaTex 包形式并不像我们用到的这种。

过程中我的困惑是:

  • 您是怎样知道在 Rmd 文件中编译含中文的文档,需要加载 ctexcap,并指定选项 UTF8

    • 处理 Rmd 文件中中文编译相关的问题,诸如指定字体,还请推荐一些必读背景资料~

  • 您是怎样知道,通过 YAML 对象键值对的形式给 pdf_documentextra_dependencies 提供入参的呢?

@tanchangde 我觉得这两个问题其实已经和 R Markdown 无关了, 编译出 PDF 的最后一步还是用 LaTeX 的,那么 LaTeX 文档里如何处理包含中文及别的多字节字符,这里也一样,只是调用宏包的方式写成了 YAML 的格式,资料的话我觉得再搞下去就是看 LaTeX 文档,如 一份不太简短的 LaTeX 介绍ctex 宏集手册

附中文 R Markdown 模板合集 https://github.com/XiangyunHuang/R-Markdown-Template 免得再去折腾 LaTeX

@XiangyunHuang 感激不尽~🤣

是也乎,( ̄▽ ̄)

补刀: 提问的典范 - Yihui Xie | 谢益辉

专门点赞了 @tanchangde ,
其实, 正是因为在长期 Python/Pythonic 推广过程中发现,
明明大家在高一就早已完备了足够编程思维的训练,
但是, 却难以自学掌握那怕是 Python 这么简洁的脚本语言,
核心原因, 就是被学校训练的忘记了如何提问,

所以: 蟒营®编程思维提高班Python版
专门设计包含了 永远的: 提问的智慧
相关场景;

从根儿上解决无法自学的问题..

是的, @tanchangde 就是课程助教之一, 当初原型班优秀学员.

Was this page helpful?
0 / 5 - 0 ratings