# Automatically define macros in LyX documents

I'm using LyX all the time and over the last 2 years I've accumulated some very handy macros for my lecture notes. As it is today, every time I start a new document, I copy and paste the macros from one of my other documents. Is it possible, somehow, to automatically load macros for all files?

(I asked this on SO a while back and got no answers. I hope in this new home I'll get a response).

-

I am not sure if you mean LyX macros or not. But if they are standard LaTeX macros, you can make your own style file, say "rachum.sty". Put all of your macros in there, and then have it included in the preamble by default.

This is useful for (La)TeX users in general. I have a lot of common things in my own file, such as \newcommand{\Integers}{\mathbb{Z}} and such.

-
I guess I meant LaTeX macros, it's just that LyX has this pretty graphical representation of them that I don't think of it in terms of LaTeX :) I would, however, appreciate it if you could tell me what the format of the .sty file should be (headers, etc.) and what the command is to include it. Thanks. –  Amir Rachum Jul 26 '10 at 19:34
Ooooh, I like pretend! Thanks! –  Amir Rachum Jul 26 '10 at 19:41

You can put all your macros in the Preamble in Documents → Settings, then click Save as Document Defaults.

These macros should then be present in every new LyX document.

-