How to print index with decreased font size?
Question:
Answers:
You can use maketrans
and translate
def get_sub(x):
normal = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-=()"
sub_s = "ₐ₈CDₑբGₕᵢⱼₖₗₘₙₒₚQᵣₛₜᵤᵥwₓᵧZₐ♭꜀ᑯₑբ₉ₕᵢⱼₖₗₘₙₒₚ૧ᵣₛₜᵤᵥwₓᵧ₂₀₁₂₃₄₅₆₇₈₉₊₋₌₍₎"
res = x.maketrans(''.join(normal), ''.join(sub_s))
return x.translate(res)
# display subscript
print('A{} = A{} + 10'.format(get_sub('i'),get_sub('i-1')))
#output
Aᵢ = Aᵢ₋₁ + 10
You can use maketrans
and translate
def get_sub(x):
normal = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-=()"
sub_s = "ₐ₈CDₑբGₕᵢⱼₖₗₘₙₒₚQᵣₛₜᵤᵥwₓᵧZₐ♭꜀ᑯₑբ₉ₕᵢⱼₖₗₘₙₒₚ૧ᵣₛₜᵤᵥwₓᵧ₂₀₁₂₃₄₅₆₇₈₉₊₋₌₍₎"
res = x.maketrans(''.join(normal), ''.join(sub_s))
return x.translate(res)
# display subscript
print('A{} = A{} + 10'.format(get_sub('i'),get_sub('i-1')))
#output
Aᵢ = Aᵢ₋₁ + 10