On Mon, Oct 28 2024, David Masterson <dsmasterson92...@outlook.com> wrote:

> Does anyone have a recommendation on how to structure an Org document
> such that it can be exported to either Latex or Beamer? Suppose you
> have a (small) thesis that you are writing and you want to generate
> Beamer slides of a high-level view of the document, but also generate
> a PDF for the whole document.   I suppose you could break it into two
> files, but then you'd have to copy (certain) changes from file to
> file.  I was wondering if it could be done with one file such that
> updates to the master document are simultaneously reflected in the
> Beamer slides.  Is this going to involve liberal use of
> #+BEGIN...#+END blocks?
>
> David Masterson
>
>

I think I would add the tags

#+TAGS: beameronly latexonly noexport

and then define an elisp function that changes beameronly tags to
noexport when the export backend is latex and similar for latexonly.
Add that function to the `org-export-before-processing-functions' so it
gets executed before export begins.

Attached is an example.

Note that you likely would need to fiddle with conditionally loading
packages, depending on the export backend.

Best regards,
Leo

#+TITLE: LaTeX and Beamer
#+TAGS: beameronly(b) latexonly(l) noexport(n)
#+OPTIONS: tags:nil

* Code                                                             :noexport:
#+begin_src elisp
  (defun ltb-org-export-filter (backend)
    (let ((regex (cl-case backend
  		 (latex ":beameronly:")
  		 (beamer ":latexonly:")
  		 (t nil))))
      (when regex
        (save-excursion
  	(goto-char (point-min))
  	(while (search-forward-regexp regex nil t)
  	  (replace-match ":noexport:"))))))
  (add-hook 'org-export-before-processing-functions 'ltb-org-export-filter)
#+end_src

* Some Beamer stuff                                              :beameronly:
** Frame 1                                                          :B_frame:
:PROPERTIES:
:BEAMER_env: frame
:END:
* Some LaTeX stuff                                                :latexonly:
In the beginning, there was \TeX{}.
* Other stuff
The end

Reply via email to