From what I gather (I don't use them, and have never actually managed to get it to work - though this is not my issue), bibtex/biber uses a database of references, alongside an ancillary file created by TeX, to produce a bibliography, creating a file which only has references to the citations used in the core myfile.tex document.

Correct or not in my understanding of bibtex itself, I'd like to do something similar, but with a database of macros; I have rather a large file full of miscellaneous macros that I've used in various projects over the years. I'm about to submit a paper to the arXiv (my first, yay!), and it occurred to me that I don't really want to send them my whole massive, redundant macros list, nor do I want to go through it looking for the ones I've used in this document. I'd prefer if there were a package that generated a myfile.macro or something similar, that contains the macros out of the database I've called - preferably with dependencies, that I could plug-in to myfile.tex on a second run.

My question is whether someone has written a package or piece of additional software to do this? A cursory google search hasn't turned up anything, although of course I really don't know what I'm looking for, and "latex macros" is a pretty large topic. I'll be happy to do it myself, as it seems like a noble cause and a useful piece of software to have, but figured it's better to ask around than duplicate someone else's efforts and probably do a worse job at solving the problem.

  • 1
  • In my opinion, it's better to add the macros you really need in the document itself (or a particular file to be \input), rather than always loading a massive set of mostly useless commands. You can still have a “macro repository”, but just for storing definitions to be retrieved (and pasted in the current document) from. A paper I had to manage contained 250 lines of preamble; after removing the unused ones, it became about 25-30 lines.
    – egreg
    Feb 26, 2014 at 7:51
  • Thanks @cfr. I'm not sure that's really what I'm getting at - I'm not sure yet if the arXiv is unhappy with author-defined macros; it looks like their process is automated, so my thinking is that if my code compiles fine on a standard tex distro then it will compile fine there - although preprocessing is a good workaround I think. Feb 27, 2014 at 16:24
  • @egreg: I use a lot of macros, and it's quite a bit of effort to duplicate the macros file, and then pull out packages and commands until it breaks or looks bad. I may take this approach in future, but think for now I'll just submit the thing warts-and-all, or try preprocessing. Feb 27, 2014 at 16:33
  • That is probably not wise in the case of papers you plan to publish. At least, if publishing them typically requires handing over the source code. (Even if doing so requires converting them to Word, actually.) It is different for things where you just produce the PDF for printing and distribution. (It is also a bit different if you are the one stuck having to convert to Word - at least the problems are yours in that case!)
    – cfr
    Feb 27, 2014 at 21:47


You must log in to answer this question.

Browse other questions tagged .