8

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

5

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
  • 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
  • while this is very convenient for a user's own documents, if you are submitting a document for publication, please move just those definitions actually used in the document into that document's preamble. extraneous, unused definitions can cause a great deal of confusion in a publishing production environment, and can lead to errors that you weren't expecting when changes must be made to conform to the publication's requirements. – barbara beeton Mar 28 '18 at 12:57
7

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.

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.