emacs-orgmode@gnu.org archives
help / color / mirror / code / Atom feed
From: Richard Stanton <rhstanton@berkeley.edu>
To: orgmode <emacs-orgmode@gnu.org>
Subject: Re: Exporting to LaTeX versus Beamer: how to take different actions depending on export format?
Date: Sat, 3 Jul 2021 08:57:49 -0700	[thread overview]
Message-ID: <5405F77D-B247-46D5-B4A3-B995CC126E87@berkeley.edu> (raw)

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

I’ve found a few partial solutions:

1)

#+begin_src emacs-lisp :results raw :exports (if (eq org-export-current-backend 'beamer) "results" "none")
(eval (concat "#+begin_src python\n  print('Hello, world')\n#+end_src"))
#+end_src

This prints the python code if exporting to Beamer and not if exporting to LaTeX, but the code is not now live, which rather undermines the best feature of org-mode!

2) Include the code twice, with conditional statements around it each time, so you can export one version to LaTeX and another version to Beamer. OK, but inelegant

3) Instead of trying to modify the listing options, surround the code block with some scaling statements that are called only in Beamer, e..g,

#+begin_src python
print('Hello, world’)
#+end_src

None of these is quite perfect, but they mostly do what I want, especially #3.

> On Jul 2, 2021, at 12:56 PM, Richard Stanton <rhstanton@berkeley.edu> wrote:
>
> I’ve been experimenting with using a single org file to generate an article when exported to LaTeX (or HTML) and a Beamer presentation when exported to Beamer, without requiring any edits to the org file itself.
>
> For this to be really useful, the exporter has to be able to do different things depending on which output format you’ve asked for.
>
> 1) At a minimum, you need to be able to have text included in the article that is not included in the Beamer presentation and vice versa, so that you can have, say, a paragraph in the article vs. an itemized list in the Beamer presentation. This can be taken care of relatively easily using one of several conditional-compilation packages available for LaTeX. If people are interested, I’ve uploaded a simple example to https://faculty.haas.berkeley.edu/stanton/orgLatexBeamer/ <https://faculty.haas.berkeley.edu/stanton/orgLatexBeamer/>
>
> 2) However, some things are not so easy. For example, suppose I’m using the listings package to include some code in my document, e.g.,
>
> #+begin_src python
>   print(“Hello, world”)
> #+end_src
>
> This works fine as long as I’m OK with the default output format. But suppose this listing is too long for my slide so I want to make the text smaller than normal. I can do that quite easily for both article and presentation output by putting a line like
>
> #+attr_latex: :options basicstyle=\tiny
>
> immediately before the source block. But suppose I only want to do this in the Beamer output and not in the LaTeX article output? I’ve tried
>
> #+attr_beamer: :options basicstyle=\tiny
>
> but this doesn’t seem to work. And even if it did, what if I wanted the change in font size to occur only when I’m exporting to LaTeX but not Beamer? How can I do conditional things like this at the org-file level based on whether I’m exporting to LaTeX or Beamer?
>
> Thanks for any suggestions.
>
> Richard Stanton
>
>
>
>
>
>
>
>
>
>
>

[-- Attachment #2: Type: text/html, Size: 5124 bytes --]


     prev parent reply	other threads:[~2021-07-03 15:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-02 19:56 Richard Stanton
2021-07-03 15:57  Richard Stanton [this message]


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,

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

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

switches of git-send-email(1):

git send-email \
--to=rhstanton@berkeley.edu \
--cc=emacs-orgmode@gnu.org \

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


Code repositories for project(s) associated with this public inbox
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).`