William Denton <w...@pobox.com> writes:
> I have another question related to managing a book I'm doing building for > export to LaTeX: > what do people do for managing all of the headers? > I only use the #+latex_headers or #+latext-headers-extra lines for 'one off' type documents. If I'm going to be writing lots of documents where those packages are needed, I define a new org-latex-classes entry. > It's possible to add a new class to the org-latex-classes variable, and in > the documentation on > it I see there are options ([NO-DEFAULT-PACKAGES], [NO-PACKAGES], [NO-EXTRA]) > that allow one to > trim away all the default headers. That makes it easy to take away, but not > to add in lines I > want, short of managing them in my init file. The org-latex-classes 'placeholder' macros allow you to add or remove the headers defined in either the default-packages or packages alist or headers added via latex_headers/latex_headers_extra. However, the point to note is that this 'value' is just a string, so you can just put in exactly what you want - you don't have to use the placeholder macros (though I almost always do - at least the [default-packages] macro, but usually the [packages] one as well). The value isn't just restricted to \usepackage lines either - you can put anything there which makes sense in the latgex header. > > What sorts of practices do people have for managing lots of LaTeX headers? > Juan Manuel Macías, > you mentioned something like this---literate programming in Org to export > LaTeX source---may I > ask how you do it? > If I find myself using lots of #+latex_headers lines, this tells me either 1. I need to update/add to the packages alist variable. This is especially likely if I'm adding the same headers to every document. Just add it to the packages alist. I tend to leave the default-packages alist alone. 2. There is a specific 'style' of document I write often and all documents of this style have the same additional headers. For this, I create a new entry in org-latex-classes. I think adding headers via #+latex_headers and #+latext_headers_extra should be avoided as much as possible. It is a great escape hatch or for doing 'on-offs', but not the right approach for doing something like writing a book. Consider the situation where you have been adding headers to load language support or a particular code listing package or whatever. You writing a book and it will have many org files (perhaps one per chapter). You add these #+latex_header lines to add the packages. Later, you find the listing package isn't suitable or you need to modify the language encoding - now you have to edit every org file which makes up the book. Alternatively, you define a new org-latex-classes entry call 'my-book' and use that to add the language encoding and code listing packages (along with some other 'tweaks' you typically put in the header, maybe even add a few custom commands etc). Now when you find it necessary to change the language encoding, code listing package or whatever, you just have that one definition to change and only need to edit one file.