emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Preservation of white space in babel blocks, exporting to PDF
@ 2014-01-31  5:58 John Hendy
  2014-01-31  8:09 ` Nicolas Goaziou
  0 siblings, 1 reply; 16+ messages in thread
From: John Hendy @ 2014-01-31  5:58 UTC (permalink / raw)
  To: emacs-orgmode

Greetings,


I'm sure this is just a variable I've overlooked, but I'm wondering if
it's possible to export code blocks as they appear, with whitespace
preserved for better formatting in the resultant LaTeX document (I'm
using Beamer in this case).

Currently, the leading spaces in my blocks seem to be mostly removed
(I might have 8 or so to keep options in R code aligned, and the block
exports with 1-2 instead).

If I used #+begin/end_example instead of #+begin/end_src, it works properly.

The closest I found in my googling for a solution/setting/variable was
the variable =org-src-preserve-indentation=, but that seems to only
have to do with tangling.


Thanks for any suggestions,
John

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

* Re: Preservation of white space in babel blocks, exporting to PDF
  2014-01-31  5:58 Preservation of white space in babel blocks, exporting to PDF John Hendy
@ 2014-01-31  8:09 ` Nicolas Goaziou
  2014-01-31 22:16   ` John Hendy
  0 siblings, 1 reply; 16+ messages in thread
From: Nicolas Goaziou @ 2014-01-31  8:09 UTC (permalink / raw)
  To: John Hendy; +Cc: emacs-orgmode

Hello,

John Hendy <jw.hendy@gmail.com> writes:

> The closest I found in my googling for a solution/setting/variable was
> the variable =org-src-preserve-indentation=, but that seems to only
> have to do with tangling.

The first line of its docstring is:

  If non-nil preserve leading whitespace characters on export.


Regards,

-- 
Nicolas Goaziou

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

* Re: Preservation of white space in babel blocks, exporting to PDF
  2014-01-31  8:09 ` Nicolas Goaziou
@ 2014-01-31 22:16   ` John Hendy
  2014-01-31 22:25     ` Nicolas Goaziou
  0 siblings, 1 reply; 16+ messages in thread
From: John Hendy @ 2014-01-31 22:16 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

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

On Fri, Jan 31, 2014 at 2:09 AM, Nicolas Goaziou <n.goaziou@gmail.com> wrote:
> Hello,
>
> John Hendy <jw.hendy@gmail.com> writes:
>
>> The closest I found in my googling for a solution/setting/variable was
>> the variable =org-src-preserve-indentation=, but that seems to only
>> have to do with tangling.
>
> The first line of its docstring is:
>
>   If non-nil preserve leading whitespace characters on export.

Just tried this and it's still not working. I started emacs with
`emacs -Q` and then did `M-x load-file` with this minimal config:

#+begin_src min-config

