我正在尝试在由 markdown 文件生成的 docx 中的目录前添加一个部分。我的目录是使用 pandoc 命令的 --toc 选项生成的,而我的 markdown 没有目录字段。我尝试使用 --include-before-body 选项在目录前添加一个部分,但没有成功。
pandoc test.md -f markdown -t docx -s -o test.docx --reference-doc=./custom-reference.docx --number-sections=true --lof=true --toc=true --include-before-body=cover.docx
--include-before-body 选项:
-B FILE, --include-before-body=FILE|URL
Include contents of FILE, verbatim, at the beginning of the document body (e.g. after the <body> tag in HTML, or the \begin{document} command in LaTeX). This can be used to include navigation bars or banners in HTML documents.
This option can be used repeatedly to include multiple files. They will be included in the order specified. Implies --standalone. Note that if the output format is odt,
this file must be in OpenDocument XML format suitable for insertion into the body of the document, and if the output is docx, this file must be in appropriate OpenXML format.
但是当我尝试传递一个简单的 cover.docx 文件时,它会失败并出现以下错误
UTF-8 decoding error in cover.docx at byte offset 10 (b2). The input must be a UTF-8 encoded text
我尝试生成 cover.doc、cover.docx(严格的 office XML)、cover.docx,但仍然不起作用。
在目录之前添加一个部分是正确的方法吗?如果是,我做错了什么?