I'd like to print element symbols, with the mass number represented in superscript and the atomic number as a subscript, in the single character space directly preceding the element's letter.
I'm currently using:
SUP = str.maketrans("0123456789", "⁰¹²³⁴⁵⁶⁷⁸⁹")
atom = f"{1}{H}{1}".translate(SUP)
print(atom)
This is better than nothing, but I'd like both numbers to be in line, as they would usually be.
I know that unicode wizardry exists to create fractions. Is there either a python library, or a special unicode character which can do this for me?
Unicode is ideal, because I can rely on it working in my Django templates.
I'd like to be able to create this using unicode or similar, rather than relying on custom tags within the Django template.
Search terms such as 'composite superscript and subscript unicode' and similar have so far yielded nothing.