简体   繁体   中英

Prevent escaping of special characters in LaTeX output

By default the LaTeX output generated by Sphinx escapes the LaTeX markup. So if I write:

Normal text

.. only:: latex

   \textbf{latex only text}

After a make latexpdf call it will be

Normal text

textbf\{latex only text\}

in LaTeX. So all chars are escaped, and it is not a LaTeX code anymore. Is there a way to pass LaTeX code directly to the tex source generated by Sphinx?

MWE is to do a sphinx-quickstart accepting defaults, then inputing the above ReST code somewhere in index.rst and finally building the thing with make latexpdf ( make.bat latexpdf on Windows).

What you want is the raw directive:

.. raw:: latex

   \textbf{latex only text}

If you only want this text in LaTeX output, you will need to combine it with the only directive.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM