emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Org-special-blocks for code chunks
@ 2009-08-11 15:41 Sébastien Vauban
  2009-08-11 16:51 ` Chris Gray
  0 siblings, 1 reply; 6+ messages in thread
From: Sébastien Vauban @ 2009-08-11 15:41 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hello,

I have a problem exporting code chunks to LaTeX (beamer, in fact -- but that
does not change anything to the problem) that contain underscores.

For example, the following:

--8<---------------cut here---------------start------------->8---
* Rule language
*** E.g.
#+BEGIN_lstlisting
months_employed(?applicant, ?months) AND
lessThan(?months, 3) AND
assets(?applicant, ?assets) AND
lessThan(?assets, 10000.0)
-> RejectedApplicant(?applicant)
#+END_lstlisting
--8<---------------cut here---------------end--------------->8---

generates:

--8<---------------cut here---------------start------------->8---
\begin{frame}[fragile]
\frametitle{Rule language}
\begin{itemize}
\label{sec-1}

\item{E.g.}
\label{sec-1.1}

\begin{lstlisting}
months$_{\mathrm{employed}}$(?applicant, ?months) AND
lessThan(?months, 3) AND
assets(?applicant, ?assets) AND
lessThan(?assets, 10000.0)
-> RejectedApplicant(?applicant)
\end{lstlisting}


\end{itemize}
\end{frame}
--8<---------------cut here---------------end--------------->8---

and, if I escape the underscore, such as:

--8<---------------cut here---------------start------------->8---
* Rule language
*** E.g.
#+BEGIN_lstlisting
months\_employed(?applicant, ?months) AND
lessThan(?months, 3) AND
assets(?applicant, ?assets) AND
lessThan(?assets, 10000.0)
-> RejectedApplicant(?applicant)
#+END_lstlisting
--8<---------------cut here---------------end--------------->8---

the exporter generates:

--8<---------------cut here---------------start------------->8---
\begin{frame}[fragile]
\frametitle{Rule language}
\begin{itemize}
\label{sec-1}

\item{E.g.}
\label{sec-1.1}

\begin{lstlisting}
months\_employed(?applicant, ?months) AND
lessThan(?months, 3) AND
assets(?applicant, ?assets) AND
lessThan(?assets, 10000.0)
-> RejectedApplicant(?applicant)
\end{lstlisting}


\end{itemize}
\end{frame}
--8<---------------cut here---------------end--------------->8---

So, I can't get a properly outputted underscore in my slide.

Any idea or workaround?

Best regards,
  Seb

-- 
Sébastien Vauban



_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode-mXXj517/zsQ@public.gmane.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: Org-special-blocks for code chunks
  2009-08-11 15:41 Org-special-blocks for code chunks Sébastien Vauban
@ 2009-08-11 16:51 ` Chris Gray
  2009-08-13 10:31   ` Sébastien Vauban
  0 siblings, 1 reply; 6+ messages in thread
From: Chris Gray @ 2009-08-11 16:51 UTC (permalink / raw)
  To: emacs-orgmode

Sébastien Vauban wrote:
> I have a problem exporting code chunks to LaTeX (beamer, in fact -- but that
> does not change anything to the problem) that contain underscores.

[snip]

> So, I can't get a properly outputted underscore in my slide.

> Any idea or workaround?

Hi Seb,

Is lstlisting like a verbatim environment?  I think you might be able to
just use \begin{lstlisting} and \end{lstlisting} in that case.  Org does
not interpret anything inside such blocks, which is why
org-special-blocks was created in the first place.

Cheers,
Chris

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

* Re: Org-special-blocks for code chunks
  2009-08-11 16:51 ` Chris Gray
