Index: Sweave.R
===================================================================
--- Sweave.R	(revision 51988)
+++ Sweave.R	(working copy)
@@ -368,7 +368,8 @@
                     split=FALSE, strip.white="true", include=TRUE,
                     pdf.version=grDevices::pdf.options()$version,
                     pdf.encoding=grDevices::pdf.options()$encoding,
-                    concordance=FALSE, expand=TRUE)
+                    concordance=FALSE, expand=TRUE,
+                    saveVerbatim=FALSE)
     options[names(dots)] <- dots
 
     ## to be on the safe side: see if defaults pass the check
@@ -482,8 +483,12 @@
                             thisline <- thisline + 1
                             openSchunk <- TRUE
                         }
-                        cat("\\begin{Sinput}",
-                            file=chunkout, append=TRUE)
+                        if (options$saveVerbatim) 
+                            cat("\\begin{SaveVerbatim}{", options$label, ".in.", nce, "}", sep="", 
+                                file=chunkout, append=TRUE)                        
+                        else
+                            cat("\\begin{Sinput}",
+                        	file=chunkout, append=TRUE)
                         openSinput <- TRUE
                     }
 		    cat("\n", paste(getOption("prompt"), dce[1L:leading], sep="", collapse="\n"),
@@ -516,7 +521,10 @@
                 if(length(output) & (options$results != "hide")){
 
                     if(openSinput){
-                        cat("\n\\end{Sinput}\n", file=chunkout, append=TRUE)
+                   	if (options$saveVerbatim) 
+                   	    cat("\n\\end{SaveVerbatim}\n", file=chunkout, append=TRUE)
+                   	else
+                            cat("\n\\end{Sinput}\n", file=chunkout, append=TRUE)
                         linesout[thisline + 1L:2L] <- srcline
                         thisline <- thisline + 2L
                         openSinput <- FALSE
@@ -529,8 +537,12 @@
                             thisline <- thisline + 1L
                             openSchunk <- TRUE
                         }
-                        cat("\\begin{Soutput}\n",
-                            file=chunkout, append=TRUE)
+                        if(options$saveVerbatim)
+                            cat("\\begin{SaveVerbatim}{", options$label, ".out.", nce, "}\n",
+                            	sep="", file=chunkout, append=TRUE)
+                        else
+                            cat("\\begin{Soutput}\n",
+                        	file=chunkout, append=TRUE)
                         linesout[thisline + 1L] <- srcline
                         thisline <- thisline + 1L
                     }
@@ -552,7 +564,10 @@
                     remove(output)
 
                     if(options$results=="verbatim"){
-                        cat("\n\\end{Soutput}\n", file=chunkout, append=TRUE)
+                    	if (options$saveVerbatim)
+                    	    cat("\n\\end{SaveVerbatim}\n", file=chunkout, append=TRUE)
+                    	else
+                            cat("\n\\end{Soutput}\n", file=chunkout, append=TRUE)
                         linesout[thisline + 1L:2L] <- srcline
                         thisline <- thisline + 2L
                     }
@@ -560,7 +575,10 @@
             }
 
           if(openSinput){
-              cat("\n\\end{Sinput}\n", file=chunkout, append=TRUE)
+	      if (options$saveVerbatim) 
+		  cat("\n\\end{SaveVerbatim}\n", file=chunkout, append=TRUE)
+	      else
+		  cat("\n\\end{Sinput}\n", file=chunkout, append=TRUE)
               linesout[thisline + 1L:2L] <- srcline
               thisline <- thisline + 2L
           }