emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eric Schulte <eric.schulte@gmx.com>
To: Frozenlock <frozenlock@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Including source when exporting in PDF
Date: Fri, 06 Jan 2012 00:45:01 -0700	[thread overview]
Message-ID: <8739bt1dhe.fsf@gmx.com> (raw)
In-Reply-To: CACjB3dt-=EY65JuujYy3vdDk+AXFLcW1+nFFB1fR6K_2q0s6QA@mail.gmail.com

[-- Attachment #1: Type: text/plain, Size: 1765 bytes --]

Frozenlock <frozenlock@gmail.com> 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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: with-the-source.org --]
[-- Type: text/x-org, Size: 189 bytes --]

#+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}

[-- Attachment #3: Type: text/plain, Size: 95 bytes --]


Thanks for sharing this idea!

>
>
> Cheers!
>

-- 
Eric Schulte
http://cs.unm.edu/~eschulte/

  reply	other threads:[~2012-01-06  7:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-04 21:29 Including source when exporting in PDF Frozenlock
2012-01-06  7:45 ` Eric Schulte [this message]
2012-01-11 15:28   ` Rainer M Krug
2012-01-12  2:06     ` Frozenlock
2012-01-12  9:11       ` Rainer M Krug
2012-01-12 13:54         ` Frozenlock
2012-01-12 13:59           ` Rainer M Krug
2012-01-15  5:29             ` Frozenlock
2012-01-16 11:21               ` [BUG?][babel] " Rainer M Krug
2012-01-18  0:57                 ` Frozenlock
2012-01-18  9:03                   ` Rainer M Krug
2012-01-20 18:12                     ` Eric Schulte

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8739bt1dhe.fsf@gmx.com \
    --to=eric.schulte@gmx.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=frozenlock@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).