@ 2009-08-13 10:31   ` Sébastien Vauban
  2009-08-13 11:56     ` Chris Gray
  2009-08-13 13:13     ` Eric Schulte
  0 siblings, 2 replies; 6+ messages in thread
From: Sébastien Vauban @ 2009-08-13 10:31 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hi Chris,

Chris Gray wrote:
> Sébastien Vauban wrote:
>> I have a problem exporting code chunks to LaTeX (beamer, in fact -- but
>> that does not change anything to the problem) that contain underscores.
>> I can't get a properly outputted underscore in my slide.
>> Any idea or workaround?
>
> Is lstlisting like a verbatim environment?

Yes, it is. What's extra is the highlight of keywords, contextual for every
programming language.


> I think you might be able to just use \begin{lstlisting}
> and \end{lstlisting} in that case. Org does not interpret anything inside
> such blocks, which is why org-special-blocks was created in the first place.

OK. That works.

Though, I'm lost about choosing the best representation for code chunks (I
don't even speak here of literate programming) to be shown in slides or
documents.

Look, I've done an ECM with the different ways I currently see for Org-mode:

--8<---------------cut here---------------start------------->8---
* Org

*** A. To escape the \_
***** 1. No marking at all
\begin{lstlisting}
months_employed(?applicant, ?months)
\end{lstlisting}
***** 2. Literal LaTeX code
#+LaTeX: \begin{lstlisting}
months_employed(?applicant, ?months)
#+LaTeX: \end{lstlisting}
***** 3. Lines between markers
#+BEGIN_LaTeX
\begin{lstlisting}
months_employed(?applicant, ?months)
\end{lstlisting}
#+END_LaTeX
***** 4. Org-special-blocks
#+BEGIN_lstlisting
months_employed(?applicant, ?months)
#+END_lstlisting

*** B. Or not to escape the _?
***** 1. No marking at all
\begin{lstlisting}
months\_employed(?applicant, ?months)
\end{lstlisting}
***** 2. Literal LaTeX code
#+LaTeX: \begin{lstlisting}
months\_employed(?applicant, ?months)
#+LaTeX: \end{lstlisting}
***** 3. Lines between markers
#+BEGIN_LaTeX
\begin{lstlisting}
months\_employed(?applicant, ?months)
\end{lstlisting}
#+END_LaTeX
***** 4. Org-special-blocks
#+BEGIN_lstlisting
months\_employed(?applicant, ?months)
#+END_lstlisting
--8<---------------cut here---------------end--------------->8---


Without org-special-blocks, I have such LaTeX generated:

--8<---------------cut here---------------start------------->8---
% Created 2009-08-13 Thu 12:07
\documentclass[final]{mcreport}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{hyperref}
\usepackage{xcolor}
\usepackage{listings}

\title{ecm-escape}
\author{Fabrice Niessen}
\date{13 August 2009}

\begin{document}

\maketitle

\setcounter{tocdepth}{3}
\tableofcontents
\vspace*{1cm}
\section{Org}
\label{sec-1}


\subsection{A. To escape the \_}
\label{sec-1.1}

\subsubsection{1. No marking at all}
\label{sec-1.1.1}

\begin{lstlisting}
months_employed(?applicant, ?months)
\end{lstlisting}
\subsubsection{2. Literal \LaTeX{} code}
\label{sec-1.1.2}

\begin{lstlisting}
months_employed(?applicant, ?months)
\end{lstlisting}
\subsubsection{3. Lines between markers}
\label{sec-1.1.3}

\begin{lstlisting}
months_employed(?applicant, ?months)
\end{lstlisting}
\subsubsection{4. Org-special-blocks}
\label{sec-1.1.4}

months$_{\mathrm{employed}}$(?applicant, ?months)

\subsection{B. Or not to escape the _?}
\label{sec-1.2}

\subsubsection{1. No marking at all}
\label{sec-1.2.1}

\begin{lstlisting}
months\_employed(?applicant, ?months)
\end{lstlisting}
\subsubsection{2. Literal \LaTeX{} code}
\label{sec-1.2.2}

\begin{lstlisting}
months\_employed(?applicant, ?months)
\end{lstlisting}
\subsubsection{3. Lines between markers}
\label{sec-1.2.3}

\begin{lstlisting}
months\_employed(?applicant, ?months)
\end{lstlisting}
\subsubsection{4. Org-special-blocks}
\label{sec-1.2.4}

months\_employed(?applicant, ?months)

\end{document}
--8<---------------cut here---------------end--------------->8---


With org-special-blocks turned on, I have:

--8<---------------cut here---------------start------------->8---
% Created 2009-08-13 Thu 12:10
\documentclass[final]{mcreport}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{hyperref}
\usepackage{xcolor}
\usepackage{listings}

\title{ecm-escape}
\author{Fabrice Niessen}
\date{13 August 2009}

\begin{document}

\maketitle

\setcounter{tocdepth}{3}
\tableofcontents
\vspace*{1cm}
\section{Org}
\label{sec-1}


\subsection{A. To escape the \_}
\label{sec-1.1}

\subsubsection{1. No marking at all}
\label{sec-1.1.1}

\begin{lstlisting}
months_employed(?applicant, ?months)
\end{lstlisting}
\subsubsection{2. Literal \LaTeX{} code}
\label{sec-1.1.2}

\begin{lstlisting}
months_employed(?applicant, ?months)
\end{lstlisting}
\subsubsection{3. Lines between markers}
\label{sec-1.1.3}

\begin{\LaTeX{}}
\begin{lstlisting}
months_employed(?applicant, ?months)
\end{lstlisting}
\end{\LaTeX{}}
\subsubsection{4. Org-special-blocks}
\label{sec-1.1.4}

\begin{lstlisting}
months$_{\mathrm{employed}}$(?applicant, ?months)
\end{lstlisting}

\subsection{B. Or not to escape the _?}
\label{sec-1.2}

\subsubsection{1. No marking at all}
\label{sec-1.2.1}

\begin{lstlisting}
months\_employed(?applicant, ?months)
\end{lstlisting}
\subsubsection{2. Literal \LaTeX{} code}
\label{sec-1.2.2}

\begin{lstlisting}
months\_employed(?applicant, ?months)
\end{lstlisting}
\subsubsection{3. Lines between markers}
\label{sec-1.2.3}

\begin{\LaTeX{}}
\begin{lstlisting}
months\_employed(?applicant, ?months)
\end{lstlisting}
\end{\LaTeX{}}
\subsubsection{4. Org-special-blocks}
\label{sec-1.2.4}

\begin{lstlisting}
months\_employed(?applicant, ?months)
\end{lstlisting}

\end{document}
--8<---------------cut here---------------end--------------->8---


Conclusions?

- Org-special-blocks seems to misbehave in cases A3/B3 (adding an unsound
  environment) and A4 (letting the underscore being converted);

- Cases 1 and 2 always work as expected: producing me what I want for the "A
  series", and something expected (but not what I want to see in the document)
  for the "B series" (just there for informative purpose -- because, anyway, I
  don't wanna see the underscore, nowhere, neither having to type it, neither
  printing it in the docs);

- Cases A1 and A3 are the nicest to read in Org: code chunks are highlighted
  differently.

- Though, case A1 is not very friendly: nothing tells I'm inline LaTeX code
  (what about other exports, as HTML and the like?)

- Thought, case A2 is the one I currently choose for the slides I'm producing,
  as it both works whenever org-special-blocks is activated and when it's not.

Any comments?

Seb

-- 
Sébastien Vauban



_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode-mXXj517/zsQ@public.gmane.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: Org-special-blocks for code chunks
  2009-08-13 10:31   ` Sébastien Vauban
