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 \( ... \)?

3
  • Does it work if you add :trigger-wrap "$" after :trigger "$"?
    – jagrg
    Commented May 9, 2019 at 17:05
  • No, that did not work.
    – Tohiko
    Commented May 13, 2019 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
    Commented May 14, 2019 at 14:30

1 Answer 1

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 "$")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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