all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Centering R babel plots in LaTeX/Beamer export?
@ 2012-07-09 17:18 John Hendy
  2012-07-09 21:26 ` Nick Dokos
  0 siblings, 1 reply; 6+ messages in thread
From: John Hendy @ 2012-07-09 17:18 UTC (permalink / raw)
  To: emacs-orgmode

I'm exporting a Beamer presentation with R babel blocks and my plots
are not centered. This should be a reproducible example:

-----
#+startup: beamer
#+latex_class: beamer
#+options: toc:nil latex:t tex:t
#+latex_class_options: [presentation,bigger]
#+beamer_frame_level: 1

* plot

#+header: :width 8 :height 6
#+begin_src R :exports results :results output graphics :file file.pdf
x <- c(1:10)
y <- x^2
plot(x,y)
#+end_src
-----

I tried putting #+begin_center and #+end_center around the block, but
it changes the LaTeX export to wrapping my R block in
\begin/\end{verbatim}.

Worg ob-R-doc has a :pagecentre option, but says it defaults to true,
so I'm not sure that's my fix.



Thanks,
John

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

* Re: Centering R babel plots in LaTeX/Beamer export?
  2012-07-09 17:18 Centering R babel plots in LaTeX/Beamer export? John Hendy
@ 2012-07-09 21:26 ` Nick Dokos
  2012-07-09 21:56   ` John Hendy
  0 siblings, 1 reply; 6+ messages in thread
From: Nick Dokos @ 2012-07-09 21:26 UTC (permalink / raw)
  To: John Hendy; +Cc: emacs-orgmode

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

> I'm exporting a Beamer presentation with R babel blocks and my plots
> are not centered. This should be a reproducible example:
> 
> -----
> #+startup: beamer
> #+latex_class: beamer
> #+options: toc:nil latex:t tex:t
> #+latex_class_options: [presentation,bigger]
> #+beamer_frame_level: 1
> 
> * plot
> 
> #+header: :width 8 :height 6
> #+begin_src R :exports results :results output graphics :file file.pdf
> x <- c(1:10)
> y <- x^2
> plot(x,y)
> #+end_src
> -----
> 
> I tried putting #+begin_center and #+end_center around the block, but
> it changes the LaTeX export to wrapping my R block in
> \begin/\end{verbatim}.
> 
> Worg ob-R-doc has a :pagecentre option, but says it defaults to true,
> so I'm not sure that's my fix.
> 

This is pretty much brute-force, but seems to work:

--8<---------------cut here---------------start------------->8---
#+startup: beamer
#+latex_class: beamer
#+options: toc:nil latex:t tex:t
#+latex_class_options: [presentation,bigger]
#+beamer_frame_level: 1

* plot

#+header: :width 8 :height 6
#+name: foo
#+begin_src R :exports results :results output graphics :file file.pdf :pagecentre true
x <- c(1:10)
y <- x^2
plot(x,y)
#+end_src

#+LATEX: \begin{center}
#+RESULTS: foo
[[file:file.pdf]]
#+LATEX: \end{center}
--8<---------------cut here---------------end--------------->8---

Nick

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

* Re: Centering R babel plots in LaTeX/Beamer export?
  2012-07-09 21:26 ` Nick Dokos
@ 2012-07-09 21:56   ` John Hendy
  2012-07-09 23:24     ` Nick Dokos
  0 siblings, 1 reply; 6+ messages in thread
From: John Hendy @ 2012-07-09 21:56 UTC (permalink / raw)
  To: nicholas.dokos; +Cc: emacs-orgmode