@ 2009-08-13 11:56     ` Chris Gray
  2009-08-13 12:23       ` Sébastien Vauban
  2009-08-13 13:13     ` Eric Schulte
  1 sibling, 1 reply; 6+ messages in thread
From: Chris Gray @ 2009-08-13 11:56 UTC (permalink / raw)
  To: emacs-orgmode

Hi Seb,

Thanks for testing things so extensively.  

> Look, I've done an ECM with the different ways I currently see for Org-mode:

I've never seen the term ECM before.  What does it mean?

> Conclusions?

> - Org-special-blocks seems to misbehave in cases A3/B3 (adding an unsound
>   environment) and A4 (letting the underscore being converted);

I would argue that it is only misbehaving in A3 and B3, since the whole
point of org-special-blocks is that org-style interpretation of your
text is happening inside the blocks.  In this sense, it was never really
meant to be used with verbatim-type environments.  (I use it mainly for
things like lemma and proof environments).

I think that A3/B3 show a bug, though, so that should be fixed.  (Either
with a special case in org-special-blocks or by moving the hook around
in org-exp-latex).  I will try to have a look at this later.

> - Though, case A1 is not very friendly: nothing tells I'm inline LaTeX code
>   (what about other exports, as HTML and the like?)

I'm not sure, but I think it sends the whole thing to latex and then
renders the output as an image.

Cheers,
Chris

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

* Re: Org-special-blocks for code chunks
  2009-08-13 11:56     ` Chris Gray
@ 2009-08-13 12:23       ` Sébastien Vauban
  0 siblings, 0 replies; 6+ messages in thread
From: Sébastien Vauban @ 2009-08-13 12:23 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hi Chris,

Chris Gray wrote:
> Thanks for testing things so extensively.

No prob. Trying to fully understand all sides of the problem.


>> Look, I've done an ECM with the different ways I currently see for Org-mode:
>
> I've never seen the term ECM before.  What does it mean?

ECM is French for Exemple Complet Minimal (= Minimal Complete Example).


>> Conclusions?
>
>> - Org-special-blocks seems to misbehave in cases A3/B3 (adding an unsound
>>   environment) and A4 (letting the underscore being converted);
>
> I would argue that it is only misbehaving in A3 and B3, since the whole
> point of org-special-blocks is that org-style interpretation of your
> text is happening inside the blocks.

About A4: maybe you're right, yes.


> In this sense, it was never really meant to be used with verbatim-type
> environments. (I use it mainly for things like lemma and proof
> environments).
>
> I think that A3/B3 show a bug, though, so that should be fixed.  (Either
> with a special case in org-special-blocks or by moving the hook around
> in org-exp-latex).  I will try to have a look at this later.

OK. Thanks.


>> - Though, case A1 is not very friendly: nothing tells I'm inline LaTeX code
>>   (what about other exports, as HTML and the like?)
>
> I'm not sure, but I think it sends the whole thing to latex and then
> renders the output as an image.

Never using HTML... But when it comes to make a choice for my whole life ;-),
I must take this into account...

Best regards,
  Seb

-- 
Sébastien Vauban



_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode-mXXj517/zsQ@public.gmane.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: Re: Org-special-blocks for code chunks
  2009-08-13 10:31   ` Sébastien Vauban
  2009-08-13 11:56     ` Chris Gray
@ 2009-08-13 13:13     ` Eric Schulte
  1 sibling, 0 replies; 6+ messages in thread
