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
-
2AFAIK, there is no
_
option. The^
option is calledorg-export-with-sub-superscripts
internally, indicating that it affects both.– NickDMar 11, 2019 at 16:50 -
1@NickD - Thanks for catching nonexistent
_
option! I’ve removed it from answer. Mar 11, 2019 at 17:17 -
Is there a way to have subscripts enabled but escape the underlines?
\_
doesn't work, which does in LaTeX. Oct 26, 2022 at 1:31 -
2@HappyFace - I use and recommend using
#OPTIONS: ^{}
which leaves underscores and hats alone and makes the syntax^{superscript}
and_{subscript}
instead. Nov 4, 2022 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. Dec 8, 2022 at 9:23
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
Somewhat hard to find, but you can just use foo \under foo
or foo\under{}foo
.
-
2
-
1
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.
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.
-
1Welcome, but sorry the rules of the site don't encourage answers of this type that should be comments. See meta.stackexchange.com/questions/214173/… . I'll a note below the other comment mentioning this, but the correct syntax is already given in another answer. Dec 8, 2022 at 9:21
-
2This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review Dec 8, 2022 at 9: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, 2022 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)