Pandoc - 可以使用美元符号数学输出 tex 吗?

Pandoc - is tex output with dollar sign math possible?

pandoc 中的 .tex 文件 output 是否可以具有带美元符号的数学模式 ($)? manual 表示:

LaTeX: 它将逐字显示在 \(...\) (用于内联数学)或 \[...\](用于显示数学)。

我还发现了 2016 年的这个 Github issue,作者说它可以选择。现在是否有 pandoc 参数或另一种让 .tex 输出使用美元符号的方法?

您可以使用 pandoc 过滤器执行此操作。例如:

-- Do nothing unless we are targeting TeX.
if not FORMAT:match('tex$') then return {} end

function Math (m)
  local delimiter = m.mathtype == 'InlineMath' and '$' or '$$'
  return pandoc.RawInline('tex', delimiter .. m.text .. delimiter)
end

保存到文件dollar-math.lua,并通过--lua-filter=dollar-math.lua传递给pandoc。