* Exporting to LaTeX versus Beamer: how to take different actions depending on export format?
@ 2021-07-02 19:56 Richard Stanton
2021-07-03 15:57 ` Richard Stanton
0 siblings, 1 reply; 2+ messages in thread
From: Richard Stanton @ 2021-07-02 19:56 UTC (permalink / raw)
To: orgmode
[-- Attachment #1: Type: text/plain, Size: 1940 bytes --]
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: 3123 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Exporting to LaTeX versus Beamer: how to take different actions depending on export format?
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
0 siblings, 0 replies; 2+ messages in thread
From: Richard Stanton @ 2021-07-03 15:57 UTC (permalink / raw)
To: orgmode
[-- 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,
#+beamer: \begin{adjustbox}{height=0.5\textheight}
#+begin_src python
print('Hello, world’)
#+end_src
#+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 --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-07-03 15:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
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).