0

I would like my script to print a character with a subscript "c" or "d" (as, in Latex, K_c or E_d). However, I cannot find a way to do so. I could not find the corresponding code in the Unicode database. I found unicode for specific letters, but not 'c'

I tried using str.translance, and copy/paste a list of all subscripted letters from word, to no avail (The python script editor receives them as standard letters).

Note that there are already answers in this question when it comes to unicode characters Printing subscript in python

However, the subscript I am looking for have no unicode equivalent. Thus I cannot print them by invoking a unicode code. For the same reason, I cannot use str.maketrans

How can I get my script to display these two letters as subscript ?

1
  • 1
    One approach is to use IPython and LaTeX markup. I have Jupyter Notebook support enabled in VSCode which gives me an IPython integrated terminal, if i run the Python code in teh integrated terminal it renders the LaTeX markup correctly, So import: from IPython.display import display, Latex then display: display(Latex(f'$K_c$')) or display(Latex(f'$E_d$')). Commented Apr 4, 2024 at 9:31

1 Answer 1

2

Unfortunately, the Unicode standard does not include subscript versions of all letters, and specifically, it lacks a subscript "c" or "d". This limitation means you cannot directly use a Unicode character to represent every possible subscript letter directly in your script.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks. So the Unicode option is definitely out of the picture. I was wondering if there is a workaround ?
@GaL yes, just use a GUI with rich text box instead of console. Unicode isn't about formatting so you can't do complex things arbitrary character's subscript
@phuclv Thanks, that makes sense. The question is thus specific to where I need Python to print the subscript, and the console cannot do that. It answers my question.
Subscripts, in general, are formatted (aka "rich") text, not plain text. Unicode encodes what is needed for representation in plain text. Any subscript letters encoded in Unicode are included in Unicode either for compatibility with some legacy encoding standard or because they are semantically significant and needing to be distinguished in plain text for some important writing systems, such as phonetic transcription systems.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.