* Color of exported R code results using LaTeX listings
@ 2010-09-17 7:31 Steven Delean
2010-09-17 8:00 ` Rainer M Krug
2010-09-17 12:24 ` Eric Schulte
0 siblings, 2 replies; 14+ messages in thread
From: Steven Delean @ 2010-09-17 7:31 UTC (permalink / raw)
To: emacs-orgmode
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"))
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Color of exported R code results using LaTeX listings
2010-09-17 7:31 Color of exported R code results using LaTeX listings Steven Delean
@ 2010-09-17 8:00 ` Rainer M Krug
2010-09-17 8:28 ` Steven Delean
2010-09-17 12:24 ` Eric Schulte
1 sibling, 1 reply; 14+ messages in thread
From: Rainer M Krug @ 2010-09-17 8:00 UTC (permalink / raw)
To: emacs-orgmode
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 17/09/10 09:31, Steven Delean wrote:
> 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.
Hi
This is not an answer to your question, but rather a question to you:
I added your settings to my .emacs file, and I get fontification in the
pdf output, but no color. Do I need any additional settings to get
coloring of the source code?
Cheers,
Rainer
>
> 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
- --
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
Biology, UCT), Dipl. Phys. (Germany)
Centre of Excellence for Invasion Biology
Natural Sciences Building
Office Suite 2039
Stellenbosch University
Main Campus, Merriman Avenue
Stellenbosch
South Africa
Tel: +33 - (0)9 53 10 27 44
Cell: +27 - (0)8 39 47 90 42
Fax (SA): +27 - (0)8 65 16 27 82
Fax (D) : +49 - (0)3 21 21 25 22 44
Fax (FR): +33 - (0)9 58 10 27 44
email: Rainer@krugs.de
Skype: RMkrug
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkyTIAIACgkQoYgNqgF2egrfiwCeNk5+mduTj/HamQs9lAQG5CEE
zeIAn2kc+F+yL9XGyQu771zEKyFSxxin
=/jMz
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Color of exported R code results using LaTeX listings
2010-09-17 8:00 ` Rainer M Krug
@ 2010-09-17 8:28 ` Steven Delean
2010-09-17 8:52 ` Sébastien Vauban
2010-09-17 9:05 ` Rainer M Krug
0 siblings, 2 replies; 14+ messages in thread
From: Steven Delean @ 2010-09-17 8:28 UTC (permalink / raw)
To: emacs-orgmode
Hi Rainer,
Yes, you will need to provide arguments to the \lstset listings variable
(i.e. add these arguments to a #+BEAMER_HEADER_EXTRA: line). Below are
the subset of arguments that I am using so far, though greater
customisation is available (see listings.pdf
www.ctan.org/tex-archive/macros/latex/contrib/listings/listings.pdf).
\lstset{
keywordstyle=\color{blue},
commentstyle=\color{red},
stringstyle=\color{green},
basicstyle=\ttfamily\small,
columns=fullflexible,
basewidth={0.5em,0.4em}
}
Cheers,
Steve
On Fri, 2010-09-17 at 10:00 +0200, Rainer M Krug wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 17/09/10 09:31, Steven Delean wrote:
> > 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.
>
> Hi
>
> This is not an answer to your question, but rather a question to you:
> I added your settings to my .emacs file, and I get fontification in the
> pdf output, but no color. Do I need any additional settings to get
> coloring of the source code?
>
> Cheers,
>
> Rainer
>
> >
> > 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
>
>
> - --
> Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
> Biology, UCT), Dipl. Phys. (Germany)
>
> Centre of Excellence for Invasion Biology
> Natural Sciences Building
> Office Suite 2039
> Stellenbosch University
> Main Campus, Merriman Avenue
> Stellenbosch
> South Africa
>
> Tel: +33 - (0)9 53 10 27 44
> Cell: +27 - (0)8 39 47 90 42
> Fax (SA): +27 - (0)8 65 16 27 82
> Fax (D) : +49 - (0)3 21 21 25 22 44
> Fax (FR): +33 - (0)9 58 10 27 44
> email: Rainer@krugs.de
>
> Skype: RMkrug
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAkyTIAIACgkQoYgNqgF2egrfiwCeNk5+mduTj/HamQs9lAQG5CEE
> zeIAn2kc+F+yL9XGyQu771zEKyFSxxin
> =/jMz
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> 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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Color of exported R code results using LaTeX listings
2010-09-17 8:28 ` Steven Delean
@ 2010-09-17 8:52 ` Sébastien Vauban
2010-09-17 9:13 ` Rainer M Krug
2010-09-17 9:05 ` Rainer M Krug
1 sibling, 1 reply; 14+ messages in thread
From: Sébastien Vauban @ 2010-09-17 8:52 UTC (permalink / raw)
To: emacs-orgmode-mXXj517/zsQ
Hi Steven and Rainer,
Steven Delean wrote:
>> This is not an answer to your question, but rather a question to you:
>> I added your settings to my .emacs file, and I get fontification in the
>> pdf output, but no color. Do I need any additional settings to get
>> coloring of the source code?
>
> Yes, you will need to provide arguments to the \lstset listings variable
See http://www.mail-archive.com/emacs-orgmode-mXXj517/zsQ@public.gmane.org/msg28251.html for
examples of pretty-printed code.
Best regards,
Seb
--
Sébastien Vauban
_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode-mXXj517/zsQ@public.gmane.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Color of exported R code results using LaTeX listings
2010-09-17 8:28 ` Steven Delean
2010-09-17 8:52 ` Sébastien Vauban
@ 2010-09-17 9:05 ` Rainer M Krug
2011-01-04 10:06 ` Bastien
1 sibling, 1 reply; 14+ messages in thread
From: Rainer M Krug @ 2010-09-17 9:05 UTC (permalink / raw)
To: Steven Delean; +Cc: emacs-orgmode
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 17/09/10 10:28, Steven Delean wrote:
> Hi Rainer,
>
> Yes, you will need to provide arguments to the \lstset listings variable
> (i.e. add these arguments to a #+BEAMER_HEADER_EXTRA: line). Below are
> the subset of arguments that I am using so far, though greater
> customisation is available (see listings.pdf
> www.ctan.org/tex-archive/macros/latex/contrib/listings/listings.pdf).
>
> \lstset{
> keywordstyle=\color{blue},
> commentstyle=\color{red},
> stringstyle=\color{green},
> basicstyle=\ttfamily\small,
> columns=fullflexible,
> basewidth={0.5em,0.4em}
> }
Now this explains it - thanks a million - works absolutely perfectly.
Could that info be added to worg or even the org manual? It mentions the
listings and color package are mentioned, but not that colors need to be
specified to have colors in the resulting latex / pdf file.
Thanks a lot,
Rainer
>
> Cheers,
> Steve
>
>
> On Fri, 2010-09-17 at 10:00 +0200, Rainer M Krug wrote:
> On 17/09/10 09:31, Steven Delean wrote:
>>>> 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.
>
> Hi
>
> This is not an answer to your question, but rather a question to you:
> I added your settings to my .emacs file, and I get fontification in the
> pdf output, but no color. Do I need any additional settings to get
> coloring of the source code?
>
> Cheers,
>
> Rainer
>
>>>>
>>>> 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
>
>
>>
_______________________________________________
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
> _______________________________________________
> 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
- --
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
Biology, UCT), Dipl. Phys. (Germany)
Centre of Excellence for Invasion Biology
Natural Sciences Building
Office Suite 2039
Stellenbosch University
Main Campus, Merriman Avenue
Stellenbosch
South Africa
Tel: +33 - (0)9 53 10 27 44
Cell: +27 - (0)8 39 47 90 42
Fax (SA): +27 - (0)8 65 16 27 82
Fax (D) : +49 - (0)3 21 21 25 22 44
Fax (FR): +33 - (0)9 58 10 27 44
email: Rainer@krugs.de
Skype: RMkrug
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkyTL1IACgkQoYgNqgF2egp6VwCgiF0bC1uOTVFKeCr9Q+3S9O/o
KnQAn3cBqE6E4NYMUkYJ9esqQGO0GZ1g
=5aQ7
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Re: Color of exported R code results using LaTeX listings
2010-09-17 8:52 ` Sébastien Vauban
@ 2010-09-17 9:13 ` Rainer M Krug
2010-09-17 13:14 ` Steven Delean
0 siblings, 1 reply; 14+ messages in thread
From: Rainer M Krug @ 2010-09-17 9:13 UTC (permalink / raw)
To: Sébastien Vauban; +Cc: emacs-orgmode
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 17/09/10 10:52, Sébastien Vauban wrote:
> Hi Steven and Rainer,
>
> Steven Delean wrote:
>>> This is not an answer to your question, but rather a question to you:
>>> I added your settings to my .emacs file, and I get fontification in the
>>> pdf output, but no color. Do I need any additional settings to get
>>> coloring of the source code?
>>
>> Yes, you will need to provide arguments to the \lstset listings variable
>
> See http://www.mail-archive.com/emacs-orgmode@gnu.org/msg28251.html for
> examples of pretty-printed code.
Thanks - that looks really nice. Nice example.
As I said in the other email, that should go to worg.
Instead of
#+begin_LaTeX
#+end_LaTeX
I use
#+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: }
And it also works.
Cheers,
Rainer
>
> Best regards,
> Seb
>
- --
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
Biology, UCT), Dipl. Phys. (Germany)
Centre of Excellence for Invasion Biology
Natural Sciences Building
Office Suite 2039
Stellenbosch University
Main Campus, Merriman Avenue
Stellenbosch
South Africa
Tel: +33 - (0)9 53 10 27 44
Cell: +27 - (0)8 39 47 90 42
Fax (SA): +27 - (0)8 65 16 27 82
Fax (D) : +49 - (0)3 21 21 25 22 44
Fax (FR): +33 - (0)9 58 10 27 44
email: Rainer@krugs.de
Skype: RMkrug
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEUEARECAAYFAkyTMS4ACgkQoYgNqgF2egp8egCggtSGTzSGjx3IICnt6AM0ibsV
irYAmL73loKjAanP5pEg79LbcXZbccQ=
=C9VB
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Color of exported R code results using LaTeX listings
2010-09-17 7:31 Color of exported R code results using LaTeX listings Steven Delean
2010-09-17 8:00 ` Rainer M Krug
@ 2010-09-17 12:24 ` Eric Schulte
2010-09-18 2:39 ` Steven Delean
1 sibling, 1 reply; 14+ messages in thread
From: Eric Schulte @ 2010-09-17 12:24 UTC (permalink / raw)
To: Steven Delean; +Cc: emacs-orgmode
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 <steven.delean@adelaide.edu.au> 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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Re: Color of exported R code results using LaTeX listings
2010-09-17 9:13 ` Rainer M Krug
@ 2010-09-17 13:14 ` Steven Delean
2010-09-17 13:20 ` Rainer M Krug
0 siblings, 1 reply; 14+ messages in thread
From: Steven Delean @ 2010-09-17 13:14 UTC (permalink / raw)
To: emacs-orgmode; +Cc: wxhgmqzgwmuf, Rainer M Krug
Thanks very much Rainer and Sébastien for your comments and information.
However, I am still unable to get color output for the _result_ of
evaluating R code blocks.
#+source: Rcode
#+begin_src R :results output :exports both
x <- 1:5
square <- function(x) {
x^2
}
square(x)
#+end_src
## below is the .tex code generated which results in fontified and
colored source code (code within lstlisting), but non-colored results
(within verbatim).
\lstset{language=R}
Rcode() $\equiv$
\begin{lstlisting}
x <- 1:5
square <- function(x) {
x^2
}
square(x)
\end{lstlisting}
\begin{verbatim}
[1] 1 4 9 16 25
\end{verbatim}
So the question is how to color the output of text within
\begin{verbatim} ...\end{verbatim} in an exported pdf (just a single
color is fine)?
Thanks for your time,
Steve
On Fri, 2010-09-17 at 11:13 +0200, Rainer M Krug wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 17/09/10 10:52, Sébastien Vauban wrote:
> > Hi Steven and Rainer,
> >
> > Steven Delean wrote:
> >>> This is not an answer to your question, but rather a question to you:
> >>> I added your settings to my .emacs file, and I get fontification in the
> >>> pdf output, but no color. Do I need any additional settings to get
> >>> coloring of the source code?
> >>
> >> Yes, you will need to provide arguments to the \lstset listings variable
> >
> > See http://www.mail-archive.com/emacs-orgmode@gnu.org/msg28251.html for
> > examples of pretty-printed code.
>
> Thanks - that looks really nice. Nice example.
>
> As I said in the other email, that should go to worg.
>
> Instead of
> #+begin_LaTeX
> #+end_LaTeX
>
> I use
>
> #+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: }
>
> And it also works.
>
> Cheers,
>
> Rainer
>
>
> >
> > Best regards,
> > Seb
> >
>
>
> - --
> Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
> Biology, UCT), Dipl. Phys. (Germany)
>
> Centre of Excellence for Invasion Biology
> Natural Sciences Building
> Office Suite 2039
> Stellenbosch University
> Main Campus, Merriman Avenue
> Stellenbosch
> South Africa
>
> Tel: +33 - (0)9 53 10 27 44
> Cell: +27 - (0)8 39 47 90 42
> Fax (SA): +27 - (0)8 65 16 27 82
> Fax (D) : +49 - (0)3 21 21 25 22 44
> Fax (FR): +33 - (0)9 58 10 27 44
> email: Rainer@krugs.de
>
> Skype: RMkrug
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEUEARECAAYFAkyTMS4ACgkQoYgNqgF2egp8egCggtSGTzSGjx3IICnt6AM0ibsV
> irYAmL73loKjAanP5pEg79LbcXZbccQ=
> =C9VB
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> 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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Re: Color of exported R code results using LaTeX listings
2010-09-17 13:14 ` Steven Delean
@ 2010-09-17 13:20 ` Rainer M Krug
2010-09-17 13:30 ` Sébastien Vauban
0 siblings, 1 reply; 14+ messages in thread
From: Rainer M Krug @ 2010-09-17 13:20 UTC (permalink / raw)
To: Steven Delean; +Cc: wxhgmqzgwmuf, emacs-orgmode
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 17/09/10 15:14, Steven Delean wrote:
> Thanks very much Rainer and Sébastien for your comments and information.
>
> However, I am still unable to get color output for the _result_ of
> evaluating R code blocks.
>
> #+source: Rcode
> #+begin_src R :results output :exports both
> x <- 1:5
> square <- function(x) {
> x^2
> }
> square(x)
> #+end_src
>
>
> ## below is the .tex code generated which results in fontified and
> colored source code (code within lstlisting), but non-colored results
> (within verbatim).
>
> \lstset{language=R}
>
> Rcode() $\equiv$
> \begin{lstlisting}
> x <- 1:5
> square <- function(x) {
> x^2
> }
> square(x)
> \end{lstlisting}
>
> \begin{verbatim}
> [1] 1 4 9 16 25
> \end{verbatim}
>
> So the question is how to color the output of text within
> \begin{verbatim} ...\end{verbatim} in an exported pdf (just a single
> color is fine)?
You could redefine the verbatim environment with
\renewenvironment{verbatim}[args]{begdef}{enddef}
http://www.personal.ceu.hu/tex/defs.htm
http://en.wikibooks.org/wiki/LaTeX/Customizing_LaTeX
If verbatim is only used for the results, nothing should go wrong.
Cheers,
Rainer
> Thanks for your time,
> Steve
>
>
> On Fri, 2010-09-17 at 11:13 +0200, Rainer M Krug wrote:
> On 17/09/10 10:52, Sébastien Vauban wrote:
>>>> Hi Steven and Rainer,
>>>>
>>>> Steven Delean wrote:
>>>>>> This is not an answer to your question, but rather a question to you:
>>>>>> I added your settings to my .emacs file, and I get fontification in the
>>>>>> pdf output, but no color. Do I need any additional settings to get
>>>>>> coloring of the source code?
>>>>>
>>>>> Yes, you will need to provide arguments to the \lstset listings variable
>>>>
>>>> See http://www.mail-archive.com/emacs-orgmode@gnu.org/msg28251.html for
>>>> examples of pretty-printed code.
>
> Thanks - that looks really nice. Nice example.
>
> As I said in the other email, that should go to worg.
>
> Instead of
> #+begin_LaTeX
> #+end_LaTeX
>
> I use
>
> #+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: }
>
> And it also works.
>
> Cheers,
>
> Rainer
>
>
>>>>
>>>> Best regards,
>>>> Seb
>>>>
>
>
>>
_______________________________________________
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
- --
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
Biology, UCT), Dipl. Phys. (Germany)
Centre of Excellence for Invasion Biology
Natural Sciences Building
Office Suite 2039
Stellenbosch University
Main Campus, Merriman Avenue
Stellenbosch
South Africa
Tel: +33 - (0)9 53 10 27 44
Cell: +27 - (0)8 39 47 90 42
Fax (SA): +27 - (0)8 65 16 27 82
Fax (D) : +49 - (0)3 21 21 25 22 44
Fax (FR): +33 - (0)9 58 10 27 44
email: Rainer@krugs.de
Skype: RMkrug
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkyTazsACgkQoYgNqgF2egoqcQCfb5h49qQjF1zYI6F48x8d+6NZ
MMoAnA7VoeD5W9Q7CB2ElUgs4S8kjAVF
=gBaP
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Color of exported R code results using LaTeX listings
2010-09-17 13:20 ` Rainer M Krug
@ 2010-09-17 13:30 ` Sébastien Vauban
2010-09-17 14:15 ` Rainer M Krug
0 siblings, 1 reply; 14+ messages in thread
From: Sébastien Vauban @ 2010-09-17 13:30 UTC (permalink / raw)
To: emacs-orgmode-mXXj517/zsQ
Steven,
Rainer M Krug wrote:
> On 17/09/10 15:14, Steven Delean wrote:
>> I am still unable to get color output for the _result_ of evaluating R code
>> blocks.
>
> You could redefine the verbatim environment with
> \renewenvironment{verbatim}[args]{begdef}{enddef}
>
> If verbatim is only used for the results, nothing should go wrong.
For me, this should be addressed in a more semantic view of the Babel world,
and that's (by coincidence) exactly what I asked to Eric (currently on
holidays, if I read correctly) and Dan, yesterday at 17:16.
See [[http://mid.gmane.org/87zkvhoh18.fsf%40mundaneum.com][{babel} Environment around exported results]].
I am positively sure they will address this feature in a fantastic way, as
always...
Best regards,
Seb
--
Sébastien Vauban
_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode-mXXj517/zsQ@public.gmane.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Re: Color of exported R code results using LaTeX listings
2010-09-17 13:30 ` Sébastien Vauban
@ 2010-09-17 14:15 ` Rainer M Krug
0 siblings, 0 replies; 14+ messages in thread
From: Rainer M Krug @ 2010-09-17 14:15 UTC (permalink / raw)
To: Sébastien Vauban; +Cc: emacs-orgmode
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 17/09/10 15:30, Sébastien Vauban wrote:
> Steven,
>
> Rainer M Krug wrote:
>> On 17/09/10 15:14, Steven Delean wrote:
>>> I am still unable to get color output for the _result_ of evaluating R code
>>> blocks.
>>
>> You could redefine the verbatim environment with
>> \renewenvironment{verbatim}[args]{begdef}{enddef}
>>
>> If verbatim is only used for the results, nothing should go wrong.
>
> For me, this should be addressed in a more semantic view of the Babel world,
> and that's (by coincidence) exactly what I asked to Eric (currently on
> holidays, if I read correctly) and Dan, yesterday at 17:16.
>
> See [[http://mid.gmane.org/87zkvhoh18.fsf%40mundaneum.com][{babel} Environment around exported results]].
Absolutely - but that does not help Steven at the moment. But I second
your suggestion and statement.
Cheers,
Rainer
>
> I am positively sure they will address this feature in a fantastic way, as
> always...
>
> Best regards,
> Seb
>
- --
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
Biology, UCT), Dipl. Phys. (Germany)
Centre of Excellence for Invasion Biology
Natural Sciences Building
Office Suite 2039
Stellenbosch University
Main Campus, Merriman Avenue
Stellenbosch
South Africa
Tel: +33 - (0)9 53 10 27 44
Cell: +27 - (0)8 39 47 90 42
Fax (SA): +27 - (0)8 65 16 27 82
Fax (D) : +49 - (0)3 21 21 25 22 44
Fax (FR): +33 - (0)9 58 10 27 44
email: Rainer@krugs.de
Skype: RMkrug
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkyTd+kACgkQoYgNqgF2egpd7wCeP3raKjHlGlB7z0JvEiQQqkoO
dEUAnjwBAMluSLGIjxwLIvGYpJx8liUu
=Ugou
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Color of exported R code results using LaTeX listings
2010-09-17 12:24 ` Eric Schulte
@ 2010-09-18 2:39 ` Steven Delean
2010-09-18 7:10 ` Sébastien Vauban
0 siblings, 1 reply; 14+ messages in thread
From: Steven Delean @ 2010-09-18 2:39 UTC (permalink / raw)
To: emacs-orgmode; +Cc: wxhgmqzgwmuf, 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 <steven.delean@adelaide.edu.au> 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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Color of exported R code results using LaTeX listings
2010-09-18 2:39 ` Steven Delean
@ 2010-09-18 7:10 ` Sébastien Vauban
0 siblings, 0 replies; 14+ messages in thread
From: Sébastien Vauban @ 2010-09-18 7:10 UTC (permalink / raw)
To: emacs-orgmode-mXXj517/zsQ
Hi Steven,
Steven Delean wrote:
> 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}}}
What about if your results block is an Org table, instead of verbatim?
Best regards,
Seb
--
Sébastien Vauban
_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode-mXXj517/zsQ@public.gmane.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Color of exported R code results using LaTeX listings
2010-09-17 9:05 ` Rainer M Krug
@ 2011-01-04 10:06 ` Bastien
0 siblings, 0 replies; 14+ messages in thread
From: Bastien @ 2011-01-04 10:06 UTC (permalink / raw)
To: Rainer M Krug; +Cc: Steven Delean, emacs-orgmode
Hi Rainer,
Rainer M Krug <r.m.krug@gmail.com> writes:
> Now this explains it - thanks a million - works absolutely perfectly.
>
> Could that info be added to worg or even the org manual? It mentions the
> listings and color package are mentioned, but not that colors need to be
> specified to have colors in the resulting latex / pdf file.
Is it still the case?
If so, can you provide a patch against latest Worg?
Thanks!
--
Bastien
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2011-01-04 10:06 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-17 7:31 Color of exported R code results using LaTeX listings Steven Delean
2010-09-17 8:00 ` Rainer M Krug
2010-09-17 8:28 ` Steven Delean
2010-09-17 8:52 ` Sébastien Vauban
2010-09-17 9:13 ` Rainer M Krug
2010-09-17 13:14 ` Steven Delean
2010-09-17 13:20 ` Rainer M Krug
2010-09-17 13:30 ` Sébastien Vauban
2010-09-17 14:15 ` Rainer M Krug
2010-09-17 9:05 ` Rainer M Krug
2011-01-04 10:06 ` Bastien
2010-09-17 12:24 ` Eric Schulte
2010-09-18 2:39 ` Steven Delean
2010-09-18 7:10 ` Sébastien Vauban
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).