I want to write a degree symbol in an rmarkdown file that is rendered correctly both for HTML and PDF output. A regular °
works for HTML, and a $^\circ$
works for the PDF - but what works for both cases?
$$ \textdegree $$ or $\textdegree$
The keyboard shortcut for the degree symbol is Alt + 0176. To type the degree symbol using your Windows computer keyboard, hold down the Alt key and then type 0176 on the number pad (located at the rightmost portion of the keyboard).
to your preamble, that should enable the command. Another alternative is the \textdegree command, which is provided by the textcomp package. And, finally, $^{\circ}$ is another way of obtaining roughly the right symbol.
Use °
i.e. 75°F
turns into 75°F in both HTML and PDF outputs.
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