当blockquote跟在标题后面时,会导致pandoc文档转换错误
我正在使用RStudio中的knitr,并且正在寻找从rmarkdown文件创建文档时出现奇怪错误的解释。 例如,我有一个文件,pdf-test.Rmd:
---
title: "PDF knit error"
output: pdf_document
---
##Headers
> ###Quote 1
This results in an error; if the blockquote symbol ('>') in
preceeding line is removed, no error
> ###Quote 2
This line is fine
当我尝试使用针织PDF按钮创建PDF时,这是输出:
|.................................................................| 100% ordinary text without R code processing file: pdf-test.Rmd output file: pdf-test.knit.md /usr/bin/pandoc +RTS -K512m -RTS pdf-test.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output pdf-test.pdf --template /home/jcoliver/R/x86_64-pc-linux-gnu-library/3.3/rmarkdown/rmd/latex/default-1.17.0.2.tex --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable 'geometry:margin=1in' ! LaTeX Error: Something's wrong--perhaps a missing item. See the LaTeX manual or LaTeX Companion for explanation. Type H for immediate help. ... l.94 end{quote} pandoc: Error producing PDF Error: pandoc document conversion failed with error 43 Execution halted
如上所述,从第一个实例中删除块引用字符( >
)会导致错误消失(尽管所需的格式也是如此)。
---
title: "PDF knit error"
output: pdf_document
---
##Headers
###Quote 1
No error here
> ###Quote 2
This line remains fine
而且没有来自pandoc / LaTeX的投诉:
|.................................................................| 100% ordinary text without R code /usr/bin/pandoc +RTS -K512m -RTS pdf-test.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output pdf-test.pdf --template /home/jcoliver/R/x86_64-pc-linux-gnu-library/3.3/rmarkdown/rmd/latex/default-1.17.0.2.tex --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable 'geometry:margin=1in' processing file: pdf-test.Rmd output file: pdf-test.knit.md Output created: pdf-test.pdf
我还可以通过将块引用的标题级别更改为H4或更高(H5,H6等),同时将第一个块引用的标题级别更改为H1或H2,仍然可以避免错误。
那么为什么会发生这种错误? 为什么我不能立即在头后跟H3进行块引用? 请注意,我在标题行( #Headers
, ##Headers
, ###Headers
)上尝试了不同的标题级别,在##Headers
行之后改变了空格,并且使用了不同的输出格式(即HTML),但总是发生错误。
一些系统细节:
你想引用节标题,直接在节标题后? 这听起来确实很特别,看起来像pandoc
无法处理这个问题。
正如eipi10的回答中所提出的,解决方案是在标题和报价之间添加一些内容。 不过,我认为你不应该在文档中添加白色填充文本。 例如,当您从PDF复制文本时,填充符变得可见。
相反,只需添加一个(空)框: mbox{}
。 然后,为了避免由于我们引入的额外线引起的过多垂直空白,请添加一些负垂直空间: vspace*{-1cm}
。
---
output: pdf_document
---
##Headers
mbox{}vspace*{-1cm}
> ### Quoted Section
Foobar.
我不知道错误发生的原因,但这里有一个黑客攻击,它允许你在H2头文件后立即在块引用中使用H3头文件,而不需要插入文本。
基本的想法是你在标题之间添加了一些文本,但是你将它的颜色设置为白色(你还需要在标题中声明usepackage{color}
以使其工作)。 然后,因为这也会在标题之间增加太多空间,所以使用tiny
使文本变得tiny
并使用vspace*{-baselineskip}
减少行间的空间。 (我最初尝试使用phantom{aaa}
添加幻像文本,但仍导致相同的错误,所以我切换到“真实”文本,但呈现与背景相同的颜色(即白色)。)
---
title: "PDF knit error"
output:
pdf_document:
number_sections: no
header-includes:
- usepackage{color}
---
##Headers
vspace*{-baselineskip}
tiny
begin{itemize}
color{white}
item Some text
end{itemize}
normalsize
vspace*{-baselineskip}
> ###Quote 1
This results in an error; if the blockquote symbol ('>') in
preceeding line is removed, no error
> ###Quote 2
This line is fine
链接地址: http://www.djcxy.com/p/33473.html
上一篇: What causes a pandoc document conversion error when blockquote follows header