I am using org-mode
, and the document I am writing has a table name whose name looks like this: tab_weekly_report
. When I export the document to HTML, I expect the name to exported as tab_weekly_report
, but org-mode
treats _
specially (as a markup character). How can I avoid this?
6 Answers
org-mode
exports _
as subscripts and ^
as superscripts
The default export behavior can be customized using the menus Org -> Customize -> Browse Org Group
.
To update the default behavior for subscripts & superscripts, choose:
- [-]-\ Group Org Export
- [-]-\ Group Org Export General
- — Option Org Export With Sub Superscripts
- [-]-\ Group Org Export General
Org Export With Sub Superscripts Examples
Examples
Interpret them - Default
- Underscore_subscript becomes Underscoresubscript
- Hat^superscript becomes Hatsuperscript
Curly brackets only
- Underscore_WithCurlyBrackets_{subscript} becomes Underscore_WithCurlyBracketssubscript
- Hat^WithCurlyBrackets^{superscript} becomes Hat^WithCurlyBracketssuperscript
Do not interpret them
- Underscore_subscript becomes Underscore_subscript
- Hat^superscript becomes Hat^superscript
- Underscore_WithCurlyBrackets_{subscript} becomes Underscore_WithCurlyBrackets_{subscript}
- Hat^WithCurlyBrackets^{superscript} becomes Hat^WithCurlyBrackets^{superscript}
Note: If you don't want to mess around with settings, the quick and easy solution is to disable superscripts and subscripts by setting export option for
^
tonil
.
To disable superscripts and subscripts, add the following lines to your org file:
#+OPTIONS: ^:nil

- 4,504
- 1
- 25
- 43
-
2AFAIK, there is no `_` option. The `^` option is called `org-export-with-sub-superscripts` internally, indicating that it affects both. – NickD Mar 11 '19 at 16:50
-
1@NickD - Thanks for catching nonexistent `_` option! I’ve removed it from answer. – Melioratus Mar 11 '19 at 17:17
-
Is there a way to have subscripts enabled but escape the underlines? `\_` doesn't work, which does in LaTeX. – HappyFace Oct 26 '22 at 01:31
-
1@HappyFace - I use and recommend using `#OPTIONS: ^{}` which leaves underscores and hats alone and makes the syntax `^{superscript}` and `_{subscript}` instead. – Melioratus Nov 04 '22 at 17:05
-
1@Melioratus As pointed out by a news user who doesn't how comment rights, there is a colon missing between the caret and the braces, so it should be `^:{}` instead of `^{}`, as in the answer of Joseph Tesfaye. – Andrew Swann Dec 08 '22 at 09:23
-
Thank you. I am exporting SQL queries, and table results. I have "low line"* in some of my column names. This paper doesn't require subscript, so the simple fix works. – JonathanPeel Dec 24 '22 at 18:33
Add the following at the beginning of your file.
#+OPTIONS: ^:nil
It should do the trick. If it doesn't, I'd check org-symbols: http://orgmode.org/worg/org-symbols.html

- 385
- 2
- 8
By default the underscore "_" and caret "^" characters are treated as markers of subscripts and superscripts when exporting with org-mode or pandoc. To export them as they are you can add the line
#+OPTIONS: ^:{}
to your org file and then use either org-mode or pandoc to export. If you are using pandoc-mode make sure the region to be exported also include this line before the underscore and caret characters.

- 389
- 2
- 13
Summarizing and refining @Melioratus answer/commentary (which is the currently -- 2022-12-07 -- the top and accepted answer)
You can add this directive to your file to prevent underscores getting interpreted as subscripts.
#+OPTIONS: ^:nil
...or even better, this...
#+OPTIONS: ^:{}
@Melioratus had mentioned the latter in a comment but it did not work for me. Experimentation has shown that if I change @Melioratus's comment from...
#OPTIONS: ^{}
...to...
#+OPTIONS: ^:{}
...then it works as described.

- 419
- 1
- 6
- 20

- 11
- 2
-
1Welcome, but sorry the rules of the site don't encourage answers of this type that should be comments. See https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead . I'll a note below the other comment mentioning this, but the correct syntax is already given in another answer. – Andrew Swann Dec 08 '22 at 09:21
-
2This does not provide an answer to the question. Once you have sufficient [reputation](https://emacs.stackexchange.com/help/whats-reputation) you will be able to [comment on any post](https://emacs.stackexchange.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/23334) – Andrew Swann Dec 08 '22 at 09:21
-
I saw the comment in the post about answering in the comments - please don't answer in comments - answer with an actual answer. - Can you address the concerns about this answer not actually addressing the question? If not, this answer is likely to be deleted. – Aaron Hall Dec 19 '22 at 23:20
If you want to include it in your config directly, instead of setting the option in each file:
(setq org-use-sub-superscripts nil)
(setq org-export-with-sub-superscripts nil)

- 1
- 1