如果您最近安装了包含fvextra包的 LaTeX,那么有一个简单的解决方案,最近由 jannick0 建议。
修改您的YAML 标头选项以包含
\usepackage{fvextra}
\begin{Highlighting}[breaklines,numbers=left]
并用 xelatex 编译。
例如,
---
header-includes:
- \usepackage{fvextra}
- \DefineVerbatimEnvironment{Highlighting}{Verbatim}{breaklines,commandchars=\\\{\}}
---
~~~~~{.java}
this is a very long long long long long long long long long long long long long line which is broken
~~~~~~
编译时
pandoc input.md --pdf-engine=xelatex -o output.pdf
给
如果你有.numberLines
选择,即
---
header-includes:
- \usepackage{fvextra}
- \DefineVerbatimEnvironment{Highlighting}{Verbatim}{breaklines,commandchars=\\\{\}}
---
~~~~~{.java .numberLines}
this is a very long long long long long long long long long long long long long line which is broken
~~~~~~
那么同样的命令会产生