0

Is it possible to have subscript inside of bold text in restructured text?

i.e.

**H :sub:`2` O**

Will render as `H :sub:`2` O in bold instead of H2O (with subscript 2)

I'm guessing from this thread it isn't: Bold italic in ReStructuredText

I'm converting html files into rst and stripping all the subscript elements out of bold text is inconvenient!

mzjn
  • 48,958
  • 13
  • 128
  • 248
sam
  • 1,005
  • 1
  • 11
  • 24
  • You cannot have nested formatting in reST. See https://docutils.sourceforge.io/FAQ.html#is-nested-inline-markup-possible – Steve Piercy Aug 26 '20 at 13:47

1 Answers1

1

Short answer is it's not possible with reStructuredText. You cannot have inline element inside another inline element, i.e. you can't have bold sentence with bold and emphasised word inside it. Or, your case - subscript within bold text. details

However, if you target to HTML, there is workaround based on raw role.

.. role:: raw-html(raw)
   :format: html

Water formula is :raw-html:`<strong>H<sub>2</sub>O</strong>`.

Another alternative is use math role and type chemical formulas as math formula. If your case, water written using amslatex syntax is

:math:`H_2O`.
Matt Warrick
  • 1,385
  • 1
  • 13
  • 22