How would you add a subscript to one particular word of a title in R? For example, suppose the title is "A_2 and B_2."
How would you add these two subscripts? I know that expression("A"[2])
and expression("B"[2])
individually add subscripts to these letters.
Subscripts and Superscripts To indicate a subscript, use the underscore _ character. To indicate a superscript, use a single caret character ^ . Note: this can be confusing, because the R Markdown language delimits superscripts with two carets.
Superscript is “started” by the caret ^ character. Anything after ^ is superscript. The superscript continues until you use a * or ~ character. If you want more text as superscript, then enclose it in quotes.
Use keyboard shortcuts to apply superscript or subscript Select the text or number that you want. For superscript, press Ctrl, Shift, and the Plus sign (+) at the same time. For subscript, press Ctrl and the Equal sign (=) at the same time.
Use "_" (underscore) for subscripts. If the subscript has more than one character, enclose it in braces: "lim_{x --> 0} sin (x) / x".
You do not need paste
(or quotes for that matter) at all:
expression( A[2]~and~B[2] )
Test:
plot(1,1, main=expression( A[2]~and~B[2] ) )
The syntactic principle is that tildes (which creates a space) and asterisks (non-space plotmath separator) are used to separate items and that no quotes are needed unless you are using a plotmath function name .... such as wanting the word "paste" or "sqrt" to appear in the displayed version of the expression.
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