From: Eric Schulte @ 2009-08-13 13:13 UTC (permalink / raw)
  To: Sébastien Vauban; +Cc: emacs-orgmode

Sébastien Vauban <wxhgmqzgwmuf@spammotel.com> writes:

[...]

>
> Look, I've done an ECM with the different ways I currently see for Org-mode:
>

I haven't followed this whole thread, so please forgive me if I'm
duplicating information.  With the latest Org-mode from git, regular
source-code blocks can be exported into the lstlisting LaTeX
environment.  I mention this because it does not appear as an option in
your ECM.  For instructions see
http://orgmode.org/worg/org-faq.php#fontified_source_code_w_latex

-- Eric

>
> * Org
>
> *** A. To escape the \_
> ***** 1. No marking at all
> \begin{lstlisting}
> months_employed(?applicant, ?months)
> \end{lstlisting}
> ***** 2. Literal LaTeX code
> #+LaTeX: \begin{lstlisting}
> months_employed(?applicant, ?months)
> #+LaTeX: \end{lstlisting}
> ***** 3. Lines between markers
> #+BEGIN_LaTeX
> \begin{lstlisting}
> months_employed(?applicant, ?months)
> \end{lstlisting}
> #+END_LaTeX
> ***** 4. Org-special-blocks
> #+BEGIN_lstlisting
> months_employed(?applicant, ?months)
> #+END_lstlisting
>
> *** B. Or not to escape the _?
> ***** 1. No marking at all
> \begin{lstlisting}
> months\_employed(?applicant, ?months)
> \end{lstlisting}
> ***** 2. Literal LaTeX code
> #+LaTeX: \begin{lstlisting}
> months\_employed(?applicant, ?months)
> #+LaTeX: \end{lstlisting}
> ***** 3. Lines between markers
> #+BEGIN_LaTeX
> \begin{lstlisting}
> months\_employed(?applicant, ?months)
> \end{lstlisting}
> #+END_LaTeX
> ***** 4. Org-special-blocks
> #+BEGIN_lstlisting
> months\_employed(?applicant, ?months)
> #+END_lstlisting
>
>
> Without org-special-blocks, I have such LaTeX generated:
>
> % Created 2009-08-13 Thu 12:07
> \documentclass[final]{mcreport}
> \usepackage[utf8x]{inputenc}
> \usepackage[T1]{fontenc}
> \usepackage{graphicx}
> \usepackage{longtable}
> \usepackage{hyperref}
> \usepackage{xcolor}
> \usepackage{listings}
>
> \title{ecm-escape}
> \author{Fabrice Niessen}
> \date{13 August 2009}
>
> \begin{document}
>
> \maketitle
>
> \setcounter{tocdepth}{3}
> \tableofcontents
> \vspace*{1cm}
> \section{Org}
> \label{sec-1}
>
>
> \subsection{A. To escape the \_}
> \label{sec-1.1}
>
> \subsubsection{1. No marking at all}
> \label{sec-1.1.1}
>
> \begin{lstlisting}
> months_employed(?applicant, ?months)
> \end{lstlisting}
> \subsubsection{2. Literal \LaTeX{} code}
> \label{sec-1.1.2}
>
> \begin{lstlisting}
> months_employed(?applicant, ?months)
> \end{lstlisting}
> \subsubsection{3. Lines between markers}
> \label{sec-1.1.3}
>
> \begin{lstlisting}
> months_employed(?applicant, ?months)
> \end{lstlisting}
> \subsubsection{4. Org-special-blocks}
> \label{sec-1.1.4}
>
> months$_{\mathrm{employed}}$(?applicant, ?months)
>
> \subsection{B. Or not to escape the _?}
> \label{sec-1.2}
>
> \subsubsection{1. No marking at all}
> \label{sec-1.2.1}
>
> \begin{lstlisting}
> months\_employed(?applicant, ?months)
> \end{lstlisting}
> \subsubsection{2. Literal \LaTeX{} code}
> \label{sec-1.2.2}
>
> \begin{lstlisting}
> months\_employed(?applicant, ?months)
> \end{lstlisting}
> \subsubsection{3. Lines between markers}
> \label{sec-1.2.3}
>
> \begin{lstlisting}
> months\_employed(?applicant, ?months)
> \end{lstlisting}
> \subsubsection{4. Org-special-blocks}
> \label{sec-1.2.4}
>
> months\_employed(?applicant, ?months)
>
> \end{document}
>
>
> With org-special-blocks turned on, I have:
>
> % Created 2009-08-13 Thu 12:10
> \documentclass[final]{mcreport}
> \usepackage[utf8x]{inputenc}
> \usepackage[T1]{fontenc}
> \usepackage{graphicx}
> \usepackage{longtable}
> \usepackage{hyperref}
> \usepackage{xcolor}
> \usepackage{listings}
>
> \title{ecm-escape}
> \author{Fabrice Niessen}
> \date{13 August 2009}
>
> \begin{document}
>
> \maketitle
>
> \setcounter{tocdepth}{3}
> \tableofcontents
> \vspace*{1cm}
> \section{Org}
> \label{sec-1}
>
>
> \subsection{A. To escape the \_}
> \label{sec-1.1}
>
> \subsubsection{1. No marking at all}
> \label{sec-1.1.1}
>
> \begin{lstlisting}
> months_employed(?applicant, ?months)
> \end{lstlisting}
> \subsubsection{2. Literal \LaTeX{} code}
> \label{sec-1.1.2}
>
> \begin{lstlisting}
> months_employed(?applicant, ?months)
> \end{lstlisting}
> \subsubsection{3. Lines between markers}
> \label{sec-1.1.3}
>
> \begin{\LaTeX{}}
> \begin{lstlisting}
> months_employed(?applicant, ?months)
> \end{lstlisting}
> \end{\LaTeX{}}
> \subsubsection{4. Org-special-blocks}
> \label{sec-1.1.4}
>
> \begin{lstlisting}
> months$_{\mathrm{employed}}$(?applicant, ?months)
> \end{lstlisting}
>
> \subsection{B. Or not to escape the _?}
> \label{sec-1.2}
>
> \subsubsection{1. No marking at all}
> \label{sec-1.2.1}
>
> \begin{lstlisting}
> months\_employed(?applicant, ?months)
> \end{lstlisting}
> \subsubsection{2. Literal \LaTeX{} code}
> \label{sec-1.2.2}
>
> \begin{lstlisting}
> months\_employed(?applicant, ?months)
> \end{lstlisting}
> \subsubsection{3. Lines between markers}
> \label{sec-1.2.3}
>
> \begin{\LaTeX{}}
> \begin{lstlisting}
> months\_employed(?applicant, ?months)
> \end{lstlisting}
> \end{\LaTeX{}}
> \subsubsection{4. Org-special-blocks}
> \label{sec-1.2.4}
>
> \begin{lstlisting}
> months\_employed(?applicant, ?months)
> \end{lstlisting}
>
> \end{document}
>
>
> Conclusions?
>
> - Org-special-blocks seems to misbehave in cases A3/B3 (adding an unsound
>   environment) and A4 (letting the underscore being converted);
>
> - Cases 1 and 2 always work as expected: producing me what I want for the "A
>   series", and something expected (but not what I want to see in the document)
>   for the "B series" (just there for informative purpose -- because, anyway, I
>   don't wanna see the underscore, nowhere, neither having to type it, neither
>   printing it in the docs);
>
> - Cases A1 and A3 are the nicest to read in Org: code chunks are highlighted
>   differently.
>
> - Though, case A1 is not very friendly: nothing tells I'm inline LaTeX code
>   (what about other exports, as HTML and the like?)
>
> - Thought, case A2 is the one I currently choose for the slides I'm producing,
>   as it both works whenever org-special-blocks is activated and when it's not.
>
> Any comments?
>
> Seb

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

end of thread, other threads:[~2009-08-13 13:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-11 15:41 Org-special-blocks for code chunks Sébastien Vauban
2009-08-11 16:51 ` Chris Gray
2009-08-13 10:31   ` Sébastien Vauban
2009-08-13 11:56     ` Chris Gray
2009-08-13 12:23       ` Sébastien Vauban
2009-08-13 13:13     ` Eric Schulte

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