Hey so I know that due to the Unicode support in Julia one, may write for instance the letter a with the subscript 1 by typing a\_1<TAB>. Now, what if I wanted to do something like the following:
for i in [1 2 3]
println("a\_i")
end
and have the output be written as
a₁
a₂
a₃
How would I go about this without writing out all the possible subscripts myself?
You could do this (at least in version 0.6):
ltx = Base.REPLCompletions.latex_symbols
for i in 1:3
println("a$(ltx["\\_$i"])")
end
Bogumił Kamiński's answer seems the neatest, but I needed to reverse the order to get the correct string for two-digit numbers:
subscript(i::Integer) = i<0 ? error("$i is negative") : join('₀'+d for d in reverse(digits(i)))
for i=7:13 println("a"*subscript(i)) end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With