Re: [R] Best use of LaTeX listings package for pretty printing R code

2006-09-28 Thread Frank E Harrell Jr
Michael Kubovy wrote:
 I tried to use Frank's formatting improvements to compile 
 Sweave-produced .tex, but it doesn't seem to make a difference. Advice?

I've been hoping that Fritz would put in hooks for pretty printing of 
code but I don't think it's there yet.  If you tried any special hooks 
and that didn't work please let us know.

Frank

 
 On Sep 25, 2006, at 9:31 AM, Frank E Harrell Jr wrote:
 
 This is what I have been using.  Does anyone have a better way?  In
 particular I would like to see letters in comment strings not stretched
 so much.  Thanks -Frank

 \documentclass{article}
 \usepackage{listings,relsize}
 \lstloadlanguages{R}
 \newcommand{\lil}[1]{\lstinline|#1|}

 \begin{document}
 \lstset{language=R,basicstyle=\smaller,commentstyle=\rmfamily\smaller,
   showstringspaces=false,%
   xleftmargin=4ex,literate={-}{{$\leftarrow$}}1 {~}{{$\sim$}}1}
 \lstset{escapeinside={(*}{*)}}   % for (*\ref{ }*) inside lstlistings (S
 code)
 \begin{lstlisting}
 a - b   # this is a test line
 if(i==3) {  # another line, for y^2
   y - 3^3
   z - 'this string'
   qqcat - y ~ pol(x,2)
 } else y - 4
 \end{lstlisting}
 That was \lstinline|x - 22| \lil{q - 'cat'}.
 \end{document}
 
 _
 Professor Michael Kubovy
 University of Virginia
 Department of Psychology
 USPS: P.O.Box 400400Charlottesville, VA 22904-4400
 Parcels:Room 102Gilmer Hall
 McCormick RoadCharlottesville, VA 22903
 Office:B011+1-434-982-4729
 Lab:B019+1-434-982-4751
 Fax:+1-434-982-4766
 WWW:http://www.people.virginia.edu/~mk9y/


__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Best use of LaTeX listings package for pretty printing R code

2006-09-27 Thread Michael Kubovy
I tried to use Frank's formatting improvements to compile Sweave- 
produced .tex, but it doesn't seem to make a difference. Advice?

On Sep 25, 2006, at 9:31 AM, Frank E Harrell Jr wrote:

 This is what I have been using.  Does anyone have a better way?  In
 particular I would like to see letters in comment strings not  
 stretched
 so much.  Thanks -Frank

 \documentclass{article}
 \usepackage{listings,relsize}
 \lstloadlanguages{R}
 \newcommand{\lil}[1]{\lstinline|#1|}

 \begin{document}
 \lstset{language=R,basicstyle=\smaller,commentstyle=\rmfamily\smaller,
   showstringspaces=false,%
   xleftmargin=4ex,literate={-}{{$\leftarrow$}}1 {~}{{$\sim$}}1}
 \lstset{escapeinside={(*}{*)}}   % for (*\ref{ }*) inside  
 lstlistings (S
 code)
 \begin{lstlisting}
 a - b   # this is a test line
 if(i==3) {  # another line, for y^2
   y - 3^3
   z - 'this string'
   qqcat - y ~ pol(x,2)
 } else y - 4
 \end{lstlisting}
 That was \lstinline|x - 22| \lil{q - 'cat'}.
 \end{document}

_
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS: P.O.Box 400400Charlottesville, VA 22904-4400
Parcels:Room 102Gilmer Hall
 McCormick RoadCharlottesville, VA 22903
Office:B011+1-434-982-4729
Lab:B019+1-434-982-4751
Fax:+1-434-982-4766
WWW:http://www.people.virginia.edu/~mk9y/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Best use of LaTeX listings package for pretty printing R code

2006-09-25 Thread Frank E Harrell Jr
This is what I have been using.  Does anyone have a better way?  In 
particular I would like to see letters in comment strings not stretched 
so much.  Thanks -Frank

\documentclass{article}
\usepackage{listings,relsize}
\lstloadlanguages{R}
\newcommand{\lil}[1]{\lstinline|#1|}

\begin{document}
\lstset{language=R,basicstyle=\smaller,commentstyle=\rmfamily\smaller,
  showstringspaces=false,%
  xleftmargin=4ex,literate={-}{{$\leftarrow$}}1 {~}{{$\sim$}}1}
\lstset{escapeinside={(*}{*)}}   % for (*\ref{ }*) inside lstlistings (S 
code)
\begin{lstlisting}
a - b   # this is a test line
if(i==3) {  # another line, for y^2
  y - 3^3
  z - 'this string'
  qqcat - y ~ pol(x,2)
} else y - 4
\end{lstlisting}
That was \lstinline|x - 22| \lil{q - 'cat'}.
\end{document}


-- 
Frank E Harrell Jr   Professor and Chair   School of Medicine
  Department of Biostatistics   Vanderbilt University

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Best use of LaTeX listings package for pretty printing R code

2006-09-25 Thread Vincent Goulet
Le Lundi 25 Septembre 2006 09:31, Frank E Harrell Jr a écrit :
 This is what I have been using.  Does anyone have a better way?  In
 particular I would like to see letters in comment strings not stretched
 so much.  Thanks -Frank

 \documentclass{article}
 \usepackage{listings,relsize}
 \lstloadlanguages{R}
 \newcommand{\lil}[1]{\lstinline|#1|}

 \begin{document}
 \lstset{language=R,basicstyle=\smaller,commentstyle=\rmfamily\smaller,
   showstringspaces=false,%
   xleftmargin=4ex,literate={-}{{$\leftarrow$}}1 {~}{{$\sim$}}1}
 \lstset{escapeinside={(*}{*)}}   % for (*\ref{ }*) inside lstlistings (S
 code)
 \begin{lstlisting}
 a - b   # this is a test line
 if(i==3) {  # another line, for y^2
   y - 3^3
   z - 'this string'
   qqcat - y ~ pol(x,2)
 } else y - 4
 \end{lstlisting}
 That was \lstinline|x - 22| \lil{q - 'cat'}.
 \end{document}

listings is a great package to highlight R keywords and comments and --- that 
was my main use of the package --- index those keywords. I found that I had 
to slightly redefine the list of keywords included in listings. I still did 
not take the time to submit a patch to the author, though...

In any case, here's what I use, if it can be of any help to anyone:

\lstloadlanguages{R}
\lstdefinelanguage{Renhanced}[]{R}{%
  morekeywords={acf,ar,arima,arima.sim,colMeans,colSums,is.na,is.null,%
mapply,ms,na.rm,nlmin,replicate,row.names,rowMeans,rowSums,seasonal,%
sys.time,system.time,ts.plot,which.max,which.min},
  deletekeywords={c},
  alsoletter={.\%},%
  alsoother={:_\$}}
\lstset{language=Renhanced,extendedchars=true,
  basicstyle=\small\ttfamily,
  commentstyle=\textsl,
  keywordstyle=\mdseries,
  showstringspaces=false,
  index=[1][keywords], 
  indexstyle=\indexfonction}

with

  [EMAIL PROTECTED]

-- 
  Vincent Goulet, Associate Professor
  École d'actuariat
  Université Laval, Québec 
  [EMAIL PROTECTED]   http://vgoulet.act.ulaval.ca

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Best use of LaTeX listings package for pretty printing R code

2006-09-25 Thread Anupam Tyagi
Frank E Harrell Jr f.harrell at vanderbilt.edu writes:

 
 This is what I have been using.  Does anyone have a better way?  In 
 particular I would like to see letters in comment strings not stretched 
 so much.  Thanks -Frank

It may be possible to pass on all comments to a verbatim like environment inside
the listings environment, by defining and redefining the preamble to listings. I
hope it does not interfere with something else in LaTeX. Anupam.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.