Skip to content

PDF 编译错误 #81

@qiushiyan

Description

@qiushiyan

我对 latex 排错能力有限,先把我碰到过的错误贴上来。

第一个错误是 bookdown.post.latex 里面的这一行

x = x[-unlist(mapply(seq, i1, i2, SIMPLIFY = FALSE))]

报错信息是

 Error in seq.default(dots[[1L]][[5L]], dots[[2L]][[5L]]) : 
  'to' must be a finite number 
10.
stop("'to' must be a finite number") 
9.
seq.default(dots[[1L]][[5L]], dots[[2L]][[5L]]) 
8.
(function (...) 
UseMethod("seq"))(dots[[1L]][[5L]], dots[[2L]][[5L]]) 
7.
mapply(seq, i1, i2, SIMPLIFY = FALSE) at <text>#29
6.
unlist(mapply(seq, i1, i2, SIMPLIFY = FALSE)) at <text>#29
5.
post(x) 
4.
output_format$post_processor(front_matter, input, output_file, 
    clean, !quiet) 
3.
rmarkdown::render(main, output_format, ..., clean = clean, envir = envir) 
2.
render_cur_session(files, main, config, output_format, clean, 
    envir, ...) 
1.
bookdown::render_book("index.Rmd", "bookdown::pdf_book") 

估计这里是前面的 i1 和 i2 出现了 Inf,这一行注释掉后可以消除错误。

第二错误是两张图片

https://github.com/cosname/rmarkdown-guide/blob/master/01-intro.Rmd#L139-L143

https://github.com/cosname/rmarkdown-guide/blob/master/03-document.Rmd#L170-L174

这两个图的 fig.cap 都是用了 (ref:label) 语法,错误是一样的,例如第二个图生成的 tex

\begin{figure}

{\centering \includegraphics{examples/first-rmd-theme-darkly} 

}

\caption{应用 \href{https://bootswatch.com/3/darkly}{darkly} 主题后的文档样式}\label{fig:first-rmd-theme-darkly}
\end{figure}

报错 log 是

! Argument of \@tempf has an extra }.
<inserted text> 
                \par 

把它们都改成行内 fig.cap 可以解决这个问题

第三个错误我没有找到具体的报错位置,错误信息是

! Undefined control sequence.
<argument> @{} >{\raggedright \arraybackslash 
                                              }p{(\columnwidth - 2\tabcolsep...
l.967 ...width - 2\tabcolsep) * \real{0.7639}}@{}}

log 文件是

https://gist.github.com/qiushiyan/2956afa6c2cbd2892c955d962ccfbfe1

此外 #80 还会带来一个新错误

Error running filter /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/rmarkdown/rmarkdown/lua/latex-div.lua:
.../Resources/library/rmarkdown/rmarkdown/lua/latex-div.lua:52: attempt to index a nil value (field 'integer index')
stack traceback:
Error: pandoc document conversion failed with error 83

可能有关 https://community.rstudio.com/t/pandoc-document-conversion-failed-with-error-83/138962

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions