From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rainer M Krug Subject: [babel] suggestion: wrap creation of graphics into try() block Date: Mon, 20 Jan 2014 14:36:32 +0100 Message-ID: <52DD2660.3090403@krugs.de> Reply-To: Rainer@krugs.de Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:37869) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W5F1s-0001xg-Q0 for Emacs-orgmode@gnu.org; Mon, 20 Jan 2014 08:36:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W5F1n-0001TE-CL for Emacs-orgmode@gnu.org; Mon, 20 Jan 2014 08:36:40 -0500 Received: from mail-wg0-f54.google.com ([74.125.82.54]:36516) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W5F1n-0001T5-6A for Emacs-orgmode@gnu.org; Mon, 20 Jan 2014 08:36:35 -0500 Received: by mail-wg0-f54.google.com with SMTP id x13so6770570wgg.21 for ; Mon, 20 Jan 2014 05:36:34 -0800 (PST) Received: from Rainers-MacBook-Pro-2.local (arn78-1-88-186-171-7.fbx.proxad.net. [88.186.171.7]) by mx.google.com with ESMTPSA id co15sm1436708wjb.12.2014.01.20.05.36.33 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 20 Jan 2014 05:36:33 -0800 (PST) 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: emacs orgmode-mailinglist -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi I have two suggestions which are liked to each other. They are based on R code blocks, but the should be useful for other languages as well. I have a document in which I use :session for creating R graphs. These look like: #+begin_src R :file Correlation_1.pdf :results graphics IFN.mean <- load.IFN.mean() grid <- load.grid.CASTANEA.average() image(IFN.mean) #+end_src Everything works fine, unless there is an error in one graph. In this case, the device remains open, which leaves open devices at the end of the export of the document. If the code block which should create the graph would be wrapped into a try() block, so that it would look like the following: try( { pdf("./Correlation_1.pdf") IFN.mean <- load.IFN.mean() grid <- load.grid.CASTANEA.average() image(IFN.mean) } ) dev.off() The device would be closed even if an error occurred during the execution of the code. But still, when exporting to pdf, the call to pdflatex fails as only a empty pdf is available. So it becomes necessary to go through the pdf log to identify the graphs which failed. In this case it would be useful, to have a placeholder grah in the final pdf, so that one can see which graphs did not work. In addition, this could be used as placeholders (well - they are placeholders) for to be created graphs, while the text has already been written. So my second suggestion would be to include a placeholder image, which would be used if the generation of the actual graph fails. It would be great (but not necessary) if the actual error message would be in the image. Cheers, Rainer - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Stellenbosch University South Africa Tel : +33 - (0)9 53 10 27 44 Cell: +33 - (0)6 85 62 59 98 Fax : +33 - (0)9 58 10 27 44 Fax (D): +49 - (0)3 21 21 25 22 44 email: Rainer@krugs.de Skype: RMkrug -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.22 (Darwin) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBAgAGBQJS3SZgAAoJENvXNx4PUvmCOwQIAKEZuXPy2m8fB05i+h/5KOt6 xxXY+B8AWbBuCj7vtxeSgoXATE3mN6PYIitIqamwnlbb0aeenS8O9T4LOKo/msen 1jvOaSjwtllDTITY4XjNpD6nEp+3Ypheih1OjRWAQh/rozA55ZTmprVoo7ZnwFY/ SQYttaTeJHGws4GzjUBqLBcJwFSshNs3zcygobrFB06FACzLV1lfSLsVQMl6m+Sh g5Ycs7SG6DuKou5HE5QNxw/0RQerMqM78HOCmqhn2bmrE9emnXaz/nNWA6LX/Mnx A4T6Y0rY0t3A6TRCTRyUbSnAbx1MGPz37WxQZmqTIkv8M7xldOxFin4LTwihgBQ= =y+do -----END PGP SIGNATURE-----