1

I'm writing a document to be PDF exported in org, and I'm also collaborating with a proof reader. I send her exports on ODT so she can open the documents and make edits in an easy way for her.

I have a complex part that I'm directly writing in latex so I can export it to the pdf, but I also wrote the part in plain text using tables so she can check it, each one on it's own tree.

Is there a way to mark one tree to only export on ODT and the other to only export on Latex?

So far I'm using the :noexport: tag, but switching between exports is tedious.

4

You can use tags to differentiate the sections:

* Section one
This section will be exported always.

* Section two      :export_latex:
This section should only be exported with the LaTeX/PDF exporter.

* Section three    :export_odt:
This section should only be exported with the ODT exporter.

The trick is to then define the appropriate set of noexport tags: you basically want to define the equivalent of

#+EXCLUDE_TAGS: export_latex

when you export to ODT and

#+EXCLUDE_TAGS: export_odt

when you export to LaTeX/PDF.

So instead of fiddling around with adding and removing tags, you can add the above tags permanently, add both #+EXCLUDE_TAGS lines to the file and then comment/uncomment appropriately:

# #+EXCLUDE_TAGS: export_latex
#+EXCLUDE_TAGS: export_odt

for LaTeX/PDF export and

#+EXCLUDE_TAGS: export_latex
# #+EXCLUDE_TAGS: export_odt

for ODT export.

That should work better than your current method but it still involves fiddling every time you export, so the next step would be to do these settings through two different functions exporting to the two different formats. Here's an implementation with the two functions bound to C-<f11> and C-<f12> resp. (which only works in GUI Emacs AFAIK, so you should probably decide your own key bindings):

#+OPTIONS: tags:nil

  
* foo
** Section one
 This section will be exported always.

** Section two                        :export_latex:
 This section should only be exported with the LaTeX/PDF exporter.

** Section three                      :export_odt:
 This section should only be exported with the ODT exporter.


 
* Code                                :noexport:

#+begin_src emacs-lisp
  (defun ndk/org-export-as-latex ()
     (interactive)
     (let ((org-export-exclude-tags '("export_odt" "noexport")))
        (org-open-file (org-latex-export-to-pdf))))

  (defun ndk/org-export-as-odt ()
     (interactive)
     (let ((org-export-exclude-tags '("export_latex" "noexport")))
        (org-open-file (org-odt-export-to-odt))))

  (define-key org-mode-map (kbd "C-<f11>") #'ndk/org-export-as-odt)
  (define-key org-mode-map (kbd "C-<f12>") #'ndk/org-export-as-latex)
#+end_src

With that, you should be able to export in either of the two formats with the press of a key.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.