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)
In-Reply-To: <16BF3CE5-AD4F-4BAB-9C18-D51DA66C36B6@berkeley.edu>

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

I’ve found a few partial solutions:


#+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"))

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,

#+beamer: \begin{adjustbox}{height=0.5\textheight}
#+begin_src python
  print('Hello, world’)
#+beamer: \end{adjustbox}

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 --]

      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 Exporting to LaTeX versus Beamer: how to take different actions depending on export format? 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,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  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=5405F77D-B247-46D5-B4A3-B995CC126E87@berkeley.edu \
    --to=rhstanton@berkeley.edu \
    --cc=emacs-orgmode@gnu.org \


* 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


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).