[Tex/LaTex] How to render a markdown file with some LaTeX inline math

command linemarkdown

When I receive a Markdown file, I can open it in a markdown editor like React on Linux or Markdown Monster on Windows etc. However – such editors do not support rendering of LaTeX embedded in the Markdown as inline math (i.e. with single-dollar signs) – and I'm faced with the task of rendering such documents.

Obviously this is supported on some web-based systems – like the one here on TeX.SX . But I am in a terminal with a command shell; or am possibly writing a script, to do this. I'm on a Linux system.

The rendered output format should be PDF, HTML with MathML, HTML with rendered images, or anything else that's reasonable. Preferably I should be able to choose among these output type options.

Best Answer

If you need a command line tool to convert markdown to pdf or html, then pandoc might be a good candidate. You simply call:

$ pandoc infile.md -o outfile.pdf 

or

$ pandoc infile.md -o outfile.html

to generate the desired output.

You can configure the process, if desired. For math in html, you could choose different rendering options, like --mathjax or --mathml. If you need embedded pictures, use --webtex. This is all documented in the manual: https://pandoc.org/MANUAL.html#math-rendering-in-html

Related Question