(add-to-list 'load-path "~/.elisp/org.git/lisp/")
(add-to-list 'load-path "~/.elisp/org.git/contrib/lisp")
(add-to-list 'load-path "~/.elisp/site-lisp/ess/lisp/")

;; setup babel languages
(org-babel-do-load-languages
 'org-babel-load-languages
 '((R . t)))

(require 'ox-latex)
(require 'ox-beamer)

(add-to-list 'org-latex-classes
             '("beamer"
               "\\documentclass\[presentation\]\{beamer\}"
               ("\\section\{%s\}" . "\\section*\{%s\}")
               ("\\subsection\{%s\}" . "\\subsection*\{%s\}")
               ("\\subsubsection\{%s\}" . "\\subsubsection*\{%s\}")))

(setq org-src-preserve-indentation t)

#+end_src

Here's the test file:

#+begin_src org

#+latex_class: beamer
#+options: toc:nil latex:t tex:t H:1
#+latex_class_options: [presentation]

* Slide

#+begin_src R
a <- "Test of whitespace preservation"

b <- cat("Let's see what happens when we spill",
         "onto multiple lines but want the text",
         "being passed to cat() to be aligned")

#+end_src

#+end_src

It doesn't show up that well, but with fixed-font, the quotation is
aligned for all three lines passed to cat().

I also checked (from the emacs -Q session) on org-src-preserve-indentation:

#+begin_src M-x help RET v RET org-src-preserve-indentation RET

org-src-preserve-indentation is a variable defined in `org-src.el'.
Its value is t
Original value was nil

#+end_src

I attached the resultant output.


Best regards,
John

>
>
> Regards,
>
> --
> Nicolas Goaziou

[-- Attachment #2: test.pdf --]
[-- Type: application/pdf, Size: 47635 bytes --]

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

* Re: Preservation of white space in babel blocks, exporting to PDF
  2014-01-31 22:16   ` John Hendy
@ 2014-01-31 22:25     ` Nicolas Goaziou
  2014-01-31 22:46       ` John Hendy
  0 siblings, 1 reply; 16+ messages in thread
From: Nicolas Goaziou @ 2014-01-31 22:25 UTC (permalink / raw)
  To: John Hendy; +Cc: emacs-orgmode

John Hendy <jw.hendy@gmail.com> writes:

> Here's the test file:
>
> #+begin_src org
>
> #+latex_class: beamer
> #+options: toc:nil latex:t tex:t H:1
> #+latex_class_options: [presentation]
>
> * Slide
>
> #+begin_src R
> a <- "Test of whitespace preservation"
>
> b <- cat("Let's see what happens when we spill",
>          "onto multiple lines but want the text",
>          "being passed to cat() to be aligned")
>
> #+end_src
>
> #+end_src
>
> It doesn't show up that well, but with fixed-font, the quotation is
> aligned for all three lines passed to cat().
>
> I also checked (from the emacs -Q session) on org-src-preserve-indentation:
>
> #+begin_src M-x help RET v RET org-src-preserve-indentation RET
>
> org-src-preserve-indentation is a variable defined in `org-src.el'.
> Its value is t
> Original value was nil
>
> #+end_src
>
> I attached the resultant output.

I cannot reproduce the problem.

Please look at the TeX source instead of the PDF. What did you expect
instead?


Regards,

-- 
Nicolas Goaziou

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

* Re: Preservation of white space in babel blocks, exporting to PDF
  2014-01-31 22:25     ` Nicolas Goaziou
@ 2014-01-31 22:46       ` John Hendy
  2014-01-31 23:04         ` Nicolas Goaziou
  0 siblings, 1 reply; 16+ messages in thread
From: John Hendy @ 2014-01-31 22:46 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

On Fri, Jan 31, 2014 at 4:25 PM, Nicolas Goaziou <n.goaziou@gmail.com> wrote:
> John Hendy <jw.hendy@gmail.com> writes:
>
>> Here's the test file:
>>
>> #+begin_src org
>>
>> #+latex_class: beamer
>> #+options: toc:nil latex:t tex:t H:1
>> #+latex_class_options: [presentation]
>>
>> * Slide
>>
>> #+begin_src R
>> a <- "Test of whitespace preservation"
>>
>> b <- cat("Let's see what happens when we spill",
>>          "onto multiple lines but want the text",
>>          "being passed to cat() to be aligned")
>>
>> #+end_src
>>
>> #+end_src
>>
>> It doesn't show up that well, but with fixed-font, the quotation is
>> aligned for all three lines passed to cat().
>>
>> I also checked (from the emacs -Q session) on org-src-preserve-indentation:
>>
>> #+begin_src M-x help RET v RET org-src-preserve-indentation RET
>>
>> org-src-preserve-indentation is a variable defined in `org-src.el'.
>> Its value is t
>> Original value was nil
>>
>> #+end_src
>>
>> I attached the resultant output.
>
> I cannot reproduce the problem.

In the .tex file or in the .pdf?

>
> Please look at the TeX source instead of the PDF. What did you expect
> instead?

If it's not straightforward, I expect the phrase "preserve whitespace"
to  mean that the PDF (or whatever final exported output) look like
the actual code block. Perhaps some are interested purely in the .tex
file looking correct, but I would think most folks who read
"org-src-preserve-indentation preserves whitespace upon export or
tangling" would read that to mean "the appearance of the exported
document," not simply the base file. If the raw .html or .tex code
preserves whitespace but the rendered documents don't, then I don't
consider whitespace to have been preserved.

I know that #+begin/end_example works properly, so I took a look at
the difference between them:

\begin{frame}[fragile,label=sec-1]{begin src}
 \begin{verbatim}
a <- "Test of whitespace preservation"

b <- cat("Let's see what happens when we spill",
"onto multiple lines but want the text",
"being passed to cat() to be aligned")
\end{verbatim}
\end{frame}

\begin{frame}[fragile,label=sec-2]{begin example}
 \begin{verbatim}
a <- "Test of whitespace preservation"

b <- cat("Let's see what happens when we spill",
         "onto multiple lines but want the text",
         "being passed to cat() to be aligned")
\end{verbatim}
\end{frame}
\end{document}

Source blocks are exported with what appears to be some sort of tab
character; the cursor jumps from the line beginning to the first word
in the line. I don't know what character it is, and you can see from
above that pasting into this email shows no effect of any such
character.

Example blocks use literal spaces, and indeed the whitespace is
preserved, both in the .tex file as well as the resultant .pdf.


John

>
>
> Regards,
>
> --
> Nicolas Goaziou

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

* Re: Preservation of white space in babel blocks, exporting to PDF
  2014-01-31 22:46       ` John Hendy
@ 2014-01-31 23:04         ` Nicolas Goaziou
  2014-01-31 23:16           ` John Hendy
  0 siblings, 1 reply; 16+ messages in thread
From: Nicolas Goaziou @ 2014-01-31 23:04 UTC (permalink / raw)
  To: John Hendy; +Cc: emacs-orgmode

John Hendy <jw.hendy@gmail.com> writes:

>> I cannot reproduce the problem.
>
> In the .tex file or in the .pdf?

Both.

> I know that #+begin/end_example works properly, so I took a look at
> the difference between them:
>
> \begin{frame}[fragile,label=sec-1]{begin src}
>  \begin{verbatim}
> a <- "Test of whitespace preservation"
>
> b <- cat("Let's see what happens when we spill",
> "onto multiple lines but want the text",
> "being passed to cat() to be aligned")
> \end{verbatim}
> \end{frame}

I don't know why or how you get this, but this has nothing to do with
`org-src-preserve-indentation' since there in no global indentation in
your code (i.e., a line starts at column 0).

> \begin{frame}[fragile,label=sec-2]{begin example}
>  \begin{verbatim}
> a <- "Test of whitespace preservation"
>
> b <- cat("Let's see what happens when we spill",
>          "onto multiple lines but want the text",
>          "being passed to cat() to be aligned")
> \end{verbatim}
> \end{frame}
> \end{document}
>
> Source blocks are exported with what appears to be some sort of tab
> character;

You can use C-u C-x = in order to know what it is.

What happens if you run (org-export-execute-babel-code) on your Org
buffer?


Regards,

-- 
Nicolas Goaziou

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

* Re: Preservation of white space in babel blocks, exporting to PDF
  2014-01-31 23:04         ` Nicolas Goaziou
@ 2014-01-31 23:16           ` John Hendy
  2014-01-31 23:25             ` Andreas Leha
  0 siblings, 1 reply; 16+ messages in thread
From: John Hendy @ 2014-01-31 23:16 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

On Fri, Jan 31, 2014 at 5:04 PM, Nicolas Goaziou <n.goaziou@gmail.com> wrote:
> John Hendy <jw.hendy@gmail.com> writes:
>
>>> I cannot reproduce the problem.
>>
>> In the .tex file or in the .pdf?
>
> Both.

Weird.

>
>> I know that #+begin/end_example works properly, so I took a look at
>> the difference between them:
>>
>> \begin{frame}[fragile,label=sec-1]{begin src}
>>  \begin{verbatim}
>> a <- "Test of whitespace preservation"
>>
>> b <- cat("Let's see what happens when we spill",
>> "onto multiple lines but want the text",
>> "being passed to cat() to be aligned")
>> \end{verbatim}
>> \end{frame}
>
> I don't know why or how you get this, but this has nothing to do with
> `org-src-preserve-indentation' since there in no global indentation in
> your code (i.e., a line starts at column 0).
>
>> \begin{frame}[fragile,label=sec-2]{begin example}
>>  \begin{verbatim}
>> a <- "Test of whitespace preservation"
>>
>> b <- cat("Let's see what happens when we spill",
>>          "onto multiple lines but want the text",
>>          "being passed to cat() to be aligned")
>> \end{verbatim}
>> \end{frame}
>> \end{document}
>>
>> Source blocks are exported with what appears to be some sort of tab
>> character;
>
> You can use C-u C-x = in order to know what it is.
>

Here's what I get:

             position: 754 of 1188 (63%), column: 0
            character: TAB (displayed as TAB) (codepoint 9, #o11, #x9)
    preferred charset: ascii (ASCII (ISO646 IRV))
code point in charset: 0x09
               syntax:   which means: whitespace
             to input: type "C-x 8 RET HEX-CODEPOINT" or "C-x 8 RET NAME"
          buffer code: #x09
            file code: #x09 (encoded by coding system utf-8-unix)
              display: no font available

I checked my locale, and it's set to en_US.utf8 (Arch Linux)

> What happens if you run (org-export-execute-babel-code) on your Org
> buffer?

I'm not used to running functions. I placed this in the document,
selected the text, and did `M-x eval-region`. Nothing appears to have
happened, but the *Messages* buffer printed out: "org-babel-exp
process R at line 9..."

Does that help any?


John

>
>
> Regards,
>
> --
> Nicolas Goaziou

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

* Re: Preservation of white space in babel blocks, exporting to PDF
  2014-01-31 23:16           ` John Hendy
@ 2014-01-31 23:25             ` Andreas Leha
  2014-02-01  4:08               ` John Hendy
  0 siblings, 1 reply; 16+ messages in thread
From: Andreas Leha @ 2014-01-31 23:25 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

John Hendy <jw.hendy@gmail.com> writes:

> On Fri, Jan 31, 2014 at 5:04 PM, Nicolas Goaziou <n.goaziou@gmail.com> wrote:
>> John Hendy <jw.hendy@gmail.com> writes:
>>
>>>> I cannot reproduce the problem.
>>>
>>> In the .tex file or in the .pdf?
>>
>> Both.
>
> Weird.
>
>>
>>> I know that #+begin/end_example works properly, so I took a look at
>>> the difference between them:
>>>
>>> \begin{frame}[fragile,label=sec-1]{begin src}
>>>  \begin{verbatim}
>>> a <- "Test of whitespace preservation"
>>>
>>> b <- cat("Let's see what happens when we spill",
>>> "onto multiple lines but want the text",
>>> "being passed to cat() to be aligned")
>>> \end{verbatim}
>>> \end{frame}
>>
>> I don't know why or how you get this, but this has nothing to do with
>> `org-src-preserve-indentation' since there in no global indentation in
>> your code (i.e., a line starts at column 0).
>>
>>> \begin{frame}[fragile,label=sec-2]{begin example}
>>>  \begin{verbatim}
>>> a <- "Test of whitespace preservation"
>>>
>>> b <- cat("Let's see what happens when we spill",
>>>          "onto multiple lines but want the text",
>>>          "being passed to cat() to be aligned")
>>> \end{verbatim}
>>> \end{frame}
>>> \end{document}
>>>
>>> Source blocks are exported with what appears to be some sort of tab
>>> character;
>>
>> You can use C-u C-x = in order to know what it is.
>>
>
> Here's what I get:
>
>              position: 754 of 1188 (63%), column: 0
>             character: TAB (displayed as TAB) (codepoint 9, #o11, #x9)
>     preferred charset: ascii (ASCII (ISO646 IRV))
> code point in charset: 0x09
>                syntax:   which means: whitespace
>              to input: type "C-x 8 RET HEX-CODEPOINT" or "C-x 8 RET NAME"
>           buffer code: #x09
>             file code: #x09 (encoded by coding system utf-8-unix)
>               display: no font available
>
> I checked my locale, and it's set to en_US.utf8 (Arch Linux)
>
>> What happens if you run (org-export-execute-babel-code) on your Org
>> buffer?
>
> I'm not used to running functions. I placed this in the document,
> selected the text, and did `M-x eval-region`. Nothing appears to have
> happened, but the *Messages* buffer printed out: "org-babel-exp
> process R at line 9..."
>
> Does that help any?
>
>
> John
>


I have not been following this thread.  So please scratch this in case
it is not relevant here.  But I once had problems concerning tabs and
source blocks in beamer documents.  So, this is what I have in my .emacs
(quite crude):

--8<---------------cut here---------------start------------->8---
(defun my-e-beamer-final-filter (contents backend info)
  (replace-regexp-in-string "\t" "        " contents))
(add-to-list 'org-export-filter-final-output-functions 'my-e-beamer-final-filter)
--8<---------------cut here---------------end--------------->8---

Regards,
Andreas

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

* Re: Preservation of white space in babel blocks, exporting to PDF
  2014-01-31 23:25             ` Andreas Leha
@ 2014-02-01  4:08               ` John Hendy
  2014-02-01  8:28                 ` Nicolas Goaziou
  0 siblings, 1 reply; 16+ messages in thread
From: John Hendy @ 2014-02-01  4:08 UTC (permalink / raw)
  To: Andreas Leha; +Cc: emacs-orgmode

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

On Jan 31, 2014 5:26 PM, "Andreas Leha" <andreas.leha@med.uni-goettingen.de>
wrote:
>
> Hi,
>
> John Hendy <jw.hendy@gmail.com> writes:
>
> > On Fri, Jan 31, 2014 at 5:04 PM, Nicolas Goaziou <n.goaziou@gmail.com>
wrote:
> >> John Hendy <jw.hendy@gmail.com> writes:
> >>
> >>>> I cannot reproduce the problem.
> >>>
> >>> In the .tex file or in the .pdf?
> >>
> >> Both.
> >
> > Weird.
> >
> >>
> >>> I know that #+begin/end_example works properly, so I took a look at
> >>> the difference between them:
> >>>
> >>> \begin{frame}[fragile,label=sec-1]{begin src}
> >>>  \begin{verbatim}
> >>> a <- "Test of whitespace preservation"
> >>>
> >>> b <- cat("Let's see what happens when we spill",
> >>> "onto multiple lines but want the text",
> >>> "being passed to cat() to be aligned")
> >>> \end{verbatim}
> >>> \end{frame}
> >>
> >> I don't know why or how you get this, but this has nothing to do with
> >> `org-src-preserve-indentation' since there in no global indentation in
> >> your code (i.e., a line starts at column 0).
> >>
> >>> \begin{frame}[fragile,label=sec-2]{begin example}
> >>>  \begin{verbatim}
> >>> a <- "Test of whitespace preservation"
> >>>
> >>> b <- cat("Let's see what happens when we spill",
> >>>          "onto multiple lines but want the text",
> >>>          "being passed to cat() to be aligned")
> >>> \end{verbatim}
> >>> \end{frame}
> >>> \end{document}
> >>>
> >>> Source blocks are exported with what appears to be some sort of tab
> >>> character;
> >>
> >> You can use C-u C-x = in order to know what it is.
> >>
> >
> > Here's what I get:
> >
> >              position: 754 of 1188 (63%), column: 0
> >             character: TAB (displayed as TAB) (codepoint 9, #o11, #x9)
> >     preferred charset: ascii (ASCII (ISO646 IRV))
> > code point in charset: 0x09
> >                syntax:   which means: whitespace
> >              to input: type "C-x 8 RET HEX-CODEPOINT" or "C-x 8 RET
NAME"
> >           buffer code: #x09
> >             file code: #x09 (encoded by coding system utf-8-unix)
> >               display: no font available
> >
> > I checked my locale, and it's set to en_US.utf8 (Arch Linux)
> >
> >> What happens if you run (org-export-execute-babel-code) on your Org
> >> buffer?
> >
> > I'm not used to running functions. I placed this in the document,
> > selected the text, and did `M-x eval-region`. Nothing appears to have
> > happened, but the *Messages* buffer printed out: "org-babel-exp
> > process R at line 9..."
> >
> > Does that help any?
> >
> >
> > John
> >
>
>
> I have not been following this thread.  So please scratch this in case
> it is not relevant here.  But I once had problems concerning tabs and
> source blocks in beamer documents.  So, this is what I have in my .emacs
> (quite crude):
>
> --8<---------------cut here---------------start------------->8---
> (defun my-e-beamer-final-filter (contents backend info)
>   (replace-regexp-in-string "\t" "        " contents))
> (add-to-list 'org-export-filter-final-output-functions
'my-e-beamer-final-filter)
> --8<---------------cut here---------------end--------------->8---
>

Certainly looks like it would do what needs to be done based on my issue.
I'll try it this weekend.

I'd still like to understand the src vs. example block discrepancy if
possible. It's really odd, especially since Nicholas isn't able to
reproduce even with the same minimal config.

Thanks for posting your solution,
John

> Regards,
> Andreas
>
>

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

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

* Re: Preservation of white space in babel blocks, exporting to PDF
  2014-02-01  4:08               ` John Hendy
@ 2014-02-01  8:28                 ` Nicolas Goaziou
  2014-02-01 17:54                   ` John Hendy
  0 siblings, 1 reply; 16+ messages in thread
From: Nicolas Goaziou @ 2014-02-01  8:28 UTC (permalink / raw)
  To: John Hendy; +Cc: Andreas Leha, emacs-orgmode

Hello,

John Hendy <jw.hendy@gmail.com> writes:

> I'd still like to understand the src vs. example block discrepancy if
> possible. It's really odd, especially since Nicholas isn't able to
> reproduce even with the same minimal config.

There is no discrepancy. You indent your code with tabs and these tabs
appear in the TeX file, but Beamer cannot handle them properly. The same
problem will arise in an example block.

I couldn't reproduce it because I only indent with spaces.


Regards,

-- 
Nicolas Goaziou

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

* Re: Preservation of white space in babel blocks, exporting to PDF
  2014-02-01  8:28                 ` Nicolas Goaziou
@ 2014-02-01 17:54                   ` John Hendy
  2014-02-01 20:27                     ` Nicolas Goaziou
  0 siblings, 1 reply; 16+ messages in thread
From: John Hendy @ 2014-02-01 17:54 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Andreas Leha, emacs-orgmode

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

On Sat, Feb 1, 2014 at 2:28 AM, Nicolas Goaziou <n.goaziou@gmail.com> wrote:
> Hello,
>
> John Hendy <jw.hendy@gmail.com> writes:
>
>> I'd still like to understand the src vs. example block discrepancy if
>> possible. It's really odd, especially since Nicholas isn't able to
>> reproduce even with the same minimal config.
>
> There is no discrepancy. You indent your code with tabs and these tabs
> appear in the TeX file, but Beamer cannot handle them properly. The same
> problem will arise in an example block.

From whence comes this assumption? In the previous emails, I mentioned
the different treatment between src and example blocks with the same
code. I don't know why I'd complain about the .tex containing "some
sort of tab character" if I'd put it there myself!

> I couldn't reproduce it because I only indent with spaces.

This doesn't compute with me. If we're talking about reproduction, it
means that you ran my code as posted, with the same min config. What
you typically intent with wouldn't come into play. Feedback would be
provided on what my code produced on your system, as-is. You appear to
be highlighting that we indent differently instead (which I don't
think is the case).

To attempt to get at the root of this, find attached the exact .org
file (no confusion on tabs vs. spaces), and the outpuy .tex/.pdf
created (I renamed the .tex and .pdf so others don't have to worry
about them being overwritten with local export). My process, again, is
the following:
- $ emacs -Q
- M-x load-file ~/path/to/min-config
- C-x C-f ~/path/to/test.org
- C-c C-e l P (output to Beamer)

- M-x org-version
Org-mode version 8.2.5h (release_8.2.5h-576-gca0c77 @
/home/jwhendy/.elisp/org.git/lisp/)

- $ emacs --version
GNU Emacs 24.3.1

Check the .org file; no tabs. The latex output contains tabs for the
exported src block, but spaces for the example block. On a whim, I
added two more headlines to the .org file; they only use 2 or 3 spaces
vs. the first two headlines which contain 9. They export properly in
both cases. Could it be possible that there's some sort of
substitution of a tab for 5 spaces going on somewhere?

Thanks for any suggestions.


John

>
>
> Regards,
>
> --
> Nicolas Goaziou

[-- Attachment #2: test.org --]
[-- Type: application/octet-stream, Size: 1160 bytes --]

#+latex_class: beamer
#+options: toc:nil latex:t tex:t H:1
#+latex_class_options: [presentation]

* src block

- Only spaces here, but tabs will appear in .tex

#+begin_src R 
a <- "Test of whitespace preservation"

b <- cat("Let's see what happens when we spill",
         "onto multiple lines but want the text",
         "being passed to cat() to be aligned")
#+end_src

#+RESULTS:

* example block

- Only spaces here, which will be unchanged in .tex

#+begin_example
a <- "Test of whitespace preservation"

b <- cat("Let's see what happens when we spill",
         "onto multiple lines but want the text",
         "being passed to cat() to be aligned")
#+end_example


* src block

- Idea to play with less spaces (< 5)

#+begin_src R 
a <- "Test of whitespace preservation"

b <- cat("Let's see what happens when we spill",
  "onto multiple lines but want the text",
   "being passed to cat() to be aligned")
#+end_src

#+RESULTS:

* example block

#+begin_example
a <- "Test of whitespace preservation"

b <- cat("Let's see what happens when we spill",
  "onto multiple lines but want the text",
   "being passed to cat() to be aligned")
#+end_example

[-- Attachment #3: jw-text.tex --]
[-- Type: application/x-tex, Size: 1977 bytes --]

[-- Attachment #4: jw-test.pdf --]
[-- Type: application/pdf, Size: 60988 bytes --]

[-- Attachment #5: min-config --]
[-- Type: application/octet-stream, Size: 645 bytes --]

(add-to-list 'load-path "~/.elisp/org.git/lisp/")
(add-to-list 'load-path "~/.elisp/org.git/contrib/lisp")
(add-to-list 'load-path "~/.elisp/site-lisp/ess/lisp/")

;; setup babel languages
(org-babel-do-load-languages
 'org-babel-load-languages
 '((R . t)))

(require 'ox-latex)
(require 'ox-beamer)

(add-to-list 'org-latex-classes
             '("beamer"
               "\\documentclass\[presentation\]\{beamer\}"
               ("\\section\{%s\}" . "\\section*\{%s\}")
               ("\\subsection\{%s\}" . "\\subsection*\{%s\}")
               ("\\subsubsection\{%s\}" . "\\subsubsection*\{%s\}")))

;; (setq org-src-preserve-indentation t)

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

* Re: Preservation of white space in babel blocks, exporting to PDF
  2014-02-01 17:54                   ` John Hendy
@ 2014-02-01 20:27                     ` Nicolas Goaziou
  2014-02-01 21:02                       ` Nicolas Goaziou
  2014-02-02  1:33                       ` John Hendy
  0 siblings, 2 replies; 16+ messages in thread
From: Nicolas Goaziou @ 2014-02-01 20:27 UTC (permalink / raw)
  To: John Hendy; +Cc: Andreas Leha, emacs-orgmode

Hello,

John Hendy <jw.hendy@gmail.com> writes:

> On Sat, Feb 1, 2014 at 2:28 AM, Nicolas Goaziou <n.goaziou@gmail.com> wrote:

>> There is no discrepancy. You indent your code with tabs and these tabs
>> appear in the TeX file, but Beamer cannot handle them properly. The same
>> problem will arise in an example block.
>
> From whence comes this assumption? In the previous emails, I mentioned
> the different treatment between src and example blocks with the same
> code. I don't know why I'd complain about the .tex containing "some
> sort of tab character" if I'd put it there myself!

Again, you have `indent-tabs-mode' set to a non-nil value. This is what
I mean by "you indent your code with tabs".

Babel happens to indent source blocks when re-inserting them after
evaluation. So you get tabs even if you didn't explicitly write them in
the first place.


Regards,

-- 
Nicolas Goaziou

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

* Re: Preservation of white space in babel blocks, exporting to PDF
  2014-02-01 20:27                     ` Nicolas Goaziou
@ 2014-02-01 21:02                       ` Nicolas Goaziou
  2014-02-02  1:33                       ` John Hendy
  1 sibling, 0 replies; 16+ messages in thread
From: Nicolas Goaziou @ 2014-02-01 21:02 UTC (permalink / raw)
  To: John Hendy; +Cc: Andreas Leha, emacs-orgmode

Completing myself,

Nicolas Goaziou <n.goaziou@gmail.com> writes:

> Babel happens to indent source blocks when re-inserting them after
> evaluation. So you get tabs even if you didn't explicitly write them in
> the first place.

... but this shouldn't happen if `org-src-preserve-indentation' is
non-nil. I fixed that in maint.

Thank you for the report.

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

* Re: Preservation of white space in babel blocks, exporting to PDF
  2014-02-01 20:27                     ` Nicolas Goaziou
  2014-02-01 21:02                       ` Nicolas Goaziou
@ 2014-02-02  1:33                       ` John Hendy
  2014-02-02  8:45                         ` Nicolas Goaziou
  1 sibling, 1 reply; 16+ messages in thread
From: John Hendy @ 2014-02-02  1:33 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Andreas Leha, emacs-orgmode

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

On Feb 1, 2014 2:26 PM, "Nicolas Goaziou" <n.goaziou@gmail.com> wrote:
>
> Hello,
>
> John Hendy <jw.hendy@gmail.com> writes:
>
> > On Sat, Feb 1, 2014 at 2:28 AM, Nicolas Goaziou <n.goaziou@gmail.com>
wrote:
>
> >> There is no discrepancy. You indent your code with tabs and these tabs
> >> appear in the TeX file, but Beamer cannot handle them properly. The
same
> >> problem will arise in an example block.
> >
> > From whence comes this assumption? In the previous emails, I mentioned
> > the different treatment between src and example blocks with the same
> > code. I don't know why I'd complain about the .tex containing "some
> > sort of tab character" if I'd put it there myself!
>
> Again, you have `indent-tabs-mode' set to a non-nil value. This is what
> I mean by "you indent your code with tabs".

What do you mean, "again"? Have you mentioned that variable in this
conversation yet? I've not done anything with that variable, as evidenced
by the minimal config I sent. Thus, I take it that the default org setting
is non-nil?

I am a bit frustrated by trying to be as clear as I could about the
situation with reproducible examples, and then finding out the behavior was
apparently obvious, but due to a variable I didn't know existed...

I'll try a fresh pull tomorrow as well as looking at indent-tabs-mode.

John

>
> Babel happens to indent source blocks when re-inserting them after
> evaluation. So you get tabs even if you didn't explicitly write them in
> the first place.
>
>
> Regards,
>
> --
> Nicolas Goaziou

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

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

* Re: Preservation of white space in babel blocks, exporting to PDF
  2014-02-02  1:33                       ` John Hendy
@ 2014-02-02  8:45                         ` Nicolas Goaziou
  2014-02-02 15:59                           ` John Hendy
  0 siblings, 1 reply; 16+ messages in thread
From: Nicolas Goaziou @ 2014-02-02  8:45 UTC (permalink / raw)
  To: John Hendy; +Cc: Andreas Leha, emacs-orgmode

Hello,

John Hendy <jw.hendy@gmail.com> writes:

> Thus, I take it that the default org setting is non-nil?

Actually this is an Emacs variable, and it is indeed non-nil.

> I am a bit frustrated by trying to be as clear as I could about the
> situation with reproducible examples, and then finding out the behavior was
> apparently obvious, but due to a variable I didn't know existed...

The behaviour is not obvious.

> I'll try a fresh pull tomorrow as well as looking at indent-tabs-mode.

This should hopefully work. It should also work if you don't change this
variable but set `org-src-preserve-indentation' to a non-nil value,
since I fixed that.

Note that you can set this variable on a per-block basis with "-i" flag:

  #+BEGIN_SRC python -i
  ...
  #+END_SRC


Regards,

-- 
Nicolas Goaziou

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

* Re: Preservation of white space in babel blocks, exporting to PDF
  2014-02-02  8:45                         ` Nicolas Goaziou
@ 2014-02-02 15:59                           ` John Hendy
  0 siblings, 0 replies; 16+ messages in thread
From: John Hendy @ 2014-02-02 15:59 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Andreas Leha, emacs-orgmode

On Sun, Feb 2, 2014 at 2:45 AM, Nicolas Goaziou <n.goaziou@gmail.com> wrote:
> Hello,
>
> John Hendy <jw.hendy@gmail.com> writes:
>
>> Thus, I take it that the default org setting is non-nil?
>
> Actually this is an Emacs variable, and it is indeed non-nil.

Gotcha. So if it interferes with org-src-preserve-indentation, that's
good to know. I'm assuming that was the change you recently pushed per
the last note.

>
>> I am a bit frustrated by trying to be as clear as I could about the
>> situation with reproducible examples, and then finding out the behavior was
>> apparently obvious, but due to a variable I didn't know existed...
>
> The behaviour is not obvious.

Sorry, what I meant is that at no point in our dialog did you seem
surprised by my outcomes. First, you simply said you couldn't
reproduce. Then you said the issue was because I was /using/ tabs (vs.
spaces). When I disagreed, you clarified that saying I was /using/
tabs had really meant I had indent-tabs-mode set to non-nil. From my
non-mastery of Org/emacs perspective, it appeared you knew what was
going on, but revealed it in layers to me.

>> I'll try a fresh pull tomorrow as well as looking at indent-tabs-mode.
>
> This should hopefully work. It should also work if you don't change this
> variable but set `org-src-preserve-indentation' to a non-nil value,
> since I fixed that.
>
> Note that you can set this variable on a per-block basis with "-i" flag:
>
>   #+BEGIN_SRC python -i
>   ...
>   #+END_SRC
>

Awesome. Tried both methods, both of which work exactly as I'd have hoped!
- Putting =(setq org-src-preserve-indentation t)= in .emacs
- No setting for the above variable, but using =-i= in the src block

Thanks so much! This has perplexed me for a really long time, but I've
never looked into it. I'm giving my first more "major" talk at a local
event (talking about R + geo-spatial data as well as Shiny interactive
web-apps), and wanted my code to look nice and pretty. Many thanks for
enabling that!!

I'll be on the lookout for somewhere on Worg where I can add the new
documentation if you haven't done so already.


Best regards,
John

>
> Regards,
>
> --
> Nicolas Goaziou

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

end of thread, other threads:[~2014-02-02 16:44 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-31  5:58 Preservation of white space in babel blocks, exporting to PDF John Hendy
2014-01-31  8:09 ` Nicolas Goaziou
2014-01-31 22:16   ` John Hendy
2014-01-31 22:25     ` Nicolas Goaziou
2014-01-31 22:46       ` John Hendy
2014-01-31 23:04         ` Nicolas Goaziou
2014-01-31 23:16           ` John Hendy
2014-01-31 23:25             ` Andreas Leha
2014-02-01  4:08               ` John Hendy
2014-02-01  8:28                 ` Nicolas Goaziou
2014-02-01 17:54                   ` John Hendy
2014-02-01 20:27                     ` Nicolas Goaziou
2014-02-01 21:02                       ` Nicolas Goaziou
2014-02-02  1:33                       ` John Hendy
2014-02-02  8:45                         ` Nicolas Goaziou
2014-02-02 15:59                           ` John Hendy

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