emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* What determines if R source block output is wrapped in begin_example or not?
@ 2022-01-13 20:49 John Hendy
  2022-01-14  3:04 ` John Hendy
  0 siblings, 1 reply; 6+ messages in thread
From: John Hendy @ 2022-01-13 20:49 UTC (permalink / raw)
  To: emacs-orgmode

Greetings,

I was perplexed when a table in my exported latex/pdf document came
out garbled, to find out it's being included like "normal text." In
another block with well-behaving output, I observed the same src
header args, but it was wrapped in #+begin/end_example for free,
without me trying.

Here's a reproducible example. This output would not look right when exported:

#+begin_src R :exports results :results output :eval yes
data.frame(
  x = c(1:3))
#+end_src

#+RESULTS:
:   x
: 1 1
: 2 2
: 3 3

From trial and error, it seems the magical length is 9 where it gets wrapped:

#+begin_src R :exports results :results output :eval yes
data.frame(
  x = c(1:9))
#+end_src

#+RESULTS:
#+begin_example
  x
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
#+end_example

I see nothing like this mentioned in the docs on the results of evaluation:
https://orgmode.org/manual/Results-of-Evaluation.html

For now, my workaround is to use :results output code. I guess my
typical output must usually be longer than 9, or I use :results value
and manually add header rows to the generated org table, as I don't
recall dealing with this before!

Thanks for help understanding.

Best regards,
John


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

* Re: What determines if R source block output is wrapped in begin_example or not?
  2022-01-13 20:49 What determines if R source block output is wrapped in begin_example or not? John Hendy
@ 2022-01-14  3:04 ` John Hendy
  2022-01-14  9:48   ` Eric S Fraga
  0 siblings, 1 reply; 6+ messages in thread
From: John Hendy @ 2022-01-14  3:04 UTC (permalink / raw)
  To: emacs-orgmode

Possible false alarm. As I continued to work on this, I accidentally
didn't use :results output code, yet the formatting was fine... I'm
wondering if I had a dangling #+begin_src with no matching end?

Still, I am intrigued by the toggle between prepending with ":" and
wrapping in example blocks, despite what appears to be no practical
impact at this point.

John

On Thu, Jan 13, 2022 at 2:49 PM John Hendy <jw.hendy@gmail.com> wrote:
>
> Greetings,
>
> I was perplexed when a table in my exported latex/pdf document came
> out garbled, to find out it's being included like "normal text." In
> another block with well-behaving output, I observed the same src
> header args, but it was wrapped in #+begin/end_example for free,
> without me trying.
>
> Here's a reproducible example. This output would not look right when exported:
>
> #+begin_src R :exports results :results output :eval yes
> data.frame(
>   x = c(1:3))
> #+end_src
>
> #+RESULTS:
> :   x
> : 1 1
> : 2 2
> : 3 3
>
> From trial and error, it seems the magical length is 9 where it gets wrapped:
>
> #+begin_src R :exports results :results output :eval yes
> data.frame(
>   x = c(1:9))
> #+end_src
>
> #+RESULTS:
> #+begin_example
>   x
> 1 1
> 2 2
> 3 3
> 4 4
> 5 5
> 6 6
> 7 7
> 8 8
> 9 9
> #+end_example
>
> I see nothing like this mentioned in the docs on the results of evaluation:
> https://orgmode.org/manual/Results-of-Evaluation.html
>
> For now, my workaround is to use :results output code. I guess my
> typical output must usually be longer than 9, or I use :results value
> and manually add header rows to the generated org table, as I don't
> recall dealing with this before!
>
> Thanks for help understanding.
>
> Best regards,
> John


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

* Re: What determines if R source block output is wrapped in begin_example or not?
  2022-01-14  3:04 ` John Hendy
@ 2022-01-14  9:48   ` Eric S Fraga
  2022-01-14 13:13     ` John Hendy
  0 siblings, 1 reply; 6+ messages in thread
From: Eric S Fraga @ 2022-01-14  9:48 UTC (permalink / raw)
  To: John Hendy; +Cc: emacs-orgmode

Have a look at

