I think I have done something like that before. What I did was make it so
each code block would be written out to a file, e.g.
course-notes/script-%d.py and a link would be put in the exported pdf right
after that block. I do not know how you could get the captions though.

In the header I have this:
#+LATEX_HEADER: \newcommand{\LaunchBinary}[2]{%
#+LATEX_HEADER:   % #1: layer name,
#+LATEX_HEADER:   % #2: link text
#+LATEX_HEADER:   \leavevmode%
#+LATEX_HEADER:   \pdfstartlink  attr{/C [0.9 0 0] /Border [0 0 2]} user {
#+LATEX_HEADER:     /Subtype /Link
#+LATEX_HEADER:     /A <<
#+LATEX_HEADER:       /F <<
#+LATEX_HEADER:          /DOS (#1)
#+LATEX_HEADER:          /Mac (#1)
#+LATEX_HEADER:          /Unix (#1)
#+LATEX_HEADER:       >>
#+LATEX_HEADER:       /S /Launch
#+LATEX_HEADER:     >>
#+LATEX_HEADER:   } #2%
#+LATEX_HEADER:   \pdfendlink%
#+LATEX_HEADER: }

Then this code for the export. (I pasted it from my build file, so there
may be an extra parenthesis at the end)

(setq counter 0)

  (defun ox-mrkup-filter-src-block (text back-end info)
    (setq counter (+ counter 1))

    (let ((filename (format "course-notes-scripts/script-%d.py" counter)))
      (with-temp-buffer
        (insert (mapconcat 'identity (butlast (cdr (split-string text "\n"
t))) "\n"))
        (write-region (point-min) (point-max) filename))

      (format "%s

\\LaunchBinary{%s}{Open the python script (%s).}

" text filename filename)))

(let ((org-export-filter-src-block-functions '(ox-mrkup-filter-src-block)))
  (org-latex-export-to-latex async subtreep visible-only body-only
                 '(:with-author t
                                            :with-date t
                                            :with-title t
                                            :with-timestamps t
                                            :with-todo-keywords t
                                            :with-toc nil))))

maybe that is close to what you want?

John

-----------------------------------
John Kitchin
Associate Professor
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
http://kitchingroup.cheme.cmu.edu



On Sun, Jan 12, 2014 at 9:49 AM, James Harkins <jamshar...@gmail.com> wrote:

> I'm working on a set of Beamer presentations with a bunch of source
> code blocks. I would like to collect all the blocks into one text file
> per presentation, but I also need the captions and ideally a numeric
> index.
>
> That is, I'm *not* looking for the normal behavior of
> org-babel-tangle, which assembles only the source code itself without
> any other identifying information (on the assumption that the tangled
> file should be OK to be compiled). These code blocks are not part of
> one big program. They are examples that workshop participants should
> run interactively.
>
> So, for instance, where the slideshow and handouts would have a code
> block identified like so:
>
> Listing 3: Compare geometric vs. band-limited waves, aurally.
>
> ... a student should be able to open up the corresponding code file and
> find:
>
> // Listing 3: Compare geometric vs. band-limited waves, aurally.
>
> Just wondering if anyone has done this. If not, I'm sure I can hack
> something up but it would save some time if somebody has some code
> lying around.
>
> Thanks in advance --
> hjh
>
>

Reply via email to