Lily Mara
Lily Mara

Reputation: 4128

LaTeX in RST processed with Pandoc

I want to use ReStructuredText to take notes, and I sometimes want to add equations to the notes with LaTeX. I followed the advice of both answers to this question, but neither of them worked for me. I have an RST file called foo.rst with these contents:

.. role:: latex(raw)
   :format: latex

==============
This is a test
==============

Test with latex role :latex:`\Delta X`

Test with raw role :raw:`\Delta X`

Test with raw role and $ :raw:`$\Delta X$`

Test with raw role and $ :raw:`$\Delta X$`

Then when I compile this to a pdf with pandoc -o foo.pdf foo.rst, I get this output.

Imgur

If I first compile to tex, I get this:

\section{This is a test}\label{this-is-a-test}

Test with latex role \textbackslash{}Delta X

Test with raw role \textbackslash{}Delta X

Test with raw role and \$ \$\textbackslash{}Delta X\$

Test with raw role and \$ \$\textbackslash{}Delta X\$

It seems to be escaping the text inside of the raw and latex directives. Is there a way to use inline LaTeX with pandoc and RST?

Upvotes: 3

Views: 1534

Answers (1)

gozzilli
gozzilli

Reputation: 8337

There are a math directive and a math role that should do the job:

The area of a circle is :math:`A_\text{c} = (\pi/4) d^2`.

Then:

pandoc -o foo.pdf foo.rst

Results in:

enter image description here

Upvotes: 3

Related Questions