From mboxrd@z Thu Jan 1 00:00:00 1970 From: Steven Delean Subject: Re: Color of exported R code results using LaTeX listings Date: Sat, 18 Sep 2010 12:09:41 +0930 Message-ID: <1284777581.3782.17.camel@sduofa-desktop> References: <1284708719.2732.28.camel@sduofa-desktop> <87k4mk5uji.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit Return-path: Received: from [140.186.70.92] (port=46245 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OwnL9-0005XK-L2 for emacs-orgmode@gnu.org; Fri, 17 Sep 2010 22:39:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OwnL8-0005iQ-2O for emacs-orgmode@gnu.org; Fri, 17 Sep 2010 22:39:47 -0400 Received: from pulteney-pix.border.net.adelaide.edu.au ([192.43.227.18]:46238 helo=mailguard-send.adelaide.edu.au) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OwnL7-0005hx-O3 for emacs-orgmode@gnu.org; Fri, 17 Sep 2010 22:39:46 -0400 In-Reply-To: <87k4mk5uji.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Cc: wxhgmqzgwmuf@spammotel.com, Rainer M Krug Hi Eric, Rainer and Sébastien, Thanks again for all your assistance. I was not able to achieve the results I was after exactly using any proposed solutions, but have found a way forward and outline my solution below in case it benefits others. The following allows fontification and syntax highlighting for source code and a single color for exported output, and works both for latex documents and beamer slides. NB: A single color for source code in exported documents can be acheived by adding e.g. \color{blue} to basicstyle. 1. The following must appear in your .emacs (require 'org-latex) (setq org-export-latex-listings t) (add-to-list 'org-export-latex-packages-alist '("" "listings")) (add-to-list 'org-export-latex-packages-alist '("" "color")) 2. Add the following to your .org document header to allow colors and 'nice' font #+LATEX_HEADER: \lstset{ #+LATEX_HEADER: keywordstyle=\color{blue}, #+LATEX_HEADER: commentstyle=\color{red}, #+LATEX_HEADER: stringstyle=\color{green}, #+LATEX_HEADER: basicstyle=\ttfamily\small, #+LATEX_HEADER: columns=fullflexible, #+LATEX_HEADER: basewidth={0.5em,0.4em} #+LATEX_HEADER: } 3. Also add the following to your .org document header to allow the output results of evaluating R (or other language) code to be in color #+LATEX_HEADER: \RequirePackage{fancyvrb} #+LATEX_HEADER: \DefineVerbatimEnvironment{verbatim}{Verbatim}{fontsize= \small,formatcom = {\color[rgb]{0.5,0,0}}} Hope it helps, Regards, Steve On Fri, 2010-09-17 at 08:24 -0400, Eric Schulte wrote: > Hi Steven, > > If your R blocks are outputting actual R code, then you can use the > "code" argument to the :results header argument to have the output > exported as R code under listings instead of within verbatim blocks. > --8<---------------cut here---------------start------------->8--- > #+begin_src R :results code 8 #+end_src > > #+results: > #+BEGIN_SRC R > 8 > #+END_SRC > --8<---------------cut here---------------end--------------->8--- > > Alternately if your output is some other language you could use the > ":results latex" header argument and explicitly provide the listings > wrapper yourself. > > Hope this Helps -- Eric > > Steven Delean writes: > > > Hi everyone, > > > > I am using org-mode to make a beamer presentation that includes blocks > > of R code and wish to export the source code and results to pdf in > > color (using the listings package). > > > > The source code block syntax is highlighted successfully, but the > > output results of the executed R code are not colored at all. > > > > The results are presented in \begin{verbatim}...\end{verbatim}, > > whereas the source code is presented within > > \begin{lstlisting}...\end{lstlisting}. I can affect changes to the > > fontsize and color of the source code using \lstset in the .org > > document header, but not the results output from evaluating the code. > > > > Is there some way I can export these results in color? > > > > Thanks for any suggestions, > > > > Regards, > > Steve > > > > PS I have the follwing in my .emacs > > (require 'org-latex) > > (setq org-export-latex-listings t) > > (add-to-list 'org-export-latex-packages-alist '("" "listings")) > > (add-to-list 'org-export-latex-packages-alist '("" "color")) > > > > > > > > > > > > _______________________________________________ > > Emacs-orgmode mailing list > > Please use `Reply All' to send replies to the list. > > Emacs-orgmode@gnu.org > > http://lists.gnu.org/mailman/listinfo/emacs-orgmode