Using espanso (a text expander) to automate writing LaTeX

Reply to: Support for custom LaTeX macros

You can use a third-party text expander to insert LaTeX macros minimizing the typing effort.
The cross platform espanso for example supports forms to even fill in the arguments of a latex macro.

Here is a sample config for espanso. Note the backend: Clipboard is only needed if you want to paste a complete latex environment directly (like $x$):

backend: Clipboard
matches:
  - trigger: "\\pd "
    form: \frac{\partial {{num}}}{\partial {{denum}}}
  - trigger: "\\pdc "
    form: \left(\frac{\partial {{num}}}{\partial {{denum}}}\right)_{{index}}
  - trigger: ":x "
    replace: "$x$"

Now you just type \pd<space> in RemNote’s LaTeX Editor. It shows a form window to enter the arguments. Tab trough the inputs and submit with Ctrl + Enter.

You now have a beautiful formula without much typing effort:

image

You can also insert complete LaTeX variables/formulas directly without having to open invoke the LaTeX Editor by wrapping the macro in single $ for inline and $$ for full width LaTeX and use it in RemNote’s normal editor.

To quicky add more macros while live-texing a lecture have a text editor with the expanso config open and add them there of course using another macro:

  - trigger: ":macro"
    form: |
      - trigger: "{{trigger}}"
          replace: "{{replace}}"

Saving the config automatically reloads espanso making the new macro available for typing in RemNote.

Note that you can also use this to paste styling tags (kanban, table, …): Copy the tag in RemNote with Ctrl + Alt + S and paste it into the replace part.

7 Likes

Thank you for mentioning this @Hannes! I’m trying to make this work, but I’m not sure how to open up what is called a modulo or form (I think). I’m not sure how to get the software needed to type the “triggers” and “replace.” Would you happen to know? (I’m on Windows btw)

After you installed espanso you should be able to type :espanso anywhere to confirm it’s working. After that you follow the Getting Started guide.

Basically you can add your expansions/macros to espanso’s config file which is stored in C:\Users\YOUR_USER_NAME\AppData\Roaming\espanso\default.yml on windows. Open it in any text editor (VS Code, Sublime Text, …, notepad) to edit. You can also run espanso edit in PowerShell (that’s the built-in windows terminal, just search for that in the start menu) which opens the config in notepad.

1 Like

That helps a lot! Thank you so much as always @hannesfrank!