From mboxrd@z Thu Jan 1 00:00:00 1970 From: Feiming Chen Subject: Re: Bug: Org-Babel Mode R Plot Output to LaTeX File [Babel] [7.5] Date: Mon, 18 Jul 2011 09:19:45 -0700 (PDT) Message-ID: <1311005985.52922.YahooMailClassic@web81703.mail.mud.yahoo.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="0-874255018-1311005985=:52922" Return-path: Received: from eggs.gnu.org ([140.186.70.92]:42989) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QiqXx-0004V0-DM for emacs-orgmode@gnu.org; Mon, 18 Jul 2011 12:19:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QiqXs-0006ar-Eq for emacs-orgmode@gnu.org; Mon, 18 Jul 2011 12:19:53 -0400 Received: from nm19-vm0.access.bullet.mail.mud.yahoo.com ([66.94.236.25]:47711) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1QiqXr-0006aj-Mp for emacs-orgmode@gnu.org; Mon, 18 Jul 2011 12:19:48 -0400 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: Eric Schulte Cc: emacs-orgmode@gnu.org --0-874255018-1311005985=:52922 Content-Type: multipart/alternative; boundary="0-865750877-1311005985=:52922" --0-865750877-1311005985=:52922 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Hi Eric:=20 Thanks a lot!=A0=A0 It would be nice if Org-Babel model could automatically= add the "#+ATTR_LaTeX" lines (from the hint in the R code header line) dur= ing LaTeX export. Somehow I failed to compile the file on my system.=A0 It seems the line:=20 #+ATTR_LaTeX: width=3D5px has corrupted the PDF file generated in R.=A0=A0 Because after "C-c C-e d",= =A0 I get the following error: !pdfTeX error: pdflatex (file ./a3.pdf): PDF inclusion: required page does = not exist <0> =0A=A0=3D=3D> Fatal error occurred, no output PDF file produced! =0A and=A0 I could not open the PDF file of the R plot any more (the error mess= age is "Cannot display this page! Maybe because of a conversion failure").= =A0=A0=20 Attached is the simplified org file that failed on "LaTeX transport" on my = computer.=A0=20 Thanks!=A0=20 Sincerely,=20 =0AFeiming Chen --- On Fri, 7/15/11, Eric Schulte wrote: From: Eric Schulte Subject: Re: [O] Bug: Org-Babel Mode R Plot Output to LaTeX File [Babel] [7= .5] To: "Feiming Chen" Cc: emacs-orgmode@gnu.org Date: Friday, July 15, 2011, 9:32 AM Hi Feiming, The "width" and "height" header arguments are passed to R to affect the size of the generated file e.g., =A0 png(filename=3D"a1.png",width=3D500,height=3D500) however they do not affect the generated latex code.=A0 Luckily Org-mode does support passing information like image width to latex figures.=A0 See my attached version of your test file which uses #+ATTR_LaTeX lines to specify the width during LaTeX=0A export. Best -- Eric -----Inline Attachment Follows----- Feiming Chen writes: > Hi, I like org-mode and org-babel mode very much, but recently I am=A0 ha= ving problems outputting R graphics to LaTeX report with > Org-Babel mode.=A0 Attached is my test file, where I am generating 4 > simple plots of different sizes and format (.png or .pdf).=A0 The HTML > export is satisfactory, however, the LaTeX export (C-c C-e l) presents tw= o problems:=20 > > =A0=A0=A0 1.=A0 All 4 plots have the same size (10em) which is different = from the > =A0=A0=A0 header specification and is too small. > > \includegraphics[width=3D10em]{a1.png} ... > \includegraphics[width=3D10em]{a2.png} ... >=0A \includegraphics[width=3D10em]{a3.pdf} ... > \includegraphics[width=3D10em]{a4.pdf} ... > > =A0=A0=A0 2. While exporting to PDF file, the R code is mysteriously lost= in > =A0=A0=A0 the R execution for the PDF output of the plots and the compila= tion failed correspondingly:=20 > >> pdf(file=3D"a3.pdf",width=3D5,height=3D5) >>=20 >> dev.off() >> pdf(file=3D"a4.pdf",width=3D10,height=3D10) >> >> dev.off() > > > Hopefully you can replicate my errors and help me on this.=A0 Thanks a > lot! > > Best regards,=20 > Feiming Chen > > ____________________________________________________________ > > > Emacs=A0 : GNU Emacs 23.2.1 (i386-redhat-linux-gnu, GTK+ Version 2.21.4) > =A0of 2010-07-08 on x86-05.phx2.fedoraproject.org > Package: Org-mode version 7.5 > > current state: >=0A =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > (setq > =A0org-file-apps '((auto-mode . emacs) ("\\.mm\\'" . default) > =A0=A0 =A0=A0=A0=A0 =A0("\\.x?html?\\'" . "firefox %s") ("\\.pdf\\'" . "e= vince %s")) > =A0org-export-latex-after-initial-vars-hook '(org-beamer-after-initial-va= rs) > =A0org-hide-block-startup t > =A0org-speed-command-hook '(org-speed-command-default-hook > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 =A0 org-babel-speed-command-hook) > =A0org-src-fontify-natively t > =A0org-babel-load-languages '((emacs-lisp . t) (R . t)) > =A0org-metaup-hook '(org-babel-load-in-session-maybe) > =A0org-after-todo-state-change-hook '(org-clock-out-if-current) > =A0org-export-blocks-postblock-hook '(org-exp-res/src-name-cleanup) > =A0org-export-latex-format-toc-function 'org-export-latex-format-toc-defa= ult > =A0org-tab-first-hook=0A '(org-hide-block-toggle-maybe > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0=A0=A0 org-src-native-tab-command-maybe > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0=A0=A0 org-babel-hide-result-toggle-maybe) > =A0outline-regexp "\\*+ " > =A0org-src-mode-hook '(org-src-babel-configure-edit-buffer > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0=A0 org-src-mode-configure-edit-buffer) > =A0org-confirm-shell-link-function 'yes-or-no-p > =A0org-reveal-start-hook '(org-decrypt-entry) > =A0org-export-first-hook '(org-beamer-initialize-open-trackers) > =A0org-format-latex-header > "\\documentclass{article}\n\\usepackage[usenames]{color}\n\\usepackage{am= smath}\n\\usepackage[mathscr]{eucal}\n% > Feiming's Customization > BEGIN\n\\usepackage[colorlinks=3Dtrue]{hyperref}\n\\input{/home/chen/lib/= math.tex}\n% > Feiming's=0A Customization END\n\\pagestyle{empty}=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0 % do not > remove\n[PACKAGES]\n[DEFAULT-PACKAGES]\n% The settings below are > copied from > fullpage.sty\n\\setlength{\\textwidth}{\\paperwidth}\n\\addtolength{\\tex= twidth}{-3cm}\n\\setlength{\\oddsidemargin}{1.5cm}\n\\addtolength{\\oddside= margin}{-2.54cm}\n\\setlength{\\evensidemargin}{\\oddsidemargin}\n\\setleng= th{\\textheight}{\\paperheight}\n\\addtolength{\\textheight}{-\\headheight}= \n\\addtolength{\\textheight}{-\\headsep}\n\\addtolength{\\textheight}{-\\f= ootskip}\n\\addtolength{\\textheight}{-3cm}\n\\setlength{\\topmargin}{1.5cm= }\n\\addtolength{\\topmargin}{-2.54cm}" > =A0org-startup-indented t > =A0org-agenda-before-write-hook '(org-agenda-add-entry-text) > =A0org-babel-pre-tangle-hook '(save-buffer) > =A0org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-hide-drawe= rs >=0A =A0=A0 =A0=A0=A0=A0 =A0 org-cycle-show-empty-lines > =A0=A0 =A0=A0=A0=A0 =A0 org-optimize-window-after-visibility-change) > =A0org-export-preprocess-before-normalizing-links-hook '(org-remove-file-= link-modifiers) > =A0org-use-speed-commands t > =A0org-mode-hook '(turn-on-org-cdlatex > =A0=A0 =A0=A0=A0=A0 =A0(lambda nil > =A0=A0 =A0=A0=A0=A0 =A0 (setq org-mouse-context-menu-function > =A0=A0 =A0=A0=A0=A0 =A0=A0 (quote org-mouse-context-menu)) > =A0=A0 =A0=A0=A0=A0 =A0 (when (memq (quote context-menu) org-mouse-featur= es) > =A0=A0 =A0=A0=A0=A0 =A0=A0 (org-defkey org-mouse-map [mouse-3] nil) > =A0=A0 =A0=A0=A0=A0 =A0=A0 (org-defkey org-mode-map [mouse-3] > =A0=A0 =A0=A0=A0=A0=0A =A0=A0=A0 (quote org-mouse-show-context-menu)) > =A0=A0 =A0=A0=A0=A0 =A0=A0 ) > =A0=A0 =A0=A0=A0=A0 =A0 (org-defkey org-mode-map [down-mouse-1] > =A0=A0 =A0=A0=A0=A0 =A0=A0 (quote org-mouse-down-mouse)) > =A0=A0 =A0=A0=A0=A0 =A0 (when (memq (quote context-menu) org-mouse-featur= es) > =A0=A0 =A0=A0=A0=A0 =A0=A0 (org-defkey org-mouse-map [C-drag-mouse-1] > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 (quote org-mouse-move-tree)) > =A0=A0 =A0=A0=A0=A0 =A0=A0 (org-defkey org-mouse-map [C-down-mouse-1] > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 (quote org-mouse-move-tree-start)) > =A0=A0 =A0=A0=A0=A0 =A0=A0 ) > =A0=A0 =A0=A0=A0=A0 =A0 (when (memq (quote yank-link)=0A org-mouse-featur= es) > =A0=A0 =A0=A0=A0=A0 =A0=A0 (org-defkey org-mode-map [S-mouse-2] > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 (quote org-mouse-yank-link)) > =A0=A0 =A0=A0=A0=A0 =A0=A0 (org-defkey org-mode-map [drag-mouse-3] > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 (quote org-mouse-yank-link)) > =A0=A0 =A0=A0=A0=A0 =A0=A0 ) > =A0=A0 =A0=A0=A0=A0 =A0 (when (memq (quote move-tree) org-mouse-features) > =A0=A0 =A0=A0=A0=A0 =A0=A0 (org-defkey org-mouse-map [drag-mouse-3] > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 (quote org-mouse-move-tree)) > =A0=A0 =A0=A0=A0=A0 =A0=A0 (org-defkey org-mouse-map [down-mouse-3] > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 (quote=0A org-mouse-move-tree-start)) > =A0=A0 =A0=A0=A0=A0 =A0=A0 ) > =A0=A0 =A0=A0=A0=A0 =A0 (when (memq (quote activate-stars) org-mouse-feat= ures) > =A0=A0 =A0=A0=A0=A0 =A0=A0 (font-lock-add-keywords nil > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 (\` > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0=A0 (((\, outline-regexp) 0 > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0=A0=A0=A0 (\` > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 (face org-link mouse-face highlight keymap > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 =A0(\, org-mouse-map)) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 ) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0=A0=A0=A0 (quote prepend)) > =A0=A0 =A0=A0=A0=A0=0A =A0=A0=A0=A0=A0 ) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0=A0 ) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 t) > =A0=A0 =A0=A0=A0=A0 =A0=A0 ) > =A0=A0 =A0=A0=A0=A0 =A0 (when (memq (quote activate-bullets) org-mouse-fe= atures) > =A0=A0 =A0=A0=A0=A0 =A0=A0 (font-lock-add-keywords nil > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 (\` > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0=A0 (("^[=A0=A0 =A0]*\\([-+*]\\|[0-9]+[.)]\\= ) +" > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0=A0=A0=A0 (1 > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 (\` > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 =A0(face org-link keymap (\, org-mouse-map)= mouse-face > =A0=A0 =A0=A0=A0=A0=0A =A0=A0=A0 =A0 highlight) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 =A0) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 (quote prepend)) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0=A0=A0=A0 ) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0=A0=A0 ) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0=A0 ) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 t) > =A0=A0 =A0=A0=A0=A0 =A0=A0 ) > =A0=A0 =A0=A0=A0=A0 =A0 (when (memq (quote activate-checkboxes) org-mouse= -features) > =A0=A0 =A0=A0=A0=A0 =A0=A0 (font-lock-add-keywords nil > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 (\` > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0=A0 (("^[=A0=A0 =A0]*\\([-+*]\\|[0-9]+[.)]\\= ) +\\(\\[[=0A X]\\]\\)" > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0=A0=A0=A0 (2 > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 (\` > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 =A0(face bold keymap (\, org-mouse-map) mou= se-face > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 =A0 highlight) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 =A0) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 t) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0=A0=A0=A0 ) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0=A0=A0 ) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0=A0 ) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 t) > =A0=A0 =A0=A0=A0=A0 =A0=A0 ) > =A0=A0 =A0=A0=A0=A0 =A0 (defadvice org-open-at-point >=0A =A0=A0 =A0=A0=A0=A0 =A0=A0 (around org-mouse-open-at-point activate) > =A0=A0 =A0=A0=A0=A0 =A0=A0 (let ((context (org-context))) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 (cond ((assq :headline-stars context) (org-= cycle)) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0=A0 ((assq :checkbox context) (org-toggle-ch= eckbox)) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0=A0 ((assq :item-bullet context) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0=A0=A0 (let ((org-cycle-include-plain-lists = t)) (org-cycle))) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0=A0 (t ad-do-it)) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 ) > =A0=A0 =A0=A0=A0=A0 =A0=A0 ) > =A0=A0 =A0=A0=A0=A0 =A0 ) > =A0=A0 =A0=A0=A0=A0=0A =A0#[nil "\300\301\302\303\304$\207" > =A0=A0 =A0=A0=A0=A0 =A0=A0 [org-add-hook change-major-mode-hook org-show-= block-all append > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 local] > =A0=A0 =A0=A0=A0=A0 =A0=A0 5] > =A0=A0 =A0=A0=A0=A0 =A0#[nil "\300\301\302\303\304$\207" > =A0=A0 =A0=A0=A0=A0 =A0=A0 [org-add-hook change-major-mode-hook org-babel= -show-result-all > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 append local] > =A0=A0 =A0=A0=A0=A0 =A0=A0 5] > =A0=A0 =A0=A0=A0=A0 =A0org-babel-result-hide-spec org-babel-hide-all-hash= es) > =A0org-ctrl-c-ctrl-c-hook '(org-babel-hash-at-point org-babel-execute-saf= ely-maybe) > =A0org-confirm-elisp-link-function 'yes-or-no-p > =A0org-agenda-mode-hook '((lambda nil >=0A =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 =A0(setq org-mouse-context-menu-function > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 =A0 (quote org-mouse-agenda-context-menu)) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 =A0(org-defkey org-agenda-mode-map [mouse-3= ] > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 =A0 (quote org-mouse-show-context-menu)) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 =A0(org-defkey org-agenda-mode-map [down-mo= use-3] > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 =A0 (quote org-mouse-move-tree-start)) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 =A0(org-defkey org-agenda-mode-map [C-mouse= -4] > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 =A0 (quote org-agenda-earlier)) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 =A0(org-defkey=0A org-agenda-mode-map [C-mo= use-5] > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 =A0 (quote org-agenda-later)) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 =A0(org-defkey org-agenda-mode-map [drag-mo= use-3] > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 =A0 (quote > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 =A0=A0 (lambda (event) (interactive "e") > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 (case (org-mouse-get-gesture even= t) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 =A0=A0=A0=A0 (:left (org-agenda-earlier 1)) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 =A0=A0=A0=A0 (:right (org-agenda-later 1))) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 ) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 =A0=A0=0A ) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 =A0 ) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 =A0) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 ) > =A0org-export-interblocks '((lob org-babel-exp-lob-one-liners) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 =A0 (src org-babel-exp-inline-src-blocks)) > =A0org-occur-hook '(org-first-headline-recenter) > =A0org-export-preprocess-before-selecting-backend-code-hook '(org-beamer-= select-beamer-code) > =A0org-confirm-babel-evaluate nil > =A0org-infojs-options '((path . "http://bancs.bdx.com/chen/lib/org-info.j= s") > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0=A0=A0 (view . "overview") (toc . "nil") (ft= oc . "0") > =A0=A0 =A0=A0=A0=A0=0A =A0=A0=A0=A0=A0 (tdepth . "max") (sdepth . "max") = (mouse . "underline") > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0=A0=A0 (buttons . "0") (ltoc . "1") (up . :l= ink-up) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0=A0=A0 (home . :link-home)) > =A0org-src-tab-acts-natively t > =A0org-export-latex-final-hook '(org-beamer-amend-header org-beamer-fix-t= oc > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 =A0=A0=A0=A0=A0=A0 org-beamer-auto-fragile-= frames > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0 =A0=A0=A0=A0=A0=A0 org-beamer-place-default= -actions-for-lists) > =A0org-metadown-hook '(org-babel-pop-to-session-maybe) > =A0org-export-blocks '((src org-babel-exp-src-block nil) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0=A0 (comment org-export-blocks-format-commen= t=0A t) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0=A0 (ditaa org-export-blocks-format-ditaa ni= l) > =A0=A0 =A0=A0=A0=A0 =A0=A0=A0=A0 (dot org-export-blocks-format-dot nil)) > =A0) > > --=20 Eric Schulte http://cs.unm.edu/~eschulte/ --0-865750877-1311005985=:52922 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable
Hi Eric:

Thanks a lot!   It would = be nice if Org-Babel model could automatically add the "#+ATTR_LaTeX" lines= (from the hint in the R code header line) during LaTeX export.

Some= how I failed to compile the file on my system.  It seems the line:
#+ATTR_LaTeX: width=3D5px

has corrupted the PDF file generated = in R.   Because after "C-c C-e d",  I get the following erro= r:

!pdfTeX error: pdflatex (file ./a3.pdf): PDF inclusion: required = page does not exist <0>
=0A =3D=3D> Fatal error occurred, no output PDF file = produced!
=0A
and  I could not open the PDF file of the R plot a= ny more (the error message is "Cannot display this page! Maybe because of a= conversion failure").  

Attached is the simplified org f= ile that failed on "LaTeX transport" on my computer. 

Thanks!&= nbsp;

Sincerely,
=0AFeiming Chen

--- On Fri, 7/15/11,= Eric Schulte <schulte.eric@gmail.com> wrote:

From: Eric Schulte <schulte.eric@gmail.com>
Su= bject: Re: [O] Bug: Org-Babel Mode R Plot Output to LaTeX File [Babel] [7.5= ]
To: "Feiming Chen" <feimingchen@yahoo.com>
Cc: emacs-orgmode@= gnu.org
Date: Friday, July 15, 2011, 9:32 AM