On Mon, Jul 9, 2012 at 4:26 PM, Nick Dokos <nicholas.dokos@hp.com> wrote:
> John Hendy <jw.hendy@gmail.com> wrote:
>
>> I'm exporting a Beamer presentation with R babel blocks and my plots
>> are not centered. This should be a reproducible example:
>>
>> -----
>> #+startup: beamer
>> #+latex_class: beamer
>> #+options: toc:nil latex:t tex:t
>> #+latex_class_options: [presentation,bigger]
>> #+beamer_frame_level: 1
>>
>> * plot
>>
>> #+header: :width 8 :height 6
>> #+begin_src R :exports results :results output graphics :file file.pdf
>> x <- c(1:10)
>> y <- x^2
>> plot(x,y)
>> #+end_src
>> -----
>>
>> I tried putting #+begin_center and #+end_center around the block, but
>> it changes the LaTeX export to wrapping my R block in
>> \begin/\end{verbatim}.
>>
>> Worg ob-R-doc has a :pagecentre option, but says it defaults to true,
>> so I'm not sure that's my fix.
>>
>
> This is pretty much brute-force, but seems to work:
>
> --8<---------------cut here---------------start------------->8---
> #+startup: beamer
> #+latex_class: beamer
> #+options: toc:nil latex:t tex:t
> #+latex_class_options: [presentation,bigger]
> #+beamer_frame_level: 1
>
> * plot
>
> #+header: :width 8 :height 6
> #+name: foo
> #+begin_src R :exports results :results output graphics :file file.pdf :pagecentre true
> x <- c(1:10)
> y <- x^2
> plot(x,y)
> #+end_src
>
> #+LATEX: \begin{center}
> #+RESULTS: foo
> [[file:file.pdf]]
> #+LATEX: \end{center}
> --8<---------------cut here---------------end--------------->8---
>

I only get a #+results line if I do C-c C-c on the block. I'm
primarily tweaking other stuff and just using C-c C-e p to export to
LaTeX, which produces no #+results section and thus does not allow me
to use a center environment around that bit. I suppose I can manually
add them, but if I re-evaluate babel doesn't recognize it as the
#+results section anymore and I wind up with this after the second
eval:

-----
#+RESULTS: foo
[[file:file.pdf]]

#+LATEX: \begin{center}
#+RESULTS: foo
[[file:file.pdf]]
#+LATEX: \end{center}
-----

I still may consider it as an interim solution. I'm surprised there's
no option to center resultant plots!


John


> Nick
>

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

* Re: Centering R babel plots in LaTeX/Beamer export?
  2012-07-09 21:56   ` John Hendy
@ 2012-07-09 23:24     ` Nick Dokos
  2012-07-12 21:22       ` John Hendy
  0 siblings, 1 reply; 6+ messages in thread
From: Nick Dokos @ 2012-07-09 23:24 UTC (permalink / raw)
  To: John Hendy; +Cc: emacs-orgmode

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

> On Mon, Jul 9, 2012 at 4:26 PM, Nick Dokos <nicholas.dokos@hp.com> wrote:
> > John Hendy <jw.hendy@gmail.com> wrote:
> >
> >> I'm exporting a Beamer presentation with R babel blocks and my plots
> >> are not centered. This should be a reproducible example:
> >>
> >> -----
> >> #+startup: beamer
> >> #+latex_class: beamer
> >> #+options: toc:nil latex:t tex:t
> >> #+latex_class_options: [presentation,bigger]
> >> #+beamer_frame_level: 1
> >>
> >> * plot
> >>
> >> #+header: :width 8 :height 6
> >> #+begin_src R :exports results :results output graphics :file file.pdf
> >> x <- c(1:10)
> >> y <- x^2
> >> plot(x,y)
> >> #+end_src
> >> -----
> >>
> >> I tried putting #+begin_center and #+end_center around the block, but
> >> it changes the LaTeX export to wrapping my R block in
> >> \begin/\end{verbatim}.
> >>
> >> Worg ob-R-doc has a :pagecentre option, but says it defaults to true,
> >> so I'm not sure that's my fix.
> >>
> >
> > This is pretty much brute-force, but seems to work:
> >
> > --8<---------------cut here---------------start------------->8---
> > #+startup: beamer
> > #+latex_class: beamer
> > #+options: toc:nil latex:t tex:t
> > #+latex_class_options: [presentation,bigger]
> > #+beamer_frame_level: 1
> >
> > * plot
> >
> > #+header: :width 8 :height 6
> > #+name: foo
> > #+begin_src R :exports results :results output graphics :file file.pdf :pagecentre true
> > x <- c(1:10)
> > y <- x^2
> > plot(x,y)
> > #+end_src
> >
> > #+LATEX: \begin{center}
> > #+RESULTS: foo
> > [[file:file.pdf]]
> > #+LATEX: \end{center}
> > --8<---------------cut here---------------end--------------->8---
> >
> 
> I only get a #+results line if I do C-c C-c on the block. I'm
> primarily tweaking other stuff and just using C-c C-e p to export to
> LaTeX, which produces no #+results section and thus does not allow me
> to use a center environment around that bit. I suppose I can manually
> add them, but if I re-evaluate babel doesn't recognize it as the
> #+results section anymore and I wind up with this after the second
> eval:
> 

Not here: if you have a *named* code block (did you add the ``#+name: foo''
line to the code block?), the results block is named the same way the first
time it is generated (as you say, C-c C-c on the block is necessary to
produce it). But once it is produced, I can delete the link to file.pdf
(but not the ``#+RESULTS: foo'' line), redo the C-c C-c and end up with
exactly the same thing as before: no duplication of results blocks.

And this property of named blocks allows the results block to be separated
from the code block by arbitrary intervening text:

--8<---------------cut here---------------start------------->8---
#+startup: beamer
#+latex_class: beamer
#+options: toc:nil latex:t tex:t
#+latex_class_options: [presentation,bigger]
#+beamer_frame_level: 1

* plot

#+header: :width 8 :height 6
#+name: foo
#+begin_src R :exports results :results output graphics :file file.pdf :pagecentre true
x <- c(1:10)
y <- x^2
plot(x,y)
#+end_src


foo

bar

* baz

#+LATEX: \begin{center}

#+RESULTS: foo

#+LATEX: \end{center}
--8<---------------cut here---------------end--------------->8---

The link will be placed after the ``#+RESULTS: foo'' line.

Nick

PS. Org-mode version 7.8.11 (release_7.8.11-139-g0442b9 @ /home/nick/elisp/org-mode/lisp/)
    (includes 3 local commits).

> -----
> #+RESULTS: foo
> [[file:file.pdf]]
> 
> #+LATEX: \begin{center}
> #+RESULTS: foo
> [[file:file.pdf]]
> #+LATEX: \end{center}
> -----
> 
> I still may consider it as an interim solution. I'm surprised there's
> no option to center resultant plots!
> 

PPS. There may be: I just don't know.

> 
> John
> 
> 
> > Nick
> >
> 

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

* Re: Centering R babel plots in LaTeX/Beamer export?
  2012-07-09 23:24     ` Nick Dokos
