2

I have been a texstudio user for quite some time now and recently I have started using macros but I haven't been able to figure out how to define something that does the following:

I start to write a sentence and when I reach the end and write the full stop sign . I would like to automatically insert a space caracter and then a CR (enter press) to move the cursor on the next line and start again.

I have been writing my documents like this because it is easier for me keep track of the text. I am not sure if such a macro is possible or if it is, it will break functionality in other places. I imagine that this macro must be active outside math, figure or table environments.

Cheers

  • How do you treat abbreviations? – TeXnician Aug 2 '17 at 18:52
  • I would imagine that for those cases I would have to delete the new line and get back to the line where the abbreviated word appeared. I didn't think about abbreviations! I just thought that a macro to automatically take me to a new line would be cool and work well with my workflow – lucian Aug 2 '17 at 18:56
2

Choose Macros -> Edit macros from the menu. Click add, enter some name and abbreviation of choice. Type \. under trigger, and a dot, a space, and a carriage return under latex content (see screenshot). I just tested that it works.

enter image description here

Edit: to suppress the behaviour in math mode, we can add another macro defined only in math mode that just inserts a dot when a dot is typed:

enter image description here

Although it is not self-evident that this should be so, the math mode macro seems to take precedence over the generic one, which produces the desired behaviour - dot augmented by space and new line in text mode, no change in math mode.

  • It works! but unfortunately it works everywhere. is there a way to disable it automatically inside math environment for example? This example activates the macro only inside a math environment. Can it be made to do the reverse in my case? I don't really understand the syntax. – lucian Aug 2 '17 at 22:05
  • See edited answer. – Michael Palmer Aug 2 '17 at 22:23
  • Perfect! I will accept this as the answer to this problem! Thank you! – lucian Aug 3 '17 at 7:25

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.