First approach: I first tried to create the normal macro in TexStudio


but TexStudio has problem with it, I assume because of the double backslash. If I leave TexStudio and start it again the macro is mutilated. I should fill a bug.

Step 1: enter image description here

Step 2: The macro works: enter image description here

Step 3: I leave the edit and start it again, result: enter image description here

Second approach: now I tried this script:

editor.write("\\begin{cases}???&\\text{}\\\\ \n")
----------   from here -------------
cursor.movePosition(3,,cursorEnums.Right, cursorEnums.KeepAnchor);

the Qt script does what I wanted initially do, but in the second part I want to select the "???" and I don't now which method has to be used . The error is at selectionStart.

Approach 1: Is a known issue? Work around?

Approach 2: How can I solve the problem? is the cursor an instance of this: Qt documentation?

Here a similar question: Macro phrase selection and line selection for texstudio, that does need a general curson movement.

Also interesting would be to be able in the script to produce a placeholder, but that is perhaps too much.

  • What do you expect when run the macro? \begin{cases} &\text{%|}\\ \end{cases} produces the cases environment with cursor positioned inside the braces. – Sigur Jun 29 at 13:50
  • @Sigur Approach 1? Yes, just copy and paste of the code where %| is meant to place the cursor – PeptideChain Jun 29 at 13:56
  • @Sigur Have you left the editor , started it again, and used the macro again? – PeptideChain Jun 29 at 13:59
  • Yes. It works well. Simply type that command in the macro editor in the Normal, not Script nor Environment. – Sigur Jun 29 at 14:00
  • @Sigur For me it does not work. I don't know why. Thus the second approach is the only one for me. – PeptideChain Jun 29 at 14:02

Your Answer

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

Browse other questions tagged or ask your own question.