@ 2012-07-12 21:22       ` John Hendy
  2012-07-19 15:29         ` John Hendy
  0 siblings, 1 reply; 6+ messages in thread
From: John Hendy @ 2012-07-12 21:22 UTC (permalink / raw)
  To: nicholas.dokos; +Cc: emacs-orgmode

On Mon, Jul 9, 2012 at 6:24 PM, Nick Dokos <nicholas.dokos@hp.com> wrote:
> John Hendy <jw.hendy@gmail.com> wrote:
>
>> On Mon, Jul 9, 2012 at 4:26 PM, Nick Dokos <nicholas.dokos@hp.com> wrote:
>> > John Hendy <jw.hendy@gmail.com> wrote:
>> >
>> >> I'm exporting a Beamer presentation with R babel blocks and my plots
>> >> are not centered. This should be a reproducible example:
>> >>
>> >> -----
>> >> #+startup: beamer
>> >> #+latex_class: beamer
>> >> #+options: toc:nil latex:t tex:t
>> >> #+latex_class_options: [presentation,bigger]
>> >> #+beamer_frame_level: 1
>> >>
>> >> * plot
>> >>
>> >> #+header: :width 8 :height 6
>> >> #+begin_src R :exports results :results output graphics :file file.pdf
>> >> x <- c(1:10)
>> >> y <- x^2
>> >> plot(x,y)
>> >> #+end_src
>> >> -----
>> >>
>> >> I tried putting #+begin_center and #+end_center around the block, but
>> >> it changes the LaTeX export to wrapping my R block in
>> >> \begin/\end{verbatim}.
>> >>
>> >> Worg ob-R-doc has a :pagecentre option, but says it defaults to true,
>> >> so I'm not sure that's my fix.
>> >>
>> >
>> > This is pretty much brute-force, but seems to work:
>> >
>> > --8<---------------cut here---------------start------------->8---
>> > #+startup: beamer
>> > #+latex_class: beamer
>> > #+options: toc:nil latex:t tex:t
>> > #+latex_class_options: [presentation,bigger]
>> > #+beamer_frame_level: 1
>> >
>> > * plot
>> >
>> > #+header: :width 8 :height 6
>> > #+name: foo
>> > #+begin_src R :exports results :results output graphics :file file.pdf :pagecentre true
>> > x <- c(1:10)
>> > y <- x^2
>> > plot(x,y)
>> > #+end_src
>> >
>> > #+LATEX: \begin{center}
>> > #+RESULTS: foo
>> > [[file:file.pdf]]
>> > #+LATEX: \end{center}
>> > --8<---------------cut here---------------end--------------->8---
>> >
>>
>> I only get a #+results line if I do C-c C-c on the block. I'm
>> primarily tweaking other stuff and just using C-c C-e p to export to
>> LaTeX, which produces no #+results section and thus does not allow me
>> to use a center environment around that bit. I suppose I can manually
>> add them, but if I re-evaluate babel doesn't recognize it as the
>> #+results section anymore and I wind up with this after the second
>> eval:
>>
>
> Not here: if you have a *named* code block (did you add the ``#+name: foo''
> line to the code block?), the results block is named the same way the first
> time it is generated (as you say, C-c C-c on the block is necessary to
> produce it). But once it is produced, I can delete the link to file.pdf
> (but not the ``#+RESULTS: foo'' line), redo the C-c C-c and end up with
> exactly the same thing as before: no duplication of results blocks.

Ah. I did not (and do not usually) use the #+name argument. I'll try that out.


Thanks!
John

>
> And this property of named blocks allows the results block to be separated
> from the code block by arbitrary intervening text:
>
> --8<---------------cut here---------------start------------->8---
> #+startup: beamer
> #+latex_class: beamer
> #+options: toc:nil latex:t tex:t
> #+latex_class_options: [presentation,bigger]
> #+beamer_frame_level: 1
>
> * plot
>
> #+header: :width 8 :height 6
> #+name: foo
> #+begin_src R :exports results :results output graphics :file file.pdf :pagecentre true
> x <- c(1:10)
> y <- x^2
> plot(x,y)
> #+end_src
>
>
> foo
>
> bar
>
> * baz
>
> #+LATEX: \begin{center}
>
> #+RESULTS: foo
>
> #+LATEX: \end{center}
> --8<---------------cut here---------------end--------------->8---
>
> The link will be placed after the ``#+RESULTS: foo'' line.
>
> Nick
>
> PS. Org-mode version 7.8.11 (release_7.8.11-139-g0442b9 @ /home/nick/elisp/org-mode/lisp/)
>     (includes 3 local commits).
>
>> -----
>> #+RESULTS: foo
>> [[file:file.pdf]]
>>
>> #+LATEX: \begin{center}
>> #+RESULTS: foo
>> [[file:file.pdf]]
>> #+LATEX: \end{center}
>> -----
>>
>> I still may consider it as an interim solution. I'm surprised there's
>> no option to center resultant plots!
>>
>
> PPS. There may be: I just don't know.
>
>>
>> John
>>
>>
>> > Nick
>> >
>>

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

* Re: Centering R babel plots in LaTeX/Beamer export?
  2012-07-12 21:22       ` John Hendy
@ 2012-07-19 15:29         ` John Hendy
  0 siblings, 0 replies; 6+ messages in thread
From: John Hendy @ 2012-07-19 15:29 UTC (permalink / raw)
  To: nicholas.dokos; +Cc: emacs-orgmode

On Thu, Jul 12, 2012 at 4:22 PM, John Hendy <jw.hendy@gmail.com> wrote:
> On Mon, Jul 9, 2012 at 6:24 PM, Nick Dokos <nicholas.dokos@hp.com> wrote:
>> John Hendy <jw.hendy@gmail.com> wrote:
>>
>>> On Mon, Jul 9, 2012 at 4:26 PM, Nick Dokos <nicholas.dokos@hp.com> wrote:
>>> > John Hendy <jw.hendy@gmail.com> wrote:
>>> >
>>> >> I'm exporting a Beamer presentation with R babel blocks and my plots
>>> >> are not centered. This should be a reproducible example:
>>> >>
>>> >> -----
>>> >> #+startup: beamer
>>> >> #+latex_class: beamer
>>> >> #+options: toc:nil latex:t tex:t
>>> >> #+latex_class_options: [presentation,bigger]
>>> >> #+beamer_frame_level: 1
>>> >>
>>> >> * plot
>>> >>
>>> >> #+header: :width 8 :height 6
>>> >> #+begin_src R :exports results :results output graphics :file file.pdf
>>> >> x <- c(1:10)
>>> >> y <- x^2
>>> >> plot(x,y)
>>> >> #+end_src
>>> >> -----
>>> >>
>>> >> I tried putting #+begin_center and #+end_center around the block, but
>>> >> it changes the LaTeX export to wrapping my R block in
>>> >> \begin/\end{verbatim}.
>>> >>
>>> >> Worg ob-R-doc has a :pagecentre option, but says it defaults to true,
>>> >> so I'm not sure that's my fix.
>>> >>
>>> >
>>> > This is pretty much brute-force, but seems to work:
>>> >
>>> > --8<---------------cut here---------------start------------->8---
>>> > #+startup: beamer
>>> > #+latex_class: beamer
>>> > #+options: toc:nil latex:t tex:t
>>> > #+latex_class_options: [presentation,bigger]
>>> > #+beamer_frame_level: 1
>>> >
>>> > * plot
>>> >
>>> > #+header: :width 8 :height 6
>>> > #+name: foo
>>> > #+begin_src R :exports results :results output graphics :file file.pdf :pagecentre true
>>> > x <- c(1:10)
>>> > y <- x^2
>>> > plot(x,y)
>>> > #+end_src
>>> >
>>> > #+LATEX: \begin{center}
>>> > #+RESULTS: foo
>>> > [[file:file.pdf]]
>>> > #+LATEX: \end{center}
>>> > --8<---------------cut here---------------end--------------->8---
>>> >
>>>
>>> I only get a #+results line if I do C-c C-c on the block. I'm
>>> primarily tweaking other stuff and just using C-c C-e p to export to
>>> LaTeX, which produces no #+results section and thus does not allow me
>>> to use a center environment around that bit. I suppose I can manually
>>> add them, but if I re-evaluate babel doesn't recognize it as the
>>> #+results section anymore and I wind up with this after the second
>>> eval:
>>>
>>
>> Not here: if you have a *named* code block (did you add the ``#+name: foo''
>> line to the code block?), the results block is named the same way the first
>> time it is generated (as you say, C-c C-c on the block is necessary to
>> produce it). But once it is produced, I can delete the link to file.pdf
>> (but not the ``#+RESULTS: foo'' line), redo the C-c C-c and end up with
>> exactly the same thing as before: no duplication of results blocks.

Tried this and confirm it works. Not too bad. One oddity. I re-use a
lot of similar R blocks for the same plot types but different data
attributes. I'll copy a block, change the :file attribute and #+name
of the block as as well as the #+results name argument, but when I
execute the block, I get a new #+results line. If I delete the new
line that was created and keep the old one from the copy/yank, it then
updates that.

Is there a reason it doesn't realize there's a named results block
already in existence until after it runs the first time?


John

>
> Ah. I did not (and do not usually) use the #+name argument. I'll try that out.
>
>
> Thanks!
> John
>
>>
>> And this property of named blocks allows the results block to be separated
>> from the code block by arbitrary intervening text:
>>
>> --8<---------------cut here---------------start------------->8---
>> #+startup: beamer
>> #+latex_class: beamer
>> #+options: toc:nil latex:t tex:t
>> #+latex_class_options: [presentation,bigger]
>> #+beamer_frame_level: 1
>>
>> * plot
>>
>> #+header: :width 8 :height 6
>> #+name: foo
>> #+begin_src R :exports results :results output graphics :file file.pdf :pagecentre true
>> x <- c(1:10)
>> y <- x^2
>> plot(x,y)
>> #+end_src
>>
>>
>> foo
>>
>> bar
>>
>> * baz
>>
>> #+LATEX: \begin{center}
>>
>> #+RESULTS: foo
>>
>> #+LATEX: \end{center}
>> --8<---------------cut here---------------end--------------->8---
>>
>> The link will be placed after the ``#+RESULTS: foo'' line.
>>
>> Nick
>>
>> PS. Org-mode version 7.8.11 (release_7.8.11-139-g0442b9 @ /home/nick/elisp/org-mode/lisp/)
>>     (includes 3 local commits).
>>
>>> -----
>>> #+RESULTS: foo
>>> [[file:file.pdf]]
>>>
>>> #+LATEX: \begin{center}
>>> #+RESULTS: foo
>>> [[file:file.pdf]]
>>> #+LATEX: \end{center}
>>> -----
>>>
>>> I still may consider it as an interim solution. I'm surprised there's
>>> no option to center resultant plots!
>>>
>>
>> PPS. There may be: I just don't know.
>>
>>>
>>> John
>>>
>>>
>>> > Nick
>>> >
>>>

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

end of thread, other threads:[~2012-07-19 15:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-09 17:18 Centering R babel plots in LaTeX/Beamer export? John Hendy
2012-07-09 21:26 ` Nick Dokos
2012-07-09 21:56   ` John Hendy
2012-07-09 23:24     ` Nick Dokos
2012-07-12 21:22       ` John Hendy
2012-07-19 15:29         ` John Hendy

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.