Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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).

share|improve this question
add comment

2 Answers

up vote 5 down vote accepted

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.

share|improve this answer
    
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
    
Just type the macros in the style file how you would normally. It doesn't need any special formatting. If you know C, pretend it's like a C include file. :) But as an example, you could very well just have \usepackage{amsmath,amsfonts} \newcommand{\Integers}{\mathbb{Z}} \newcommand{\Naturals}{\mathbb{N}} in the file. Then just \usepackage{rachum} or \input{rachum.sty} and you should be good to go. –  Quadrescence Jul 26 '10 at 19:40
    
Ooooh, I like pretend! Thanks! –  Amir Rachum Jul 26 '10 at 19:41
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.