1
$\begingroup$

How do I write a superscript text standalone, without implying power? E.g.

ToExpression[25]<>"CNTRL+^oC"

doesn't format well, italicizing o and leaving whitespace in-between the number and Centigrade symbol.

How do I in general write text which is superscripted?

$\endgroup$
  • $\begingroup$ For your specific example, you can simply use \[Degree]C $\endgroup$ – xzczd Jan 15 '16 at 6:11
1
$\begingroup$

How do I write a superscript text standalone, without implying power?

Like this

Superscript["", "more text"]

enter image description here

As pointed out by MikeLimaOscar, Superscript[\[Null], "more text"] will produce something similar without a string in the main part of the text.

If you need to put text after the subscript rather than before, you can follow the directions here or do something like this

Row[{Superscript["", "more text"], "text"}]

enter image description here

$\endgroup$
  • $\begingroup$ but how to do superscript without the "text" part, so it will output "more text" superscript, without any white spaces before it? $\endgroup$ – Al Guy Jan 15 '16 at 8:22
  • $\begingroup$ Sorry, misunderstood your question, I think you can just use a blank string there $\endgroup$ – Jason B. Jan 15 '16 at 8:24
  • $\begingroup$ There is also the invisible character, \[Null], that can be used as the base of super/subscripts. $\endgroup$ – MikeLimaOscar Jan 15 '16 at 9:28
  • $\begingroup$ Thanks, that's even better. I was trying Null but it would actually print Null $\endgroup$ – Jason B. Jan 15 '16 at 9:29
  • 1
    $\begingroup$ @AlGuy, that isn't what you mentioned in the first post. Try to describe exactly what you are looking for from the get go. A "standalone superscript" is much different than a superscript on the left. $\endgroup$ – Jason B. Jan 15 '16 at 10:27
3
$\begingroup$

If it is this specific example you are interested in, you could have found it out yourself by evaluating

Quantity[25, "DegreesCelsius"]

and then pressing Ctrl+Shift+E when the cursor is in the output cell. There, you would have found

Cell[BoxData[
 TemplateBox[{"25","\"\[Degree]C\"","degrees Celsius","\"DegreesCelsius\""},
...]

which would have given you the hint that xzczd gave you. Therefore, you can use

"25\[Degree]C"
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.