From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: Including source when exporting in PDF Date: Fri, 06 Jan 2012 00:45:01 -0700 Message-ID: <8739bt1dhe.fsf@gmx.com> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([140.186.70.92]:34341) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rj4UG-0008W1-4k for emacs-orgmode@gnu.org; Fri, 06 Jan 2012 02:45:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rj4UE-0000HR-Ny for emacs-orgmode@gnu.org; Fri, 06 Jan 2012 02:45:16 -0500 Received: from mailout-us.gmx.com ([74.208.5.67]:54556 helo=mailout-us.mail.com) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1Rj4UE-0000Fn-Eh for emacs-orgmode@gnu.org; Fri, 06 Jan 2012 02:45:14 -0500 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Frozenlock Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Frozenlock writes: > I am a strong advocate in keeping the source of everything. > > However, a source can easily be lost if it doesn't follow the document. > In LaTeX, there's a package to attach a file to a PDF (like when you > attach a file to an email). > By doing so, the source will follow the PDF even if the common reader > have no clue what it's for, or even how to use it. > This sounds like a great Reproducible Research practice. > > Here is how I attach my org source to every document I export to PDF: > > ;; Include the source file for every exported PDF (org-mode) > (eval-after-load "org-exp" > '(defadvice org-export-as-latex (around org-export-add-source-pdf activate) > "Add the source (org file) to the resulting pdf file" > (let ((filename (buffer-name))) > ad-do-it ;do the function > (let ((latex-buffer ad-return-value)) > (set-buffer latex-buffer) > (while (re-search-forward "\\\\usepackage{.+}" nil t)); go to the > end of packages > (insert "\n\\usepackage{attachfile2}"); the package needed to attach files > (when (re-search-forward "\\\\end{document}" nil t) > (forward-line -1) > (insert > (concat > "\\vfill\n" > "\\footnotesize\n" > "The source of this document is an Org-Mode file attached here:" > "\n\\attachfile" > "{" filename "}"))) > (save-buffer))))) > > > This is by no mean a patch, but rather a quick hack. Perhaps someone > with a working knowledge of the org-export could find a way to add a > source option? > I think this practice may not actually require any changes to the Org-mode core. The attached small Org-mode file will attach itself to pdf exports using only features already present in Org-mode. --=-=-= Content-Type: text/x-org Content-Disposition: attachment; filename=with-the-source.org #+Title: this has the source included #+Author: Eric Schulte #+LaTeX_Header: \usepackage{attachfile2} A tiny latex file with the source attached. #+LaTeX: \attachfile{with-the-source.org} --=-=-= Content-Type: text/plain Thanks for sharing this idea! > > > Cheers! > -- Eric Schulte http://cs.unm.edu/~eschulte/ --=-=-=--