In python-sphinx there is the only directive, which can be used to conditionally influence the document according to its output. For instance text appears in html or latex only.
It is use like this:
.. only:: not latex Here there is some Text, that does not appear in latex output. .. only:: html Here there is some Text, that only appears in html output.
How can I use the role directive in the right way to use the only-class inline, let's say like this:
Here there is some Text, that :only-notlatex:`does not appear in latex`
:only-html:`only appears in html`.
I saw something similar for the raw directive. Is this also possible for the only directive? I tried:
.. role:: only-html(only) :format: html .. role:: only-notlatex(only) :format: not latex
But this does not work.
only
directive. You will have to create your own custom role for this purpose. I can't provide any detailed instructions, but here is an article that can help you get started: doughellmann.com/2010/05/09/…. – Idealist