,----[ C-h v org-babel-min-lines-for-block-output RET ]
| org-babel-min-lines-for-block-output is a variable defined in ‘ob-core.el’.
| 
| Its value is 10
| 
| The minimum number of lines for block output.
| If number of lines of output is equal to or exceeds this
| value, the output is placed in a #+begin_example...#+end_example
| block.  Otherwise the output is marked as literal by inserting
| colons at the starts of the lines.  This variable only takes
| effect if the :results output option is in effect.
| 
`----

-- 
: Eric S Fraga, with org release_9.5.2-298-g1f48d2 in Emacs 29.0.50


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

* Re: What determines if R source block output is wrapped in begin_example or not?
  2022-01-14  9:48   ` Eric S Fraga
@ 2022-01-14 13:13     ` John Hendy
  2022-01-14 14:04       ` Eric S Fraga
  0 siblings, 1 reply; 6+ messages in thread
From: John Hendy @ 2022-01-14 13:13 UTC (permalink / raw)
  To: Org Mode List

On Fri, Jan 14, 2022 at 3:48 AM Eric S Fraga <e.fraga@ucl.ac.uk> wrote:
>
> Have a look at
>
> ,----[ C-h v org-babel-min-lines-for-block-output RET ]
> | org-babel-min-lines-for-block-output is a variable defined in ‘ob-core.el’.
> |
> | Its value is 10
> |
> | The minimum number of lines for block output.
> | If number of lines of output is equal to or exceeds this
> | value, the output is placed in a #+begin_example...#+end_example
> | block.  Otherwise the output is marked as literal by inserting
> | colons at the starts of the lines.  This variable only takes
> | effect if the :results output option is in effect.
> |
> `----

Well, indeed, that's definitely it! Out of curiosity, despite being an
org-mode user for... 10(?) yrs now, is there a heuristic on when to
look at the manual vs. when to M-x help RET v RET
[guess-and-check-randomly]?

I don't feel familiar enough with org internals to have known where to
look... despite this being 100% exactly what I experienced, so much so
it's comedic how accurately it's written vs. what I I would have
described.

Thanks so much!
John
> --
> : Eric S Fraga, with org release_9.5.2-298-g1f48d2 in Emacs 29.0.50


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

* Re: What determines if R source block output is wrapped in begin_example or not?
  2022-01-14 13:13     ` John Hendy
@ 2022-01-14 14:04       ` Eric S Fraga
  2022-01-14 14:44         ` Ihor Radchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Eric S Fraga @ 2022-01-14 14:04 UTC (permalink / raw)
  To: John Hendy; +Cc: Org Mode List

On Friday, 14 Jan 2022 at 07:13, John Hendy wrote:
> is there a heuristic on when to look at the manual vs. when to M-x
> help RET v RET [guess-and-check-randomly]?

Pretty much the heuristic I use. ;-)

This is one of the problems with org: way too many variables.  However,
it is the presence of these variables that makes it so powerful and
gives it the capability to adapt to your own needs so I wouldn't want
less variables.

One technique I do use is "Info-index" in the manual (bound to i in
Info-mode by default) although not everything is indexed.

-- 
: Eric S Fraga, with org release_9.5.2-304-g1537bb in Emacs 29.0.50


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

* Re: What determines if R source block output is wrapped in begin_example or not?
  2022-01-14 14:04       ` Eric S Fraga
@ 2022-01-14 14:44         ` Ihor Radchenko
  0 siblings, 0 replies; 6+ messages in thread
From: Ihor Radchenko @ 2022-01-14 14:44 UTC (permalink / raw)
  To: Eric S Fraga; +Cc: Org Mode List

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

> One technique I do use is "Info-index" in the manual (bound to i in
> Info-mode by default) although not everything is indexed.

Another technique is M-x customize-group <RET> org <RET>
Also, helm-info is often more handy - it provides full text search
through the manual.

Best,
Ihor


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

end of thread, other threads:[~2022-01-14 15:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-13 20:49 What determines if R source block output is wrapped in begin_example or not? John Hendy
2022-01-14  3:04 ` John Hendy
2022-01-14  9:48   ` Eric S Fraga
2022-01-14 13:13     ` John Hendy
2022-01-14 14:04       ` Eric S Fraga
2022-01-14 14:44         ` Ihor Radchenko

Code repositories for project(s) associated with this 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).