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 10:08:41 -0700 (PDT) Message-ID: <1311008921.2540.YahooMailClassic@web81707.mail.mud.yahoo.com> References: <87vcuz8s1f.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0-452266302-1311008921=:2540" Return-path: Received: from eggs.gnu.org ([140.186.70.92]:40592) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QirJI-0001Xx-HV for emacs-orgmode@gnu.org; Mon, 18 Jul 2011 13:08:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QirJE-0005Zg-HS for emacs-orgmode@gnu.org; Mon, 18 Jul 2011 13:08:48 -0400 Received: from nm28.access.bullet.mail.mud.yahoo.com ([66.94.237.93]:45743) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1QirJD-0005ZV-MK for emacs-orgmode@gnu.org; Mon, 18 Jul 2011 13:08:44 -0400 In-Reply-To: <87vcuz8s1f.fsf@gmail.com> 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-452266302-1311008921=:2540 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Hi Eric: Thanks a lot for your quick response!=A0 The problem is solved by "adding a= headline".=A0 I can now successfully generated the PDF file from LaTeX exp= ort.=20 I agree with your point about complexity vs. convenience. Thanks again, and have a good week!=20 Sincerely, Feiming Chen --- On Mon, 7/18/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: "Eric Schulte" , emacs-orgmode@gnu.org Date: Monday, July 18, 2011, 11:36 AM Feiming Chen writes: > 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) during LaTeX export. > I don't think this will happen at least in the near term, as searching out and creating/changing org export directives would be a major change to the current behavior which inserts code results, and would cross some semantic lines separating parts of Org-mode. In this case I don't think the relatively limited convenience justifies the added complexity. > > Somehow I failed to compile the file on my system.=A0 It seems the line: > > #+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 doe= s not exist <0> > > =A0=3D=3D> Fatal error occurred, no output PDF file produced! > > > and=A0 I could not open the PDF file of the R plot any more (the error > message is "Cannot display this page! Maybe because of a conversion > failure").=A0=A0 > > Attached is the simplified org file that failed on "LaTeX transport" on m= y computer.=A0=20 > I believe in this case the problem is caused by the lack of any headline levels.=A0 The LaTeX exporter can be weird about headline levels, try adding a line like * top to the org file before the code block.=A0 That fixes the problem on my system. Also, there is no way that an #+attr_latex line could affect the execution of a code block, precisely because of the simplifying separation of distinct components mentioned earlier. Best -- Eric > > Thanks!=A0 > > Sincerely,=20 > > Feiming 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 Se= e > my attached version of your test file which uses #+ATTR_LaTeX lines to > specify the width during LaTeX >=A0 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 h= aving 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 t= wo 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} ... >> >=A0 \includegraphics[width=3D10em]{a3.pdf} ... >> \includegraphics[width=3D10em]{a4.pdf} ... >> >> =A0=A0=A0 2. While exporting to PDF file, the R code is mysteriously los= t in >> =A0=A0=A0 the R execution for the PDF output of the plots and the compil= ation 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: >> >=A0 =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\\'" . "= evince %s")) >> =A0org-export-latex-after-initial-vars-hook '(org-beamer-after-initial-v= ars) >> =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-def= ault >> =A0org-tab-first-hook >=A0 '(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{a= msmath}\n\\usepackage[mathscr]{eucal}\n% >> Feiming's Customization >> BEGIN\n\\usepackage[colorlinks=3Dtrue]{hyperref}\n\\input{/home/chen/lib= /math.tex}\n% >> Feiming's >=A0 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{\\te= xtwidth}{-3cm}\n\\setlength{\\oddsidemargin}{1.5cm}\n\\addtolength{\\oddsid= emargin}{-2.54cm}\n\\setlength{\\evensidemargin}{\\oddsidemargin}\n\\setlen= gth{\\textheight}{\\paperheight}\n\\addtolength{\\textheight}{-\\headheight= }\n\\addtolength{\\textheight}{-\\headsep}\n\\addtolength{\\textheight}{-\\= footskip}\n\\addtolength{\\textheight}{-3cm}\n\\setlength{\\topmargin}{1.5c= m}\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-draw= ers >> >=A0 =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-featu= res) >> =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 >=A0 =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-featu= res) >> =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) >=A0 org-mouse-features) >> =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 >=A0 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-fea= tures) >> =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 >=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-bullets) org-mouse-f= eatures) >> =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 >=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 (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-mous= e-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]+[.)]\= \) +\\(\\[[ >=A0 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) mo= use-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 >> >=A0 =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-c= heckbox)) >> =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 >=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-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-babe= l-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-has= hes) >> =A0org-ctrl-c-ctrl-c-hook '(org-babel-hash-at-point org-babel-execute-sa= fely-maybe) >> =A0org-confirm-elisp-link-function 'yes-or-no-p >> =A0org-agenda-mode-hook '((lambda nil >> >=A0 =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-m= ouse-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-mous= e-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 >=A0 org-agenda-mode-map [C-mouse-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-m= ouse-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 eve= nt) >> =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 >=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 ) >> =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.= js") >> =A0=A0 =A0=A0=A0=A0 =A0=A0=A0=A0=A0 (view . "overview") (toc . "nil") (f= toc . "0") >> =A0=A0 =A0=A0=A0=A0 >=A0 =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 . := link-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-= toc >> =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-defaul= t-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-comme= nt >=A0 t) >> =A0=A0 =A0=A0=A0=A0 =A0=A0=A0=A0 (ditaa org-export-blocks-format-ditaa n= il) >> =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-452266302-1311008921=:2540 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable
Hi Eric:

Thanks a lot for your quick r= esponse!  The problem is solved by "adding a headline".  I can no= w successfully generated the PDF file from LaTeX export.

I agree wi= th your point about complexity vs. convenience.

Thanks again, and ha= ve a good week!

Sincerely,
Feiming Chen

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

From: Eric Schulte <schulte.eric@gmail.com>=
Subject: Re: [O] Bug: Org-Babel Mode R Plot Output to LaTeX File [Babel= ] [7.5]
To: "Feiming Chen" <feimingchen@yahoo.com>
Cc: "Eric Sc= hulte" <schulte.eric@gmail.com>, emacs-orgmode@gnu.org
Date: Monda= y, July 18, 2011, 11:36 AM

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

> Hi Eric: <= br>>
> Thanks a lot!   It would be nice if Org-Babel mod= el could
> automatically add the "#+ATTR_LaTeX" lines (from the hint = in the R
> code header line) during LaTeX export.
>

I do= n't think this will happen at least in the near term, as searching
out a= nd creating/changing org export directives would be a major change
to th= e current behavior which inserts code results, and would cross some
sema= ntic lines separating parts of Org-mode.

In this case I don't think = the relatively limited convenience justifies
the added complexity.
>
> Somehow I failed to compile the file on my system.  It = seems the line:
>
> #+ATTR_LaTeX: width=3D5px
>
> h= as corrupted the PDF file generated in R.   Because after "C-c C-= e d",  I get the following error:
>
> !pdfTeX error: pdflat= ex (file ./a3.pdf): PDF inclusion: required page does not exist <0>>
>  =3D=3D> Fatal error occurred, no output PDF file pr= oduced!
>
>
> and  I could not open the PDF file of = the R plot any more (the error
> message is "Cannot display this page= ! Maybe because of a conversion
> failure").  
>
&= gt; Attached is the simplified org file that failed on "LaTeX transport" on= my computer. 
>

I believe in this case the problem is c= aused by the lack of any headline
levels.  The LaTeX exporter can b= e weird about headline levels, try
adding a line like

* top
to the org file before the code block.  That fixes the problem on my=
system.

Also, there is no way that an #+attr_latex line could af= fect the
execution of a code block, precisely because of the simplifying
separation of distinct components mentioned earlier.
Best -- Eric

>
> Thanks! 
>
> Sincerely, =
>
> Feiming Chen
>
> --- On Fri, 7/15/11, Eric Sch= ulte <schulte.eric@gmail.com> wrote:
>> From: Eric Schulte <schulte.eric@gmail.com= >
> Subject: Re: [O] Bug: Org-Babel Mode R Plot Output to LaTeX Fi= le [Babel] [7.5]
> To: "Feiming Chen" <feimingche= n@yahoo.com>
> Cc: emacs-orgmode@gnu.org<= br>> 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.,
>
>   png(filename=3D"a= 1.png",width=3D500,height=3D500)
>
> however they do not affect= the generated latex code.  Luckily Org-mode
> does support pass= ing information like image width to latex figures.  See
> my att= ached version of your test file which uses #+ATTR_LaTeX lines to
> sp= ecify the width during LaTeX
>  export.
>
> Best -- = Eric
>
>
> -----Inline Attachment Follows-----
>>
> Feiming Chen <feimingchen@yahoo.com&g= t; writes:
>
>> Hi, I like org-mode and org-babel mode very = much, but recently I am  having problems outputting R graphics to LaTe= X report with
>> Org-Babel mode.  Attached is my test file, w= here I am generating 4
>> simple plots of different sizes and format (= .png or .pdf).  The HTML
>> export is satisfactory, however, = the LaTeX export (C-c C-e l) presents two problems:
>>
>>= ;     1.  All 4 plots have the same size (10em) which i= s different from the
>>     header specification an= d is too small.
>>
>> \includegraphics[width=3D10em]{a1.p= ng} ...
>> \includegraphics[width=3D10em]{a2.png} ...
>><= br>>  \includegraphics[width=3D10em]{a3.pdf} ...
>> \inclu= degraphics[width=3D10em]{a4.pdf} ...
>>
>>   &n= bsp; 2. While exporting to PDF file, the R code is mysteriously lost in
= >>     the R execution for the PDF output of the plots= and the compilation failed correspondingly:
>>
>>> p= df(file=3D"a3.pdf",width=3D5,height=3D5)
>>>
>>> dev.off()
>>> pdf(file=3D"a4.pdf",width=3D10,height=3D10)
&= gt;>>
>>> dev.off()
>>
>>
>> H= opefully you can replicate my errors and help me on this.  Thanks a>> lot!
>>
>> Best regards,
>> Feiming C= hen
>>
>> _______________________________________________= _____________
>>
>>
>> Emacs  : GNU Emacs 2= 3.2.1 (i386-redhat-linux-gnu, GTK+ Version 2.21.4)
>>  of 201= 0-07-08 on x86-05.phx2.fedoraproject.org
>> Package: Org-mode vers= ion 7.5
>>
>> current state:
>>
>  = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>> (setq
>> &n= bsp;org-file-apps '((auto-mode . emacs) ("\\.mm\\'" . default)
>> =          ("\\.x?html?\\'" . "firefox %s"= ) ("\\.pdf\\'" . "evince %s"))
>>  org-export-latex-after-ini= tial-vars-hook '(org-beamer-after-initial-vars)
>>  org-hide-block-startup = t
>>  org-speed-command-hook '(org-speed-command-default-hook=
>>              = ; org-babel-speed-command-hook)
>>  org-src-fontify-natively = t
>>  org-babel-load-languages '((emacs-lisp . t) (R . t))>>  org-metaup-hook '(org-babel-load-in-session-maybe)
>&= gt;  org-after-todo-state-change-hook '(org-clock-out-if-current)
&= gt;>  org-export-blocks-postblock-hook '(org-exp-res/src-name-clean= up)
>>  org-export-latex-format-toc-function 'org-export-late= x-format-toc-default
>>  org-tab-first-hook
>  '(o= rg-hide-block-toggle-maybe
>>        = ;       org-src-native-tab-command-maybe
>&g= t;               org-babel-hide-result-toggle-maybe)
>= >  outline-regexp "\\*+ "
>>  org-src-mode-hook '(org= -src-babel-configure-edit-buffer
>>       = ;       org-src-mode-configure-edit-buffer)
>= ;>  org-confirm-shell-link-function 'yes-or-no-p
>>  = org-reveal-start-hook '(org-decrypt-entry)
>>  org-export-fir= st-hook '(org-beamer-initialize-open-trackers)
>>  org-format= -latex-header
>> "\\documentclass{article}\n\\usepackage[usenames]= {color}\n\\usepackage{amsmath}\n\\usepackage[mathscr]{eucal}\n%
>>= Feiming's Customization
>> BEGIN\n\\usepackage[colorlinks=3Dtrue]= {hyperref}\n\\input{/home/chen/lib/math.tex}\n%
>> Feiming's
&g= t;  Customization END\n\\pagestyle{empty}     = ;        % do not
>> remove\n[PACKAGES]\n[DEFAULT-PACKAGES]\n% The settings below are
>&g= t; copied from
>> fullpage.sty\n\\setlength{\\textwidth}{\\paperwi= dth}\n\\addtolength{\\textwidth}{-3cm}\n\\setlength{\\oddsidemargin}{1.5cm}= \n\\addtolength{\\oddsidemargin}{-2.54cm}\n\\setlength{\\evensidemargin}{\\= oddsidemargin}\n\\setlength{\\textheight}{\\paperheight}\n\\addtolength{\\t= extheight}{-\\headheight}\n\\addtolength{\\textheight}{-\\headsep}\n\\addto= length{\\textheight}{-\\footskip}\n\\addtolength{\\textheight}{-3cm}\n\\set= length{\\topmargin}{1.5cm}\n\\addtolength{\\topmargin}{-2.54cm}"
>>= ;  org-startup-indented t
>>  org-agenda-before-write-ho= ok '(org-agenda-add-entry-text)
>>  org-babel-pre-tangle-hook= '(save-buffer)
>>  org-cycle-hook '(org-cycle-hide-archived-= subtrees org-cycle-hide-drawers
>>
>     &nbs= p;      org-cycle-show-empty-lines
>>           org-optimize-window-after-vis= ibility-change)
>>  org-export-preprocess-before-normalizing-= links-hook '(org-remove-file-link-modifiers)
>>  org-use-spee= d-commands t
>>  org-mode-hook '(turn-on-org-cdlatex
>&= gt;          (lambda nil
>> &nb= sp;         (setq org-mouse-context-menu-func= tion
>>            (quote = org-mouse-context-menu))
>>         =   (when (memq (quote context-menu) org-mouse-features)
>> &nb= sp;          (org-defkey org-mouse-map [= mouse-3] nil)
>>           = ; (org-defkey org-mode-map [mouse-3]
>>      &= nbsp; 
>      (quote org-mouse-show-context-menu))
>>       &= nbsp;    )
>>         &nbs= p; (org-defkey org-mode-map [down-mouse-1]
>>     &= nbsp;      (quote org-mouse-down-mouse))
>> &n= bsp;         (when (memq (quote context-menu)= org-mouse-features)
>>         &nbs= p;  (org-defkey org-mouse-map [C-drag-mouse-1]
>>   = ;          (quote org-mouse-move-tree))<= br>>>            (org-defkey = org-mouse-map [C-down-mouse-1]
>>       &= nbsp;     (quote org-mouse-move-tree-start))
>> &nb= sp;          )
>>    =        (when (memq (quote yank-link)
>  org-mouse-features)
>>    &nbs= p;       (org-defkey org-mode-map [S-mouse-2]
&= gt;>             (quote org= -mouse-yank-link))
>>          =   (org-defkey org-mode-map [drag-mouse-3]
>>    &nb= sp;        (quote org-mouse-yank-link))
&g= t;>            )
>> &nb= sp;         (when (memq (quote move-tree) org= -mouse-features)
>>          &n= bsp; (org-defkey org-mouse-map [drag-mouse-3]
>>    &nbs= p;        (quote org-mouse-move-tree))
>= ;>            (org-defkey org-mo= use-map [down-mouse-3]
>>             (quote
>  org-mouse= -move-tree-start))
>>          =   )
>>           (when (me= mq (quote activate-stars) org-mouse-features)
>>    &nbs= p;       (font-lock-add-keywords nil
>> &= nbsp;           (\`
>> &nb= sp;            (((\, outline-r= egexp) 0
>>           &nbs= p;    (\`
>>         =     (face org-link mouse-face highlight keymap
>> &= nbsp;            (\, org-mouse= -map))
>>            = )
>>                (quote prepend))
>>  &n= bsp;     
>        = )
>>             = ; )
>>             t)=
>>            )
>&g= t;           (when (memq (quote activate= -bullets) org-mouse-features)
>>       &n= bsp;    (font-lock-add-keywords nil
>>    &nbs= p;        (\`
>>     =          (("^[    ]*\\([-= +*]\\|[0-9]+[.)]\\) +"
>>         &n= bsp;      (1
>>      =        (\`
>>              (face org-link keymap (\= , org-mouse-map) mouse-face
>>       &nbs= p;
>        highlight)
>>  &nb= sp;           )
>>  &= nbsp;          (quote prepend))
>&= gt;              &nb= sp; )
>>            &= nbsp;  )
>>           = ;   )
>>          &nb= sp;  t)
>>           = )
>>           (when (memq (qu= ote activate-checkboxes) org-mouse-features)
>>     = ;       (font-lock-add-keywords nil
>>             (= \`
>>            &nbs= p; (("^[    ]*\\([-+*]\\|[0-9]+[.)]\\) +\\(\\[[
> = ; X]\\]\\)"
>>           &= nbsp;    (2
>>        = ;     (\`
>>         =      (face bold keymap (\, org-mouse-map) mouse-face>>               h= ighlight)
>>           &nb= sp;  )
>>           &= nbsp; t)
>>           &nbs= p;    )
>>         &n= bsp;     )
>>              )
>>  &nbs= p;          t)
>>    =         )
>>     &nbs= p;     (defadvice org-open-at-point
>>
> = ;            (around org-mouse-open= -at-point activate)
>>          = ;  (let ((context (org-context)))
>>      = ;       (cond ((assq :headline-stars context) (org= -cycle))
>>           &nbs= p;  ((assq :checkbox context) (org-toggle-checkbox))
>>  = ;            ((assq :item-bull= et context)
>>           &= nbsp;   (let ((org-cycle-include-plain-lists t)) (org-cycle)))
>>          &nbs= p;   (t ad-do-it))
>>       &nb= sp;     )
>>         =    )
>>           )>>        
>   #[nil = "\300\301\302\303\304$\207"
>>       &nbs= p;    [org-add-hook change-major-mode-hook org-show-block-all app= end
>>             lo= cal]
>>            5]
&= gt;>          #[nil "\300\301\302\303= \304$\207"
>>            [= org-add-hook change-major-mode-hook org-babel-show-result-all
>> &= nbsp;           append local]
>>            5]>>          org-babel-result-hid= e-spec org-babel-hide-all-hashes)
>>  org-ctrl-c-ctrl-c-hook = '(org-babel-hash-at-point org-babel-execute-safely-maybe)
>>  = ;org-confirm-elisp-link-function 'yes-or-no-p
>>  org-agenda-= mode-hook '((lambda nil
>>
>       =         (setq org-mouse-context-menu-function=
>>              = ; (quote org-mouse-agenda-context-menu))
>>     &nb= sp;        (org-defkey org-agenda-mode-map [m= ouse-3]
>>            = ;   (quote org-mouse-show-context-menu))
>>    &nbs= p;         (org-defkey org-agenda-mode-map [down-mouse-3]
>>      &n= bsp;        (quote org-mouse-move-tree-start))
= >>              (or= g-defkey org-agenda-mode-map [C-mouse-4]
>>     &nb= sp;         (quote org-agenda-earlier))
&g= t;>              (org-= defkey
>  org-agenda-mode-map [C-mouse-5]
>>  &nbs= p;            (quote org-agenda-lat= er))
>>             &= nbsp;(org-defkey org-agenda-mode-map [drag-mouse-3]
>>   = ;            (quote
>> &nb= sp;              (lambda = (event) (interactive "e")
>>                 (case (org-= mouse-get-gesture event)
>>         =          (:left (org-agenda-earlier 1))<= br>>>              =     (:right (org-agenda-later 1)))
>>    =              )
>>= ;               
= >  )
>>           =     )
>>          &nb= sp;   )
>>          &= nbsp;  )
>>  org-export-interblocks '((lob org-babel-exp= -lob-one-liners)
>>          &n= bsp;    (src org-babel-exp-inline-src-blocks))
>>  org-occur-hook '(org-first-headline-recenter)
>>  org-= export-preprocess-before-selecting-backend-code-hook '(org-beamer-select-be= amer-code)
>>  org-confirm-babel-evaluate nil
>> &nb= sp;org-infojs-options '((path . "http://bancs.bdx.com/chen/lib/org-info.js= ")
>>            &nbs= p;  (view . "overview") (toc . "nil") (ftoc . "0")
>>  &= nbsp;     
>       = (tdepth . "max") (sdepth . "max") (mouse . "underline")
>>  =              (buttons . "= 0") (ltoc . "1") (up . :link-up)
>>       = ;        (home . :link-home))
>> &nb= sp;org-src-tab-acts-natively t
>>  org-export-latex-final-hook '(org-beamer-amend-header org-beamer-fix= -toc
>>             &= nbsp;      org-beamer-auto-fragile-frames
>&= gt;               &n= bsp;    org-beamer-place-default-actions-for-lists)
>&= gt;  org-metadown-hook '(org-babel-pop-to-session-maybe)
>> &= nbsp;org-export-blocks '((src org-babel-exp-src-block nil)
>> &nbs= p;            (comment org-exp= ort-blocks-format-comment
>  t)
>>     &= nbsp;        (ditaa org-export-blocks-format-= ditaa nil)
>>           &n= bsp;  (dot org-export-blocks-format-dot nil))
>>  )
&= gt;>
>>

--
Eric Schulte
http://cs.unm.ed= u/~eschulte/
--0-452266302-1311008921=:2540--