Roger Mason <rma...@mun.ca> writes: > Unfortunately, :exports both does not make any difference. Looking at > the generated LaTeX file I see that it contains: > > \begin{verbatim} > (defun margin-graphics (contents backend info) > (when (eq backend 'latex) > (replace-regexp-in-string "\\`\\\\includegraphics.+\\({.+}\\)" > "\\\\marginpar{\\\\includegraphics[width=0.9\\\\marginparwidth]\\1} " > contents))) > > (add-to-list 'org-export-filter-link-functions 'margin-graphics) > \end{verbatim} > > which seems odd.
It is to be expected since ":exports both" is meant to leave source code behind. Anyway, the following works for me (I had to tweak your regexp): --8<---------------cut here---------------start------------->8--- #+LATEX_HEADER: \usepackage[right=2in,left=0.5in]{geometry} #+LATEX_HEADER: \usepackage{parskip} * Setup :noexport: #+BEGIN_SRC emacs-lisp :exports both (defun margin-graphics (contents backend info) (when (eq backend 'latex) (replace-regexp-in-string "\\`\\\\includegraphics.*?\\({.+}\\)" "\\\\marginpar{\\\\includegraphics[width=0.9\\\\marginparwidth]\\1} " contents))) (add-to-list (make-local-variable 'org-export-filter-link-functions) 'margin-graphics) #+END_SRC * Document [[file:~/Documents/work/2-data/images/2-echantillonnage-1-fluctuations-fig1.png]] --8<---------------cut here---------------end--------------->8--- I suggest to use `make-local-variable' to keep global filters list clean. Regards, -- Nicolas Goaziou