emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Missing line breaks in Beamer with alltt
@ 2020-11-29  9:22 Jarmo Hurri
  2020-11-29 12:33 ` Eric S Fraga
  0 siblings, 1 reply; 8+ messages in thread
From: Jarmo Hurri @ 2020-11-29  9:22 UTC (permalink / raw)
  To: emacs-orgmode


Greetings.

Any ideas?

# ----------------------------------------------------------------------------------
#+startup: beamer

#+latex_header: \usepackage{alltt}

* A slide with some code
  - export to beamer pdf with =C-e l O=
  - line breaks disappear from this:
    #+begin_alltt 
    x \in {0, 1, ..., n}
    z \leftarrow x + 1
    #+end_alltt

* An effort to fix this
  - tip from
    https://tex.stackexchange.com/questions/68064/beamer-alltt-environment-and-only
  - the effort is here, but the end result is an error
    #+begin_src latex
      \defverbatim\SomeCode{
      \begin{alltt}
      x \in {0, 1, ..., n}
      z \leftarrow x + 1
      \end{alltt}
      }
    #+end_src

    \SomeCode
# ----------------------------------------------------------------------------------

All the best, and stay safe.

Jarmo



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Missing line breaks in Beamer with alltt
  2020-11-29  9:22 Missing line breaks in Beamer with alltt Jarmo Hurri
@ 2020-11-29 12:33 ` Eric S Fraga
  2020-11-30  5:03   ` Jarmo Hurri
  0 siblings, 1 reply; 8+ messages in thread
From: Eric S Fraga @ 2020-11-29 12:33 UTC (permalink / raw)
  To: Jarmo Hurri; +Cc: emacs-orgmode

On Sunday, 29 Nov 2020 at 11:22, Jarmo Hurri wrote:
> Any ideas?

First of all, the first frame works just fine for me.  Line breaks are
preserved.  However, I do know that in the past I have had problems with
alltt environments in beamer.  I tend to use one of the algorithm
packages instead.

Your second frame leads to an error because the \in and \leftarrow are
not in math mode.  Because your LaTeX code is explicitly in an export
LaTeX environment, org doesn't do its usual magic with LaTeX entities so
you need to put the maths delimiters yourself:

>     #+begin_src latex
>       \defverbatim\SomeCode{
>       \begin{alltt}
>       x $\in$ {0, 1, ..., n}
>       z $\leftarrow$ x + 1
>       \end{alltt}
>       }
>     #+end_src

When in doubt, export to LaTeX (C-e l b) and have a look at the
LaTeX.  Also then run pdflatex yourself on that LaTeX code to see what
errors come up.

HTH,
eric

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.4-143-g9a1549


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Missing line breaks in Beamer with alltt
  2020-11-29 12:33 ` Eric S Fraga
@ 2020-11-30  5:03   ` Jarmo Hurri
  2020-11-30  9:32     ` Eric S Fraga
  0 siblings, 1 reply; 8+ messages in thread
From: Jarmo Hurri @ 2020-11-30  5:03 UTC (permalink / raw)
  To: emacs-orgmode


Eric S Fraga <e.fraga@ucl.ac.uk> writes:

Hi there!

> On Sunday, 29 Nov 2020 at 11:22, Jarmo Hurri wrote:
>> Any ideas?
>
> First of all, the first frame works just fine for me.  Line breaks are
> preserved.

Fascinating: it has to be something in my settings. I went through my
init files and did not find anything relevant. Off to debug I go then.

> When in doubt, export to LaTeX (C-e l b) and have a look at the LaTeX.
> Also then run pdflatex yourself on that LaTeX code to see what errors
> come up.

I did that but did not notice anything weird in the latex code. Then
again, if I export to regular latex, line breaks are preserved just
fine. Therefore, this has to be related to some beamer settings (or my
texlive version or something like that).

Thanks for pointing me in the right direction.

All the best, and stay safe.

Jarmo



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Missing line breaks in Beamer with alltt
  2020-11-30  5:03   ` Jarmo Hurri
@ 2020-11-30  9:32     ` Eric S Fraga
  2020-12-03 16:07       ` Jarmo Hurri
  0 siblings, 1 reply; 8+ messages in thread
From: Eric S Fraga @ 2020-11-30  9:32 UTC (permalink / raw)
  To: Jarmo Hurri; +Cc: emacs-orgmode

On Monday, 30 Nov 2020 at 07:03, Jarmo Hurri wrote:
> Fascinating: it has to be something in my settings. I went through my
> init files and did not find anything relevant. Off to debug I go then.

Maybe post the offending LaTeX for that frame?  Happy to try to help.

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.4-143-g9a1549


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Missing line breaks in Beamer with alltt
  2020-11-30  9:32     ` Eric S Fraga
@ 2020-12-03 16:07       ` Jarmo Hurri
  2020-12-03 16:38         ` Eric S Fraga
  0 siblings, 1 reply; 8+ messages in thread
From: Jarmo Hurri @ 2020-12-03 16:07 UTC (permalink / raw)
  To: emacs-orgmode

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


Hi there.

Eric S Fraga <e.fraga@ucl.ac.uk> writes:

> Happy to try to help.

I will take you up on that offer! Are you able to replicate the
difference between these two slides?

# ----------------------------------------------------------------------------------
#+startup: beamer

#+latex_header: \usepackage{alltt}

