无法在 markdown 和 pandoc 中使用 titlesec? [英] Not able to use titlesec with markdown and pandoc?

查看:67
本文介绍了无法在 markdown 和 pandoc 中使用 titlesec?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在 Markdown 文档中使用 titlesec 时,如下所示:

When I used titlesec in my markdown document as below:

---
header-includes:
    - \usepackage{titlesec}
---

使用pandoc处理时,出现以下错误:

when processing it by pandoc, I got the following error:

pandoc try.md -o try.pdf
! Argument of \paragraph has an extra }.
<inserted text> 
                \par 
l.1290 \ttl@extract\paragraph

pandoc: Error producing PDF

通过搜索,我找到了以下针对 R-markdown 的解决方法:无法使用自定义样式编织为 pdf

by searching, I found the following work-around for R-markdown: Can't knit to pdf with custom styles

我想知道如何使用 Markdown 和 YAML 标头实现类似的解决方法?

I wonder how can I implement a similar work-around with markdown and YAML headers?

我还发现并验证了以下方法可行:

I also found and verified the following approach would work:

pandoc --variable=subparagraph try.md -o try.pdf

但这对用户来说更难,因为人们可能会忘记解决方法.

But it's harder for the user, as one might forget the work-around.

有一些关于解决方法的讨论 https://www.bountysource.com/issues/40574981-latex-template-incompatible-with-titlesec,但这超出了我的知识范围

There are some discussion of the work-around https://www.bountysource.com/issues/40574981-latex-template-incompatible-with-titlesec, but it's beyond my knowledge

感谢您的帮助

推荐答案

这是因为默认的 LaTeX 模板重新定义了 \paragraph.要禁用此行为,您可以使用 pandoc 中的 subparagraph 变量.您可以在命令行中提供:

This is because the default LaTeX template redefines \paragraph. To disable this behaviour, you can use the subparagraph variable in pandoc. You could supply this at the command-line:

pandoc --variable subparagraph -o file.pdf file.md

或者您可以将其嵌入到文档的 YAML 元数据中,使用任何非空值:

Or you could embed it in the document's YAML metadata, with any non-null value:

---
subparagraph: yes
---

来自man pandoc(以及用户指南):

小段

禁用将(子)段落重新定义为节的 LaTeX 模板的默认行为,更改某些类中嵌套标题的外观

disables default behavior of LaTeX template that redefines (sub)paragraphs as sections, changing the appearance of nested headings in some classes

在此之后,titlesec.sty 应该可以工作了.

After this, titlesec.sty should work.

这篇关于无法在 markdown 和 pandoc 中使用 titlesec?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