3

I have been trying to create the following macro in TeXStudio(seen in the picture below):

\begin{align*}
    %|
\end{align*}

but when I activate it in my tex file I get this:

\begin{align*}
(cursor here) 
\end{align*}

with no tab before the cursor. How can I create the macro to include the tab before the cursor. Also, are there any in depth articles/tutorials regarding macros in TeXstudio?

picture of macro example

2

You can achieve this by using a little bit of Javascript (more detail can be found here):

%SCRIPT
editor.write("\\begin{align*}\n\n\\end{align*}");
cursor.movePosition(1, cursorEnums.PreviousLine, cursorEnums.MoveAnchor);
editor.write("\t");

Result:

enter image description here

  • Ok, thanks! So I guess there is no way to do it with a simple text replace (not that it matters much, but do you know why the text macro editor does not include spacing)? Also, where would be a good place to start learning Java Script for the sole purpose of making advanced macros (assuming a fairly strong programming/scripting background? – walwb Dec 23 '15 at 23:59
  • @walwb: I don't think I can answer that, the only reason I "learn" Javascript was in fact that to write some fairly simple scripts in TeXstudio. All I did is Googling around. – Francis Dec 24 '15 at 0:04

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.