I am doing my undergraduate work in Electrical Engineering and I choose LaTeX as the tool for the job and TexStudio as my LaTeX editor. I had a pretty nice walk through LaTeX, but I begin to wonder what about some advanced stuff such as changing/modifying the handling of existing commands in the editor. My particular need is to make a \begin{myflalign/myflalign*} environment and configure the editor such that it would insert this code:

    &  &

and position my cursor in between two & signs.

I do a lot of aligning and find that this command really suits me well and I only need a slight improvement of an existing command.

  • 4
    Welcome to Tex.SX. I don't understand your question. Do you want a new environment (myflalign), or do you want to configure your editor to automatically complete an environment and position the cursor? If you need a new environment, what do you want it to do? – Ian Thompson Aug 22 '13 at 22:24
  • This may be editor-specific, and not every editor can/will be able to do this. For a complete list of available editors, see LaTeX Editors/IDEs. – Werner Aug 22 '13 at 22:57
  • Well I guess it is editor specific! And yes I want to configure editor to automatically complete and env and position the cursor... I use TexStudio, do you think this is doable? – Zlatko Alomerovic Aug 23 '13 at 11:00
  • @djudji Did you have a look at personal and environment macros? – ojdo Dec 4 '15 at 17:00
  • @djudji If my answer was helpful for you, I would kindly ask you to accept it by clicking on the tickmark below its vote count (see How do you accept an answer?). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers and would also raise your reputation. If there are any points left open, please add all necessary information to solve them. – cryingshadow Dec 7 '15 at 12:26

You can define a personal macro (see the manual, Section 4.5). Since you would also like to position the cursor, it should be a script macro. Choose a name and a trigger (I chose myenv as the name and %myenv as the trigger). Whenever you type in the trigger, the trigger text will be removed and the script will be executed. The following script will do the trick:

cursor.insertText("   &  & ");
cursor.movePosition(1, cursorEnums.PreviousLine);
cursor.movePosition(1, cursorEnums.StartOfLine);
cursor.movePosition(5, cursorEnums.Right);

It inserts the beginning of your environment, inserts a new line, inserts the & symbols, another new line, and the end of the environment. Then it positions the cursor by going one line upwards, then to the beginning of the current line, and finally 5 columns to the right to end up between the two & symbols.

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.