这是一个简单的用 bookdown 写中文书的例子。在使用它之前,建议您至少泛读一遍 bookdown 官方文档。
yihui / bookdown-chinese Goto Github PK
View Code? Open in Web Editor NEWbookdown 中文书籍范例
License: MIT License
bookdown 中文书籍范例
License: MIT License
这是一个简单的用 bookdown 写中文书的例子。在使用它之前,建议您至少泛读一遍 bookdown 官方文档。
因为我的文档几乎每个小标题都是存在一样的英文单词,且与中文混在一起,形如:
我喜欢
1.1 我喜欢YH
1.2 我超爱YH
不喜欢我
2.1 YH不喜欢我
2.2 YH超不爱我
这样的标题。编译出来后,后面的每个小标题跳转都会到 1.1 中,因为1.1是第一个编译出“#-YH-”来的。在后面加{#a}
这样的符号又没有用,会显示出来。
因为自己太笨,也没找到别人快速的方法。最后,我试了个很笨的解决方法,就是在每个出错小标题后面加上看起来字体透明的样式:<font color=#fff> a </font>
。形如:
我喜欢
1.1 我喜欢YH <font color=#fff> a </font>
1.2 我超爱YH<font color=#fff> b </font>
不喜欢我
2.1 YH不喜欢我<font color=#fff> c </font>
2.2 YH超不爱我<font color=#fff> d </font>
这样在网页上看不到这些字符,又能实现正确的跳转了。
当然也希望大佬能给个更加智能的解决方案,感谢~
build book 之后,生成的网页效果很好,但是生成的pdf中没有中文,有英文 和 公式,原本中文的地方是空白。
代码未进行任何修改,输出gitbook格式报错。
bookdown::render_book("index.Rmd", "bookdown::gitbook")
"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS bookdown.utf8.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash+smart --output bookdown.html --email-obfuscation none --wrap preserve --standalone --section-divs --table-of-contents --toc-depth 3 --template "D:\Documents\R\win-library\3.6\bookdown\templates\gitbook.html" --highlight-style pygments --number-sections --css "css\style.css" --include-in-header "C:\Users\kongdd\AppData\Local\Temp\Rtmp4SiaCn\rmarkdown-str44a01c37660b.html" --mathjax --lua-filter "D:/Documents/R/win-library/3.6/rmarkdown/rmd/lua/pagebreak.lua" --lua-filter "D:/Documents/R/win-library/3.6/rmarkdown/rmd/lua/latex-div.lua" --filter "C:/Program Files/RStudio/bin/pandoc/pandoc-citeproc.exe"
Error in file.exists(f) : 转换文件名时出了问题--名字太长了?
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)
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
在RStudio上构建时,由pandoc 生成html时,参数里有 --toc-depth 3, 能否指定为更多
"D:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS toturial.utf8.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash+smart --output toturial.html --email-obfuscation none --wrap preserve --standalone --section-divs --table-of-contents --toc-depth 3 --template "D:\PROGRA~1\R\R-36~1.1\library\bookdown\TEMPLA~1\GITBOO~1.HTM" --highlight-style pygments --number-sections --css style.css --include-in-header "C:\Users\ADMINI~1\AppData\Local\Temp\Rtmpcj7dNP\rmarkdown-str1b943c595493.html" --mathjax --lua-filter "D:/Program Files/R/R-3.6.1/library/rmarkdown/rmd/lua/pagebreak.lua" --lua-filter "D:/Program Files/R/R-3.6.1/library/rmarkdown/rmd/lua/latex-div.lua" --filter "D:/Program Files/RStudio/bin/pandoc/pandoc-citeproc.exe"
For example, I need to generate a table like this:
In the top right, I'd like to insert a photo. Is it possible that I can do this using htmlTable. I saw your post. But the problem is the table I'd like to generate needs row span.
Can you help me on this? Thanks.
默认情况下,Build Book 会产生下面的错误:
将 .rprofile
文件改成下面这样的:
if (.Platform$OS.type == 'windows') Sys.setlocale(locale = 'English')
则可以成功 Build。
但这时,书本中的内容包括 Figure/Table 的 caption 显示不正常。
我的 RStudio 是 1.2.5033。
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)
Matrix products: default
locale:
[1] LC_COLLATE=Chinese (Simplified)_China.936 LC_CTYPE=Chinese (Simplified)_China.936
[3] LC_MONETARY=Chinese (Simplified)_China.936 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.6.1 bookdown_0.16.3 rsconnect_0.8.15 htmltools_0.4.0 tools_3.6.1 yaml_2.2.0
[7] Rcpp_1.0.3 rmarkdown_1.17 knitr_1.26 xfun_0.11 digest_0.6.22 packrat_0.5.0
[13] rlang_0.4.1 evaluate_0.14
请问此报错信息可能是什么原因造成的,应该如何解决?
Repository见链接:https://github.com/xie186/DataScienceForLifeScience_cn/tree/4dfcb4d541a1fec2e59cae2834249f019754c154
下面是报错信息:
This is XeTeX, Version 3.1415926-2.5-0.9999.3 (TeX Live 2013)
restricted \write18 enabled.
entering extended mode
! LaTeX Error: File `ctexbook.cls' not found.
! Emergency stop.
<read *>
版本信息如下:
sessionInfo()
R version 3.3.3 (2017-03-06)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)
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=en_US.UTF-8
[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
other attached packages:
[1] bookdown_0.5
loaded via a namespace (and not attached):
[1] backports_1.1.1 magrittr_1.5 rprojroot_1.2 htmltools_0.3.6 tools_3.3.3 yaml_2.1.14
[7] Rcpp_0.12.13 stringi_1.1.5 rmarkdown_1.6 knitr_1.17 stringr_1.2.0 digest_0.6.12
[13] evaluate_0.10.1
不太懂latex
就是让1.1,1.2这级标题左对齐,现在默认是居中的。
修改template.tex中的哪部分
I replaced the .rmd files with my own files which contain no r trunks.While I try to build the book, gitbook(html) is ok, but pdf will report an error.
! LaTeX Error: Environment Shaded undefined.
Error: Failed to compile bookdown.tex. See bookdown.log for more info.
In addition: Warning message:
Your latexmk version seems to be too low. You may need to update the latexmk package or your LaTeX distribution.
Execution halted
Exited with status 1.
After some experiments I find that if any r trunk exists in any rmd files,the pdf will come out as expected so I don't think this is an latex problem
I'm using rstudio 1.0.13. here's my sessioninfo
R version 3.3.2 (2016-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.1 LTS
locale:
[1] LC_CTYPE=en_AU.UTF-8 LC_NUMERIC=C LC_TIME=en_AU.UTF-8
[4] LC_COLLATE=en_AU.UTF-8 LC_MONETARY=en_AU.UTF-8 LC_MESSAGES=en_AU.UTF-8
[7] LC_PAPER=en_AU.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_AU.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] backports_1.0.5 bookdown_0.3.9 magrittr_1.5 rprojroot_1.2 htmltools_0.3.5
[6] tools_3.3.2 yaml_2.1.14 Rcpp_0.12.9 stringi_1.1.2 rmarkdown_1.3.9002
[11] knitr_1.15.1 stringr_1.2.0 digest_0.6.12 evaluate_0.10
删除摘要和致谢中代码后会报错
! LaTeX Error: Environment Shaded undefined.
Error: Failed to compile bookdown.tex. See bookdown.log for more info.
In addition: Warning message:
running command '"xelatex" -halt-on-error -interaction=batchmode "bookdown.tex"' had status 1
已解决,注销掉 preamble.tex 文件 \renewenvironment{Shaded}{\begin{kframe}}{\end{kframe}}
即可
但是仍有警告:
Warning message:
running command '"bibtex" "bookdown.aux"' had status 2
R, RStudio 以及 bookdown 都是最新版的,系统是 Win7,用 CTeX 的 XeLaTeX 编译文档。
尝试在普通的 Rmd 文档中使用 block2
时,生成的临时 .tex
文档中并不会包含任何与 block2
代码块对应的内容(也不包含相应的 LaTeX 环境),所以想请教下是否可以直接在普通的 Rmd 文档中使用 block2
?
谢谢。
win10环境,sessionInfo如下:
R version 3.4.3 (2017-11-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
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
[5] datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.4.3 backports_1.1.2
[3] bookdown_0.7 magrittr_1.5
[5] rprojroot_1.3-2 htmltools_0.3.6
[7] tools_3.4.3 yaml_2.1.19
[9] Rcpp_0.12.17 stringi_1.2.3
[11] rmarkdown_1.10 knitr_1.20
[13] xfun_0.3 stringr_1.3.1
[15] digest_0.6.15 evaluate_0.10.1
在编译成PDF时报如下错误:
! Undefined control sequence.
l.101 \RecustomVerbatimEnvironment
{Highlighting}{Verbatim}{commandchars=\{...
Error: Failed to compile bookdown.tex. See bookdown.log for more info.
In addition: Warning message:
running command '"xelatex" -halt-on-error -interaction=batchmode "bookdown.tex"' had status 1
Please delete bookdown.Rmd after you finish debugging the error.
Execution halted
Exited with status 1.
参考了 Issue #7 ,但无效,仍然无法编译成功,想请教该如何解决?
在我的环境上无法 build,发现是因为dev: "cairo_pdf"
导致
错误信息:
Quitting from lines 20-28 (bookdown.Rmd)
Error in dev.control(displaylist = if (record) "enable" else "inhibit") :
dev.control() called without an open graphics device
Calls: <Anonymous> ... call_block -> block_exec -> chunk_device -> dev.control
In addition: Warning messages:
1: In as.POSIXlt.POSIXct(Sys.time()) :
unknown timezone 'default/Asia/Shanghai'
2: In (function (filename = if (onefile) "Rplots.pdf" else "Rplot%03d.pdf", :
unable to load shared object '/usr/local/Cellar/r/3.4.2/lib/R/library/grDevices/libs//cairo.so':
dlopen(/usr/local/Cellar/r/3.4.2/lib/R/library/grDevices/libs//cairo.so, 6): image not found
3: In (function (filename = if (onefile) "Rplots.pdf" else "Rplot%03d.pdf", :
failed to load cairo DLL
Please delete bookdown.Rmd after you finish debugging the error.
Execution halted
Exited with status 1.
系统信息:
uname -a
Darwin idealhacks-Pro.local 17.0.0 Darwin Kernel Version 17.0.0: Thu Aug 24 21:48:19 PDT 2017; root:xnu-4570.1.46~2/RELEASE_X86_64 x86_64
此问题在 brew install cairo
和安装 XQuartz 后仍然存在。在去掉该选项后消失。
目前在解决了 TeX 包缺少的问题后已经可以正常编译,但 PDF 中图表 capiton 有问题,不知是否与该选项有关。
详细问题如下:
雷猴啊,散点图!
显示为 <U+96F7><U+7334><U+554A><U+FF0C><U+6563><U+70B9><U+56FE><U+FF01>
雷猴啊,iris 数据!
显示为 <U+96F7><U+7334><U+554A><U+FF0C>iris <U+6570><U+636E><U+FF01>
@yihui 你好!在你的DEMO文件基础上修改了CSS,在编写完一本讲义编译输出时,gitbook没有任何问题,pdfbook输出时报如下错误:
! LaTeX Error: Unknown float option `H'.
Error: Failed to compile ISAD.tex. See ISAD.log for more info.
In addition: Warning message:
running command '"xelatex" -halt-on-error -interaction=batchmode "ISAD.tex"' had status 1
Execution halted
Exited with status 1.
安装的是tinytex,确认该包安装成功。因对latex不熟悉,请问如何解决?谢谢!
sessionInfo 如下:
R version 3.4.3 (2017-11-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=Chinese (Simplified)_China.936 LC_CTYPE=Chinese (Simplified)_China.936
[3] LC_MONETARY=Chinese (Simplified)_China.936 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.4.3 backports_1.1.2 magrittr_1.5 rprojroot_1.3-2 htmltools_0.3.6
[6] tools_3.4.3 yaml_2.2.0 Rcpp_0.12.17 stringi_1.2.3 rmarkdown_1.10
[11] knitr_1.20 stringr_1.3.1 digest_0.6.15 evaluate_0.10.1
麻烦 1(已解决). Latexmk: Bad options specified
Building book 为 pdf 的时候,在 Building 窗口中会显示如下的错误:
Latexmk: -latexoption bad option
Latexmk: -interaction bad option
Latexmk: -pdflatex bad option
Latexmk: Bad options specified
Use
latexmk -help
to get usage information
����: Failed to compile bookdown.tex.
解决方法:到 CTAN 下载 latexmk
的压缩包,解压后复制其中的 latexmk.pl
到 C:\CTEX\MiKTeX\scripts\latexmk\perl
,覆盖旧版本的 latexmk.pl
;
警告:不要按照 INSTALL
中说的那样,将 latexmk.bat
复制到 C:\CTEX\MiKTeX\miktex\bin
,用于替代其中的 latexmk.exe
,否则仍然会出现类似上面的错误。
原因分析:
latexmk.pl
版本为 4.30a
,对应的时间为 2011 年,因此 bookdown
调用这个版本中的接口程序 C:\CTEX\MiKTeX\miktex\bin\latexmk.exe
时,就会抛出上面的错误;latexmk.bat
或者 latexmk.exe
调用主程序 latexmk.pl
,这一点和 Linux 或其它 OS 上可能有所区别, RStudio 中也是按这一流程完成调用的。然而,如果用新版中的 latexmk.bat
,最终传递给 latexmk.pl
的参数是不完整的,大概呈如下的形式:1. C:\CTEX\MiKTeX\miktex\bin\latexmk.bat" -pdf -latexoption=-halt-on-error -interaction=batchmode -pdflatex="xelatex" "bookdown.tex"
2. perl -S latexmk.pl -pdf -latexoption -halt-on-error -interaction batchmode -pdflatex "xelatex"
也就是说,latexmk.bat
这时候只是将 value
部分传递给了 latexmk.pl
,而 key
部分却丢失了。
庆幸的是,CTEX 2.9.2.164 中的 latexmk.exe
却可以将正确的参数全部传递给 latexmk.pl
,因此不可以按照 INSTALL
中说的那样将 latexmk.bat
作为调用 latexmk.pl
的接口。
麻烦 2(已解决):参见 #7 ,这种做法最直接有效。
麻烦 3(未解决):
从 render.R
的源代码看,bookdown
应该是直接指定调用 latex 引擎的方式为 latexmk
,我知道这货很强大,很不错,很。。。
可是现在要想让 latexmk 按照设想的方式工作可能需要比较高的成本,我就想问问老大可不可以在 Pandoc 生成 tex 文件之后,自定义编译文档的脚本文件,比如通过自己写的 make.bat
什么的来完成编译,而不是通过 latexmk
来完成?
照猫画虎,在牛刀小试后面加如下段落:
每年研发经费中,约20%~30%用于研究和创新,70%用于产品开发。很早以前我们就将销售收入的10%以上用于研发经费。未来几年,每年的研发经费会逐步提升到100~200亿美元。
生成的pdf中,20%后面--200亿美元前面的文字变的很小。看了下,两个~
中间的文字变成了\textsubscript
,生成的tex如下:
每年研发经费中,约20\%\textsubscript{30\%用于研究和创新,70\%用于产品开发。很早以前我们就将销售收入的10\%以上用于研发经费。未来几年,每年的研发经费会逐步提升到100}200亿美元。
何解?
1)在使用本模板的时候,会自动生成表格和插图列表。请问如何去除这两项?
2)在生成PDF的时候,为什么cover figure 不出现在首页上?
3)如何是pdf文件不出现左上或右上的页码?或者如何删除下方的页码?
谢谢!
插入如下代码,
par(mar = c(4, 4, 1, .1))
plot(cars, pch = 19, main="雷猴啊")
生成 PDF 后,可见中文标题“雷猴啊”无法正常显示。结果如下图所示:
不仅仅是标题,只要是图片中使用的文字,都显示不正常。
我的 session_info()
:
## R version 4.0.2 (2020-06-22)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 18363)
##
## 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
## [6] methods base
##
## loaded via a namespace (and not attached):
## [1] compiler_4.0.2 magrittr_1.5 bookdown_0.20
## [4] tools_4.0.2 htmltools_0.5.0 rstudioapi_0.11
## [7] yaml_2.2.1 stringi_1.4.6 rmarkdown_2.3
## [10] knitr_1.29 stringr_1.4.0 xfun_0.16
## [13] digest_0.6.25 rlang_0.4.7 evaluate_0.14
这个目录下载到本地后,Build Book选择bookdown::gitbook能正常运行,但是选择bookdown::pdf_book总是产生如下错误:
Use of uninitialized value in concatenation (.) or string at C:\ProgramFiles\CTEX\MiKTeX\scripts\latexmk\perl\latexmk.pl line 830.
! Undefined control sequence.
\XeTeXLinkMargin
Error: Failed to compile bookdown.tex. See bookdown.log for more info.
In addition: Warning messages:
1: running command '"C:\PROGRA~4\CTEX\MiKTeX\miktex\bin\latexmk.exe" -v' had status 1
2: The LaTeX package latexmk was not correctly installed.
3: running command '"C:\PROGRA~4\CTEX\MiKTeX\miktex\bin\latexmk.exe" -v' had status 1
4: running command '"xelatex" -halt-on-error -interaction=batchmode "bookdown.tex"' had status 1
Execution halted
Exited with status 1.
请问这是我的CTEX没有安装好,还是其它问题?我猜想应该不是软件版本的问题,因为下载https://github.com/rstudio/bookdown-demo 这个英文目录时,能够正常生成pdf文件。所有测试都是在windows系统下完成的。
正文中中只是显示 et al, year,
文末的参考文献列表只要是中文的地方都无法显示,只是显示了英文和数字。
刚刚,非常感谢你在 yihui/r-ninja#24 这里提供的解决方案。现在我可以成功编译出有汉字的 PDF 文件了。我打算以这个为模板,改动一下,写点东西出来,本文有啥权限限制没,谢谢。
在index.rmd里,如果我想设置其它repo,比如coding.net上的repo,我应该怎么设置?
在复现这个项目的时候,用tinytex
生成PDF文件是总是报错,提示没有装相应的包,本人重复了多次,终于成功,现将需要的包贴出来,免去大家不必要的探索时间。代码如下:
前提是成功安装好tinytex
,关于tinytex
, 请参考: https://yihui.name/tinytex/cn/。
pkg_deps <- readLines("https://raw.githubusercontent.com/yihui/tinytex/master/tools/pkgs-yihui.txt")
pkg_deps <- c(pkg_deps, "ctex", "ttfutils.win32", "ttfutils", "xecjk", "environ", "trimspaces",
"zhnumber", "metalogo", "xltxtra", "realscripts")
# tinytex:::is_tinytex()
#> [1] TRUE
tinytex::tlmgr_install(pkg_deps)
仅供参考 😊
经过这几个月的折腾,期间不断的麻烦您,终于初步改写了一个论文模板草稿,https://github.com/bubifengyun/SJTUThesis-Rmd ,里面还有很多问题,在此向您表示感谢。
折腾中文的问题,就搜到这里来了。下载这个模板后原样编译,无法通过,出错信息附后。我试着把preamble.tex的相关的这一行注释掉,但编译仍然出错,错误信息换成了XeTeXLinkBox未定义
。原以为是xetex的版本太旧,毕竟很久没用了,于是升级,还是不行。一怒就把CTEX重装,还是不行。
用的是RStudio最新版。错误信息和session信息附后。
烦请帮忙看看是哪里出了问题吧。谢谢!看别人的留言好像都能通过......
! Undefined control sequence.
<argument> \XeTeXLinkMargin
Error: Failed to compile bookdown.tex. See bookdown.log for more info.
In addition: Warning message:
running command '"xelatex" -halt-on-error -interaction=batchmode "bookdown.tex"' had status 1
Execution halted
Exited with status 1.
> sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] backports_1.0.5 magrittr_1.5 rsconnect_0.7 rprojroot_1.2
[5] htmltools_0.3.5 tools_3.2.3 yaml_2.1.14 Rcpp_0.12.9
[9] stringi_1.0-1 rmarkdown_1.3 knitr_1.15.1 stringr_1.0.0
[13] digest_0.6.9 evaluate_0.10
rmarkdown::pandoc_version()
[1] ‘1.17.2’
我在使用该模板时:
下面这段,就会报错:
```{r hello, fig.cap='雷猴啊,散点图!', out.width='90%'}
par(mar = c(4, 4, 1, .1))
plot(cars, pch = 19)
```
报错如下
Latexmk, John Collins, 5 Sep. 2016. Version 4.48
! LaTeX Error: Environment Shaded undefined.
Error: Failed to compile bookdown.tex. See bookdown.log for more info.
In addition: Warning messages:
1: running command '"C:\Users\Shaojun\AppData\Local\Programs\MIKTEX~1.9\miktex\bin\latexmk.exe" -v' had status 1
2: The LaTeX package latexmk was not correctly installed.
3: running command '"C:\Users\Shaojun\AppData\Local\Programs\MIKTEX~1.9\miktex\bin\latexmk.exe" -v' had status 1
4: running command '"xelatex" -halt-on-error -interaction=batchmode "bookdown.tex"' had status 1
如果包括这段就没有错。请问可能是什么原因导致的?谢谢。
> sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] backports_1.0.4 bookdown_0.3 magrittr_1.5 rprojroot_1.1
[5] htmltools_0.3.5 tools_3.3.2 rstudioapi_0.6 yaml_2.1.14
[9] Rcpp_0.12.8 stringi_1.1.2 rmarkdown_1.3 knitr_1.15.1
[13] stringr_1.1.0 digest_0.6.10 evaluate_0.10
clone 这个 repo,打开 .Rproj
文件,用 RStudio build 按钮,可以生成 pdf。但是 pdf 的图片表格的中文标题无法正常显示。
修改编译器为 pdflatex 或 xelatex 均得到同样的(错误)效果。
MiKTeX,pandoc,Rstudio,bookdown 均最新版。
> sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] backports_1.0.5 bookdown_0.3.9 magrittr_1.5 rprojroot_1.2
[5] htmltools_0.3.5 tools_3.3.2 yaml_2.1.14 Rcpp_0.12.9
[9] stringi_1.1.2 rmarkdown_1.3 knitr_1.15.1 stringr_1.2.0
[13] digest_0.6.12 evaluate_0.10
> rmarkdown::pandoc_version()
[1] ‘1.19.2.1’
> system('xelatex --version')
MiKTeX-XeTeX 2.9.6216 (0.99996) (MiKTeX 2.9.6210 64-bit)
(C) 1994-2008 by SIL International, (C) 2009-2012 by Jonathan Kew, (C) 2010-2012 by Han The Thanh, (C) 2012-2013 by Khaled Hosny
下载这个项目到自己电脑(window系统)上,什么文件也没有改动,只是打开了bookdown-chinese.Rproj文件,Rstudio就有如下的错误提醒:
[1] "LC_COLLATE=Chinese (Simplified)_People's Republic of China.936;LC_CTYPE=Chinese (Simplified)_People's Republic of China.936;LC_MONETARY=Chinese (Simplified)_People's Republic of China.936;LC_NUMERIC=C;LC_TIME=Chinese (Simplified)_People's Republic of China.936"
Error in yaml::yaml.load(string, ...) :
Scanner error: mapping values are not allowed in this context at line 2, column 7。、
发现Build Book后能正常运行,得到的结果也没问题。不知道这个错误提示是哪里出了问题?
很喜欢bookdown的交叉索引、引用、题注、自动标号等功能,想用来写些长点的文章(但不是书)。但是生成PDF之后,强迫症犯了很想TOC/LOT/LOF的偶数页空白页。空白页在打印实体书的时候是必要的,但电子文档就无此必要,不知是否有可能去掉这些空白页
另外还想请教如何在PDF中强制分页(类似word中的插入“分页符”)
latex一点也没接触过,问题有点小白,见笑了。。。
多谢~
报错
processing file: bookdown.Rmd
Quitting from lines 20-28 (bookdown.Rmd)
Error in dev.control(displaylist = if (record) "enable" else "inhibit") :
dev.control() called without an open graphics device
Calls: <Anonymous> ... call_block -> block_exec -> chunk_device -> dev.control
此外: Warning messages:
1: In grSoftVersion() :
無法載入共享物件 '/Library/Frameworks/R.framework/Resources/modules//R_X11.so' :
dlopen(/Library/Frameworks/R.framework/Resources/modules//R_X11.so, 6): Library not loaded: /opt/X11/lib/libSM.6.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/4.0/Resources/modules/R_X11.so
Reason: image not found
2: In cairoVersion() :
無法載入共享物件 '/Library/Frameworks/R.framework/Resources/library/grDevices/libs//cairo.so' :
dlopen(/Library/Frameworks/R.framework/Resources/library/grDevices/libs//cairo.so, 6): Library not loaded: /opt/X11/lib/libXrender.1.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/grDevices/libs/cairo.so
Reason: image not found
3: In (function (filename = if (onefile) "Rplots.pdf" else "Rplot%03d.pdf", :
failed to load cairo DLL
Please delete bookdown.Rmd after you finish debugging the error.
停止執行
Exited with status 1.
直接 clone 本项目,未经任何改动,使用 RStudio 编译出现如上 Error
环境 | 版本 |
---|---|
OS | macOS 10.15.5 |
R | 4.0.2 (2020-06-22) |
RStudio | 1.3.959 |
bookdown | 0.2.0 |
tinytex | 0.2.4 |
knitr | 1.29 |
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.