On 17.9.2013, at 15:24, Rasmus <ras...@gmx.us> wrote: > Hi Carsten, > > Carsten Dominik <carsten.domi...@gmail.com> writes: > >> I'd be interested to see a patch to this effect. > > For now here's the filter I use and a add-to-list that hopefully > works. It could be turned into a general function such that > > - Certain packages are only required with certain flavors of TeX > (curtsy of iftex). > - It only applies to the preamble (e.g. I don't want it in my > code-blocks). > > For me it works great because I can quickly check drafts with pdftex > (which is substantially faster on my system) and switch to xelatex or > lualatex for more serious drafts. > > (setq rasmus/org-protected-packages '(inputenc fontenc)) > (add-to-list 'org-latex-default-packages-alist '("" "iftex" nil)) > > (defun rasmus/org-latex-filter-protect-inputenc (text backend info) > "Make inputenc and fontenc only load when using pdflatex" > (when (org-export-derived-backend-p backend 'latex 'beamer) > (replace-regexp-in-string > (format "\\(\\\\usepackage\\[.*\\]{\\(%s\\)}\\)" > (mapconcat 'symbol-name pank/org-protected-packages "\\|")) > "\\\\ifPDFTeX\\1\\\\else\\\\fi" > text))) > > (add-to-list 'org-export-filter-final-output-functions > 'rasmus/org-latex-filter-protect-inputenc) > > > The output tex file looks something like this: > > \ifPDFTeX\usepackage[utf8]{inputenc}\else\fi > \ifPDFTeX\usepackage[T1]{fontenc}\else\fi
Hi Rasmus, this looks excellent. I think we will implement this as the default behavior, but only after 8.2. Does this capture all the possible cases, or are there more cases to consider? - Carsten > > BTW: I think the \else is redundant. > > –Rasmus > > -- > There are known knowns; there are things we know that we know.
signature.asc
Description: Message signed with OpenPGP using GPGMail