【问题标题】:pandoc: cannot produce pdf output with rst writerpandoc:无法使用 rst writer 生成 pdf 输出
【发布时间】:2014-09-01 07:52:25
【问题描述】:

我尝试使用 pandoc 将 rst 文件转换为 pdf 使用此命令

pandoc -V geometry:a4paper -t rst test.rst --toc -s -o test.pdf

,但我收到以下错误:

pandoc: cannot produce pdf output with rst writer

如何使用 pandoc 将 rst 转换为 pdf?

【问题讨论】:

    标签: pandoc


    【解决方案1】:

    【讨论】:

      【解决方案2】:

      我遇到了同样的问题,使用 Windows 的默认 Pandoc 安装程序(在 C:\上面的路径在它的 PATH 中,我通常会成功地从 markdown 转换为 pdf。

      所以,这些是我尝试过的命令类型,但都失败了:

      $ pandoc -s -t rst --toc rest_syntax.rst -o rest_syntax.pdf
      cannot produce pdf output from rst
      

      然后,这个页面knitr pandoc: "cannot produce pdf output with pdf writer"注意到:

      ... [*对于pdf输出,使用latex或beamer和-o FILENAME.pdf] ...

      所以基本上format = "pdf"是无效的,你应该使用pandoc("tmp.Rmd", format = "latex", ext = "pdf") ...

      好的,然后我记得当我将 markdown 转换为 pdf 时,我实际上在大多数调用中都使用了 --pdf-engine 参数,所以我尝试了:

      $ pandoc -s -t rst --toc rest_syntax.rst --pdf-engine=pdflatex -o rest_syntax.pdf
      pdf-engine pdflatex is not compatible with output format rst
      
      $ pandoc -s -t rst --toc rest_syntax.rst --pdf-engine=xelatex -o rest_syntax.pdf
      pdf-engine xelatex is not compatible with output format rst
      
      $ pandoc -s -t rst --toc rest_syntax.rst --pdf-engine=lualatex -o rest_syntax.pdf
      pdf-engine lualatex is not compatible with output format rst
      

      ...我觉得很奇怪...但后来我注意到“output format rst” - 而且,我不希望 rst 作为 output 格式!于是我看了pandoc --help——原来-t就是--to,也就是说,它确实指定了输出格式!

      所以,一旦我删除了它,终于成功了:

      $ pandoc -s --toc rest_syntax.rst --pdf-engine=lualatex -o rest_syntax.pdf
      [WARNING] Reference not found for 'Key "today"' at chunk line 1 column 8
      [WARNING] Reference not found for 'python' at line 726 column 118
      [WARNING] Reference not found for '#name' at line 811 column 30
      [WARNING] Reference not found for '1' at line 822 column 53
      [WARNING] Reference not found for '#' at line 823 column 32
      

      最后,这似乎可行;请注意,rest_syntax.rst 文件实际上是这样的:https://thomas-cokelaer.info/tutorials/sphinx/_sources/rest_syntax.txt - 并非所有内容都在 PDF 中很好地格式化,但有一个目录,基本格式和方程式似乎可以工作。

      【讨论】:

        猜你喜欢
        • 2014-03-30
        • 1970-01-01
        • 2021-01-09
        • 1970-01-01
        • 2015-10-30
        • 2011-12-27
        • 1970-01-01
        • 1970-01-01
        • 2016-02-19
        相关资源
        最近更新 更多