Can I use inline raw LaTeX in reStructuredText

 ̄綄美尐妖づ 提交于 2019-12-10 13:14:19

问题


I am trying to embed a LaTeX variable into some reStructuredText. I know about the ".. raw::" directive, but I want this to be embedded in a paragraph of text. Specifically, I am looking to replicate the \numquestions\ and \numpoints\ variables from the template exam document. I have tried using :raw:\numquestions\, but this does not seem to be valid. Is there any way of doing this?


回答1:


You first have to define your own latex role, which allows you then to embed LaTex directly into paragraphs:

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

Now, you can write things like :latex:`\\textsc{NoTex}` directly embedded in paragraphs. You can find an example of this in the browser based text editor NoTex with support for reStructuredText and PDF, LaTex & HTML export options.




回答2:


Use the raw role (the inline equivalent of the raw directive). See these references:

  • http://docutils.sourceforge.net/FAQ.html#how-can-i-include-mathematical-equations-in-documents
  • http://docutils.sourceforge.net/docs/ref/rst/roles.html#raw


来源:https://stackoverflow.com/questions/7533406/can-i-use-inline-raw-latex-in-restructuredtext

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!