2

I have a Macro in TexStudio that does the following:

%SCRIPT
txt = cursor.selectedText()

editor.write("\\underbrace{"+txt+"}_{}")

cursor.clearSelection()

That is I select a text, it will be filled in between the first two brackets of underbrace. I would like to add that my cursor should be in the between the second pair of brackets, however the solutions I found so far in the internet have not helped. Does anybody have an idea?

Great thanks!

1

1 Answer 1

1

Found a solution:

%SCRIPT
txt = cursor.selectedText()
editor.write("\\underbrace{"+txt+"}_{}")
cursor.movePosition(1,cursorEnums.Left)

How it works is the following: I save what I selected with my cursor in txt. Then I go ahead and write "\underbrace{txt}_{}", where txt will be substituted with what I selected before. The cursor will be afterwards at the end, therefore going one step to the left will land my cursor inside the two curly brackets.

1
  • Please explain your answer.
    – osjerick
    Nov 19, 2015 at 14:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .