0

When I type an underscore _ in org-mode, it automatically generates math mode, i.e. $_{}$ and it puts the cursor between the braces. Is there a way to disable this when in edit mode but not in math mode?

  • What does C-h c _ RET say? It should say _ runs the command org-self-insert-command. If you have any minor modes enabled, what are they? What do you mean by edit mode and math mode in this context? What IS the context? – NickD Mar 10 at 18:07
  • Since the underscore is the emphasis char for underlining I cannot imagine that what you describe is standard behavior. I guess you cannot reproduce the effect if you start emacs with emacs -Q. We cannot help you if you do not tell us what in your setup causes that behavior. On the other hand I assume that if you tell us the cause the solution will be quite simple. – Tobias Mar 10 at 22:35
  • @NickD @Tobias thank you, you are both right. I now understand that this was a feature of the cdlatex layer I am using. Therefore the question is kind of redundant. Do you think it is better to simply delete it? – bobsacameno Mar 11 at 18:40
  • Not necessarily: it might help somebody who does the same thing that you did. But that assumes that you can put a reasonably complete answer together (and yes, you can can answer your own question): without that, the question would be useless, but if you can explain what caused the problem and how to avoid it, that would be great - I, for one, would read it with interest. – NickD Mar 11 at 19:23
1

At the end my question is not very smart. I am using cdlatex to type equations and math easily in orgmode. Then the answer is in the documentation under "PAIR INSERTION of (), [], {}, and $$":

Also, the keys _ and ^ will insert "_{}" and "^{}", respectively, and, if necessary, also a pair of dollar signs to switch to math mode.

I didn't assume that this layer operates outside of equations, so I did not know this is the issue.

I am not sure if this is the desired behavior of cdlatex or not. Personally, I would prefer to be able to write underscores without the automatic addition of _${}$.

UPDATE

I got the behavior I wanted by setting up properly smartparens and by using org-cdlatex-mode (note that it is not cdlatex-mode). In this way the cdlatex behavior regarding underscores described above is only implemented inside equations (namely, inside $ $, \( \), latex equations etc). When typing text, it does not generate any extra characters when typing _.

See the proper configuration in the answer of my other question here.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.