* A slide with some code
  - =yes= verbatim on this line, line breaks preserved
    #+begin_alltt 
    N=5
    if S\neq I
    #+end_alltt

* Another slide
  - no verbatim on this line, line breaks not preserved
    #+begin_alltt 
    N=5
    if S\neq I
    #+end_alltt

# ----------------------------------------------------------------------------------

If you are not, then please find attached generated tex.

All the best, and stay safe.

Jarmo


[-- Attachment #2: latex --]
[-- Type: application/x-tex, Size: 1147 bytes --]

% Created 2020-12-03 Thu 18:04
% Intended LaTeX compiler: pdflatex
\documentclass[presentation]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{grffile}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{amssymb}
\usepackage{capt-of}
\usepackage{hyperref}
\usepackage{color}
\usepackage{listings}
\usepackage{alltt}
\usetheme{default}
\date{\today}
\title{}
\hypersetup{
 pdfauthor={},
 pdftitle={},
 pdfkeywords={},
 pdfsubject={},
 pdfcreator={Emacs 27.1 (Org mode 9.4)}, 
 pdflang={English}}
\begin{document}

\begin{frame}{Outline}
\tableofcontents
\end{frame}


\begin{frame}[label={sec:orga545000},fragile]{A slide with some code}
 \begin{itemize}
\item \texttt{yes} verbatim on this line, line breaks preserved
\begin{alltt}
N=5
if S\(\neq\) I
\end{alltt}
\end{itemize}
\end{frame}

\begin{frame}[label={sec:org7a9adda}]{Another slide}
\begin{itemize}
\item no verbatim on this line, line breaks not preserved
\begin{alltt}
N=5
if S\(\neq\) I
\end{alltt}
\end{itemize}
\end{frame}
\end{document}

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Missing line breaks in Beamer with alltt
  2020-12-03 16:07       ` Jarmo Hurri
@ 2020-12-03 16:38         ` Eric S Fraga
  2020-12-04 14:03           ` Jarmo Hurri
  0 siblings, 1 reply; 8+ messages in thread
From: Eric S Fraga @ 2020-12-03 16:38 UTC (permalink / raw)
  To: Jarmo Hurri; +Cc: emacs-orgmode

On Thursday,  3 Dec 2020 at 18:07, Jarmo Hurri wrote:
> I will take you up on that offer! Are you able to replicate the
> difference between these two slides?

Interesting.  It seems that the use of =...= in one of the items makes
org insert the "fragile" option for the frame and that allows the alltt
environment to work properly.  The solution therefore is either make
sure that there is at least one use of =...= in the slide or, better
yet, add the fragile option yourself by setting the BEAMER_opt property
to fragile, as in:

* Another slide
:PROPERTIES:
:BEAMER_opt: fragile
:END:

I've tested this and it works for me.

HTH,
eric

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.4-143-g9a1549


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Missing line breaks in Beamer with alltt
  2020-12-03 16:38         ` Eric S Fraga
@ 2020-12-04 14:03           ` Jarmo Hurri
  2020-12-04 15:17             ` Eric S Fraga
  0 siblings, 1 reply; 8+ messages in thread
From: Jarmo Hurri @ 2020-12-04 14:03 UTC (permalink / raw)
  To: emacs-orgmode


Hi there Eric.

Eric S Fraga <e.fraga@ucl.ac.uk> writes:

>> I will take you up on that offer! Are you able to replicate the
>> difference between these two slides?
>
> Interesting.  It seems that the use of =...= in one of the items makes
> org insert the "fragile" option for the frame and that allows the alltt
> environment to work properly.  The solution therefore is either make
> sure that there is at least one use of =...= in the slide or, better
> yet, add the fragile option yourself by setting the BEAMER_opt property
> to fragile, as in:
>
> * Another slide
> :PROPERTIES:
> :BEAMER_opt: fragile
> :END:
>
> I've tested this and it works for me.

Works for me too, excellent!

I have an eerie feeling that this should be either
a) fixed so that it works without inserting fragile, or
b) written down somewhere in documentation.
Any ideas?

All the best, and stay safe.

Jarmo



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Missing line breaks in Beamer with alltt
  2020-12-04 14:03           ` Jarmo Hurri
@ 2020-12-04 15:17             ` Eric S Fraga
  0 siblings, 0 replies; 8+ messages in thread
From: Eric S Fraga @ 2020-12-04 15:17 UTC (permalink / raw)
  To: Jarmo Hurri; +Cc: emacs-orgmode

On Friday,  4 Dec 2020 at 16:03, Jarmo Hurri wrote:
> I have an eerie feeling that this should be either
> a) fixed so that it works without inserting fragile, or
> b) written down somewhere in documentation.
> Any ideas?

This is a beamer issue and I think it is mentioned somewhere in the
beamer documentation.

Of course, it wouldn't hurt to say something in the org beamer
documentation, probably on Worg.  I'm sure patches or contributions
would be welcome!

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.4-143-g9a1549


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-12-04 15:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-29  9:22 Missing line breaks in Beamer with alltt Jarmo Hurri
2020-11-29 12:33 ` Eric S Fraga
2020-11-30  5:03   ` Jarmo Hurri
2020-11-30  9:32     ` Eric S Fraga
2020-12-03 16:07       ` Jarmo Hurri
2020-12-03 16:38         ` Eric S Fraga
2020-12-04 14:03           ` Jarmo Hurri
2020-12-04 15:17             ` Eric S Fraga

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