From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Hendy Subject: Re: Centering R babel plots in LaTeX/Beamer export? Date: Thu, 12 Jul 2012 16:22:30 -0500 Message-ID: References: <6351.1341869204@alphaville> <8198.1341876273@alphaville> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: Received: from eggs.gnu.org ([208.118.235.92]:45678) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SpQqH-0003vh-GW for emacs-orgmode@gnu.org; Thu, 12 Jul 2012 17:22:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SpQqG-0007CW-31 for emacs-orgmode@gnu.org; Thu, 12 Jul 2012 17:22:33 -0400 Received: from mail-bk0-f41.google.com ([209.85.214.41]:58351) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SpQqF-0007CD-Ls for emacs-orgmode@gnu.org; Thu, 12 Jul 2012 17:22:31 -0400 Received: by bkcjc3 with SMTP id jc3so2519553bkc.0 for ; Thu, 12 Jul 2012 14:22:30 -0700 (PDT) In-Reply-To: <8198.1341876273@alphaville> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: nicholas.dokos@hp.com Cc: emacs-orgmode On Mon, Jul 9, 2012 at 6:24 PM, Nick Dokos wrote: > John Hendy wrote: > >> On Mon, Jul 9, 2012 at 4:26 PM, Nick Dokos wrote: >> > John Hendy 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 >> > >>