3

In latex mode, using \( ... \) is preferred over $ ... $, so in my configuration I have the following

(sp-local-pair modes "$" nil :actions :rem)
(sp-local-pair modes "\\(" "\\)" :trigger "$")

This way, when I try to insert $ the pair \( \) are inserted instead. This works well, however, for some reason if I select some text and press $ the pair \( \) are inserted after the text instead of wrapping the text with them.

If I press \( instead the selected text is wrapped correctly.

Is there a way to fix this so that if I press $ with a selected text, the text is wrapped with \( ... \)?

  • Does it work if you add :trigger-wrap "$" after :trigger "$"? – jagrg May 9 '19 at 17:05
  • No, that did not work. – Tohiko May 13 '19 at 8:37
  • I see the issue now with emacs -Q. In addition to adding :trigger-wrap "$" I also had to require smartparens-latex. If that works for you we'll have to dig there to answer your question. – jagrg May 14 '19 at 14:30
1

In addition to @jagrg suggestion (to add :trigger-wrap "$") I found everything works as expected if I don't remove the $ pair from my modes

I.e., I had to comment out this line

(sp-local-pair 'latex-mode "$" nil :actions :rem)

This line alone does the trick

(sp-local-pair 'latex-mode "\\(" "\\)" :trigger "$" :trigger-wrap "$")
| 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.