Pandoc - is tex output with dollar sign math possible?

Viewed 527

Is it possible to have .tex files output from pandoc have math mode with dollar signs ($)? The manual says:

LaTeX: It will appear verbatim surrounded by \(...\) (for inline math) or \[...\] (for display math).

I also found this Github issue from 2016 where the author says it could be selectable. Is there now a pandoc argument or another way of having the .tex output use dollar signs?

1 Answers

You can do this using a pandoc filter. E.g.:

-- 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

Save to file dollar-math.lua, and pass it to pandoc via --lua-filter=dollar-math.lua.

Related