Hi Feiming,

The "width" and "height" header argumen= ts are passed to R to affect the
size of the generated file e.g.,
  png(filename=3D"a1.png",width=3D500,height=3D500)

however th= ey do not affect the generated latex code.  Luckily Org-mode
does s= upport passing information like image width to latex figures.  See
= my attached version of your test file which uses #+ATTR_LaTeX lines to
s= pecify the width during LaTeX=0A export.

Best -- Eric

<= br>-----Inline Attachment Follows-----


Feiming Chen <feimingchen@yahoo.com&= gt; writes:

> Hi, I like org-mode and org-babel mode very much, b= ut recently I am  having problems outputting R graphics to LaTeX repor= t with
> Org-Babel mode.  Attached is my test file, where I am g= enerating 4
> simple plots of different sizes and format (.png or .pd= f).  The HTML
> export is satisfactory, however, the LaTeX expor= t (C-c C-e l) presents two problems:
>
>     1.=   All 4 plots have the same size (10em) which is different from the>     header specification and is too small.
>
= > \includegraphics[width=3D10em]{a1.png} ...
> \includegraphics[wi= dth=3D10em]{a2.png} ...
>=0A \includegraphics[width=3D10em]{a3.pdf} .= ..
> \includegraphics[width=3D10em]{a4.pdf} ...
>
>  = ;   2. While exporting to PDF file, the R code is mysteriously lo= st in
>     the R execution for the PDF output of the = plots and the compilation failed correspondingly:
>
>> pdf(= file=3D"a3.pdf",width=3D5,height=3D5)
>>
>> dev.off()>> pdf(file=3D"a4.pdf",width=3D10,height=3D10)
>>
>&g= t; dev.off()
>
>
> Hopefully you can replicate my errors = and help me on this.  Thanks a
> lot!
>
> Best regar= ds,
> Feiming Chen
>
> _________________________________= ___________________________
>
>
> Emacs  : GNU Emacs= 23.2.1 (i386-redhat-linux-gnu, GTK+ Version 2.21.4)
>  of 2010-= 07-08 on x86-05.phx2.fedoraproject.org
> Package: Org-mode version 7.= 5
>
> current state:
>=0A =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D
> (setq
>  org-file-apps '((auto-mode . emacs= ) ("\\.mm\\'" . default)
>         &nbs= p;("\\.x?html?\\'" . "firefox %s") ("\\.pdf\\'" . "evince %s"))
> &nb= sp;org-export-latex-after-initial-vars-hook '(org-beamer-after-initial-vars= )
>  org-hide-block-startup t
>  org-speed-command-ho= ok '(org-speed-command-default-hook
>       =         org-babel-speed-command-hook)
> &nbs= p;org-src-fontify-natively t
>  org-babel-load-languages '((emac= s-lisp . t) (R . t))
>  org-metaup-hook '(org-babel-load-in-sess= ion-maybe)
>  org-after-todo-state-change-hook '(org-clock-out-i= f-current)
>  org-export-blocks-postblock-hook '(org-exp-res/src= -name-cleanup)
>  org-export-latex-format-toc-function 'org-expo= rt-latex-format-toc-default
>  org-tab-first-hook=0A '(org-hide-= block-toggle-maybe
>          &nbs= p;    org-src-native-tab-command-maybe
>    =            org-babel-hide-resu= lt-toggle-maybe)
>  outline-regexp "\\*+ "
>  org-src= -mode-hook '(org-src-babel-configure-edit-buffer
>     = ;         org-src-mode-configure-edit-bu= ffer)
>  org-confirm-shell-link-function 'yes-or-no-p
> &n= bsp;org-reveal-start-hook '(org-decrypt-entry)
>  org-export-fir= st-hook '(org-beamer-initialize-open-trackers)
>  org-format-lat= ex-header
> "\\documentclass{article}\n\\usepackage[usenames]{color}\= n\\usepackage{amsmath}\n\\usepackage[mathscr]{eucal}\n%
> Feiming's C= ustomization
> BEGIN\n\\usepackage[colorlinks=3Dtrue]{hyperref}\n\\in= put{/home/chen/lib/math.tex}\n%
> Feiming's=0A Customization END\n\\p= agestyle{empty}          =    % do not
> remove\n[PACKAGES]\n[DEFAULT-PACKAGES]\n% The= settings below are
> copied from
> fullpage.sty\n\\setlength{\= \textwidth}{\\paperwidth}\n\\addtolength{\\textwidth}{-3cm}\n\\setlength{\\= oddsidemargin}{1.5cm}\n\\addtolength{\\oddsidemargin}{-2.54cm}\n\\setlength= {\\evensidemargin}{\\oddsidemargin}\n\\setlength{\\textheight}{\\paperheigh= t}\n\\addtolength{\\textheight}{-\\headheight}\n\\addtolength{\\textheight}= {-\\headsep}\n\\addtolength{\\textheight}{-\\footskip}\n\\addtolength{\\tex= theight}{-3cm}\n\\setlength{\\topmargin}{1.5cm}\n\\addtolength{\\topmargin}= {-2.54cm}"
>  org-startup-indented t
>  org-agenda-be= fore-write-hook '(org-agenda-add-entry-text)
>  org-babel-pre-ta= ngle-hook '(save-buffer)
>  org-cycle-hook '(org-cycle-hide-arch= ived-subtrees org-cycle-hide-drawers
>=0A      &n= bsp;    org-cycle-show-empty-lines
>     &nb= sp;     org-optimize-window-after-visibility-change)
>=  org-export-preprocess-before-normalizing-links-hook '(org-remove-fil= e-link-modifiers)
>  org-use-speed-commands t
>  org-= mode-hook '(turn-on-org-cdlatex
>       &nbs= p;  (lambda nil
>           (= setq org-mouse-context-menu-function
>       = ;     (quote org-mouse-context-menu))
>    &= nbsp;      (when (memq (quote context-menu) org-mouse-f= eatures)
>            (org-de= fkey org-mouse-map [mouse-3] nil)
>       &n= bsp;    (org-defkey org-mode-map [mouse-3]
>    &= nbsp;   =0A     (quote org-mouse-show-context= -menu))
>            )
>= ;           (org-defkey org-mode-map [do= wn-mouse-1]
>            (quo= te org-mouse-down-mouse))
>         &nb= sp; (when (memq (quote context-menu) org-mouse-features)
>  &nbs= p;         (org-defkey org-mouse-map [C-drag-= mouse-1]
>             (= quote org-mouse-move-tree))
>         &= nbsp;  (org-defkey org-mouse-map [C-down-mouse-1]
>   =          (quote org-mouse-move-tree-sta= rt))
>            )
> &= nbsp;         (when (memq (quote yank-link)= =0A org-mouse-features)
>          = ;  (org-defkey org-mode-map [S-mouse-2]
>     &nb= sp;       (quote org-mouse-yank-link))
> &nb= sp;          (org-defkey org-mode-map [d= rag-mouse-3]
>           &nbs= p; (quote org-mouse-yank-link))
>       &nbs= p;    )
>           (whe= n (memq (quote move-tree) org-mouse-features)
>     &n= bsp;      (org-defkey org-mouse-map [drag-mouse-3]
&= gt;             (quote org-mou= se-move-tree))
>            (= org-defkey org-mouse-map [down-mouse-3]
>      &n= bsp;      (quote=0A org-mouse-move-tree-start))
>=            )
>    =        (when (memq (quote activate-stars) org-mous= e-features)
>            (fon= t-lock-add-keywords nil
>          = ;   (\`
>           = ;   (((\, outline-regexp) 0
>      &nbs= p;         (\`
>    &nbs= p;        (face org-link mouse-face highlight= keymap
>             &n= bsp;(\, org-mouse-map))
>          = ;   )
>           &= nbsp;    (quote prepend))
>      &= nbsp; =0A       )
>     =          )
>     &n= bsp;       t)
>      &nb= sp;     )
>         &nbs= p; (when (memq (quote activate-bullets) org-mouse-features)
>  &= nbsp;         (font-lock-add-keywords nil
= >             (\`
> &= nbsp;            (("^[ &n= bsp;  ]*\\([-+*]\\|[0-9]+[.)]\\) +"
>      &= nbsp;         (1
>    &n= bsp;        (\`
>     &n= bsp;        (face org-link keymap (\, org-mou= se-map) mouse-face
>        =0A  &= nbsp;    highlight)
>        =      )
>         &= nbsp;   (quote prepend))
>       &= nbsp;        )
>     &nb= sp;         )
>     = ;         )
>     &= nbsp;       t)
>      &n= bsp;     )
>         &nb= sp; (when (memq (quote activate-checkboxes) org-mouse-features)
> &nb= sp;          (font-lock-add-keywords nil=
>             (\`
&g= t;              (("^[&nbs= p;   ]*\\([-+*]\\|[0-9]+[.)]\\) +\\(\\[[=0A X]\\]\\)"
> &nb= sp;              (2<= br>>             (\`
>= ;              (face bold= keymap (\, org-mouse-map) mouse-face
>      &nbs= p;        highlight)
>     &n= bsp;        )
>     &nbs= p;       t)
>       = ;         )
>     &= nbsp;         )
>    &nb= sp;         )
>     = ;        t)
>      =       )
>         &= nbsp; (defadvice org-open-at-point
>=0A      &nbs= p;     (around org-mouse-open-at-point activate)
> &nb= sp;          (let ((context (org-context= )))
>             (cond = ((assq :headline-stars context) (org-cycle))
>     &nb= sp;        ((assq :checkbox context) (org-tog= gle-checkbox))
>           &n= bsp;  ((assq :item-bullet context)
>      &n= bsp;        (let ((org-cycle-include-plain-li= sts t)) (org-cycle)))
>          &= nbsp;   (t ad-do-it))
>       &nbs= p;     )
>          = ;  )
>           )
> &n= bsp;      =0A  #[nil "\300\301\302\303\304$\2= 07"
>            [org-add-hoo= k change-major-mode-hook org-show-block-all append
>    &nb= sp;        local]
>     =        5]
>       &= nbsp;  #[nil "\300\301\302\303\304$\207"
>     &n= bsp;      [org-add-hook change-major-mode-hook org-babe= l-show-result-all
>           = ;  append local]
>          &= nbsp; 5]
>          org-babel-resu= lt-hide-spec org-babel-hide-all-hashes)
>  org-ctrl-c-ctrl-c-hoo= k '(org-babel-hash-at-point org-babel-execute-safely-maybe)
>  o= rg-confirm-elisp-link-function 'yes-or-no-p
>  org-agenda-mode-h= ook '((lambda nil
>=0A          &n= bsp;   (setq org-mouse-context-menu-function
>   =            (quote org-mouse-agenda= -context-menu))
>           &= nbsp;  (org-defkey org-agenda-mode-map [mouse-3]
>    =            (quote org-mouse-show-co= ntext-menu))
>           &nbs= p;  (org-defkey org-agenda-mode-map [down-mouse-3]
>   = ;            (quote org-mouse-move-= tree-start))
>           &nbs= p;  (org-defkey org-agenda-mode-map [C-mouse-4]
>    &= nbsp;          (quote org-agenda-earlier= ))
>              (= org-defkey=0A org-agenda-mode-map [C-mouse-5]
>     &n= bsp;         (quote org-agenda-later))
>= ;              (org-defke= y org-agenda-mode-map [drag-mouse-3]
>       = ;        (quote
>      &= nbsp;         (lambda (event) (interactive "e= ")
>              &= nbsp;  (case (org-mouse-get-gesture event)
>     =              (:left (org-= agenda-earlier 1))
>          &nbs= p;       (:right (org-agenda-later 1)))
> &n= bsp;               )=
>              &nb= sp;=0A )
>             &= nbsp; )
>             &n= bsp;)
>             )>  org-export-interblocks '((lob org-babel-exp-lob-one-liners)
= >               (src o= rg-babel-exp-inline-src-blocks))
>  org-occur-hook '(org-first-h= eadline-recenter)
>  org-export-preprocess-before-selecting-back= end-code-hook '(org-beamer-select-beamer-code)
>  org-confirm-ba= bel-evaluate nil
>  org-infojs-options '((path . "= http://bancs.bdx.com/chen/lib/org-info.js")
>     =           (view . "overview") (toc = . "nil") (ftoc . "0")
>        =0A &nbs= p;     (tdepth . "max") (sdepth . "max") (mouse . "unde= rline")
>            &nb= sp;  (buttons . "0") (ltoc . "1") (up . :link-up)
>   =            (home . :link-home= ))
>  org-src-tab-acts-natively t
>  org-export-latex= -final-hook '(org-beamer-amend-header org-beamer-fix-toc
>  &nbs= p;              &nbs= p;  org-beamer-auto-fragile-frames
>      &n= bsp;             org-beam= er-place-default-actions-for-lists)
>  org-metadown-hook '(org-b= abel-pop-to-session-maybe)
>  org-export-blocks '((src org-babel= -exp-src-block nil)
>          &nb= sp;   (comment org-export-blocks-format-comment=0A t)
> &nb= sp;            (ditaa org-expo= rt-blocks-format-ditaa nil)
>         &= nbsp;    (dot org-export-blocks-format-dot nil))
> &nb= sp;)
>
>

--
Eric Schulte
http://cs.unm.edu/~es= chulte/
--0-865750877-1311005985=:52922-- --0-874255018-1311005985=:52922 Content-Type: application/vnd.lotus-organizer; name="test2.org" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="test2.org" IytUSVRMRTp0ZXN0DQojK0JBQkVMOiA6c2Vzc2lvbiAqUiogOnJlc3VsdHMg b3V0cHV0IGdyYXBoaWNzIDpleHBvcnRzIGJvdGggDQoNCiMrc291cmNlOiBw bG90Mw0KIytiZWdpbl9zcmMgUiA6ZmlsZSBhMy5wZGYgOndpZHRoIDUgOmhl aWdodCA1DQogIGEgPC0gYiA8LSAxOjEwDQogIHBsb3QoYSwgYikNCiMrZW5k X3NyYw0KDQojK0FUVFJfTGFUZVg6IHdpZHRoPTUNCiMrcmVzdWx0czogcGxv dDMNCltbZmlsZTphMy5wZGZdXQ0KDQo= --0-874255018-1311005985=:52922--