in markdown, my_stock_index
is mystockindex. But I want it to show my_stock_index
. How can do that?
Asked
Active
Viewed 1.3e+01k times
183

GoingMyWay
- 16,802
- 32
- 96
- 149
-
1Which implementation of Markdown are you using? – ChrisGPT was on strike Mar 06 '16 at 14:20
-
@Chris, Markdown Pad – GoingMyWay Mar 07 '16 at 05:00
-
@Chris do you mean that this isn't standard behavior? – lulalala Apr 12 '18 at 01:36
-
@lulalala, many Markdown questions on SO target some implementation other than [the original](https://daringfireball.net/projects/markdown/) and some common implementations handle this differently, e.g. [GitHub Flavored Markdown](https://github.github.com/gfm/#emphasis-and-strong-emphasis) and [GitLab Flavored Markdown](https://docs.gitlab.com/ee/user/markdown.html#multiple-underscores-in-words). – ChrisGPT was on strike Apr 12 '18 at 02:25
3 Answers
248
You just escape it with a backslash:
my\_stock\_ticker
is what you type to get my_stock_ticker
The syntax seems to work for all markdown parsers. However, php markdown parsers use the numeric character reference _
instead of the actual character in it's output.

Steve Clanton
- 4,064
- 3
- 32
- 38
-
This does not seem to work on github markdown ... It converts the letters to subscript instead. – Finomnis Jun 28 '23 at 16:40
35
There is also the option to use backticks. This is actually used to refer to mark the text as inline code, but where else would you use underscores right? Besides it is much easier than managing the backslash stuff :)
`my_stock_index`

tacan
- 450
- 5
- 4
-
Thanks! This is a good solution when you don't have control over the individual characters and can't necessarily escape them – TheHanna Apr 09 '20 at 17:01
-
You are right, "where else would I use underscores"? :) – Francesco Marchetti-Stasi Sep 04 '20 at 10:08
-
30
The single backslash escape works fine in Jupyter unless you are in an italicized block, in which case, you want to close the italicized block, write the escaped underscore, then start the italicized block again.
_the cookie_\__cutter in italics_

Robert Casey
- 1,511
- 18
- 19
-
18Or you can use `*the cookie\_cutter in italics*` and avoid the extra closing. – Carlos Sep 12 '18 at 15:34
-