I would like to use Yasnippet to insert the template for a latex inline equation: \( \)

The snippet is defined:

    # -*- Mode: snippet -*-
# name: inline equation
# key: ineq
# --
\(  \)

But Yasnippet inserts only the parentheses ( ) without the backslashes. Any suggestions?

  • 1
    You need to escape the backslash with another backslash – Dan Apr 15 '17 at 1:46

The backslash is used in regular expressions to escape individual characters:

For the most part, \ followed by any character matches only that character.

So \( gives you ( in your output. To get the backslash in the output, escape it:

\\( \\)

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.