PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Escapeinside Listings



nameac
10-07-2013, 12:33
Hallo liebe Setzergemeinde,

wenn ich wie auf der Wiki-Seite (http://en.wikibooks.org/wiki/LaTeX/Source_Code_Listings) beschrieben escapeinside={\%*}{*)} setze dann wird der Latexcode nicht ausgeblendet, verwende ich eine einfache Zeichenfolge wie escapeinside={§}{§} dann funktioniert es. Woran liegt das?




\documentclass[a4paper,fleqn,titlepage,twoside]{scrreprt}
\usepackage{etex}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{scrhack}
\usepackage{listings}
\lstloadlanguages{R}
\lstdefinelanguage{Renhanced}%
{keywords={abbreviate,abline,abs,acos,acosh,action ,add1,add,%
aggregate,alias,Alias,alist,all,anova,any,aov,aper m,append,apply,%
approx,approxfun,apropos,Arg,args,array,arrows,as, asin,asinh,%
atan,atan2,atanh,attach,attr,attributes,autoload,a utoloader,ave,%
axis,backsolve,barplot,basename,besselI,besselJ,be sselK,besselY,%
beta,binomial,body,box,boxplot,break,browser,bug,b uiltins,bxp,by,%
c,C,call,Call,case,cat,category,cbind,ceiling,char acter,char,%
charmatch,check,chol,chol2inv,choose,chull,class,c lose,cm,codes,%
coef,coefficients,co,col,colnames,colors,colours,c ommandArgs,%
comment,complete,complex,conflicts,Conj,contents,c ontour,%
contrasts,contr,control,helmert,contrib,convolve,c ooks,coords,%
distance,coplot,cor,cos,cosh,count,fields,cov,covr atio,wt,CRAN,%
create,crossprod,cummax,cummin,cumprod,cumsum,curv e,cut,cycle,D,%
data,dataentry,date,dbeta,dbinom,dcauchy,dchisq,de ,debug,%
debugger,Defunct,default,delay,delete,deltat,demo, de,density,%
deparse,dependencies,Deprecated,deriv,description, detach,%
dev2bitmap,dev,cur,deviance,off,prev,,dexp,df,dfbe tas,dffits,%
dgamma,dgeom,dget,dhyper,diag,diff,digamma,dim,dim names,dir,%
dirname,dlnorm,dlogis,dnbinom,dnchisq,dnorm,do,dot plot,double,%
download,dpois,dput,drop,drop1,dsignrank,dt,dummy, dump,dunif,%
duplicated,dweibull,dwilcox,dyn,edit,eff,effects,e igen,else,%
emacs,end,environment,env,erase,eval,equal,evalq,e xample,exists,%
exit,exp,expand,expression,External,extract,extrac tAIC,factor,%
fail,family,fft,file,filled,find,fitted,fivenum,fi x,floor,for,%
For,formals,format,formatC,formula,Fortran,forward solve,frame,%
frequency,ftable,ftable2table,function,gamma,Gamma ,gammaCody,%
gaussian,gc,gcinfo,gctorture,get,getenv,geterrmess age,getOption,%
getwd,gl,glm,globalenv,gnome,GNOME,graphics,gray,g rep,grey,grid,%
gsub,hasTsp,hat,heat,help,hist,home,hsv,httpclient ,I,identify,if,%
ifelse,Im,image,\%in\%,index,influence,measures,in herits,install,%
installed,integer,interaction,interactive,Internal ,intersect,%
inverse,invisible,IQR,is,jitter,kappa,kronecker,la bels,lapply,%
layout,lbeta,lchoose,lcm,legend,length,levels,lgam ma,library,%
licence,license,lines,list,lm,load,local,locator,l og,log10,log1p,%
log2,logical,loglin,lower,lowess,ls,lsfit,lsf,ls,m achine,Machine,%
mad,mahalanobis,make,link,margin,match,Math,matlin es,mat,matplot,%
matpoints,matrix,max,mean,median,memory,menu,merge ,methods,min,%
missing,Mod,mode,model,mosaicplot,mtext,mvfft,na,n an,%response,
names,omit,nargs,nchar,ncol,NCOL,new,next,NextMeth od,nextn,%
nlevels,nlm,noquote,NotYetImplemented,NotYetUsed,n row,NROW,null,%
numeric,\%o\%,objects,offset,old,on,Ops,optim,opti mise,optimize,%
options,or,order,ordered,outer,package,packages,pa ge,pairlist,%
pairs,palette,panel,par,parent,parse,paste,path,pb eta,pbinom,%
pcauchy,pchisq,pentagamma,persp,pexp,pf,pgamma,pge om,phyper,pico,%
pictex,piechart,Platform,plnorm,plogis,plot,pmatch ,pmax,pmin,%
pnbinom,pnchisq,pnorm,points,poisson,poly,polygon, polyroot,pos,%
postscript,power,ppoints,ppois,predict,preplot,pre tty,Primitive,%
print,prmatrix,proc,prod,profile,proj,prompt,prop, provide,%
psignrank,ps,pt,ptukey,punif,pweibull,pwilcox,q,qb eta,qbinom,%
qcauchy,qchisq,qexp,qf,qgamma,qgeom,qhyper,qlnorm, qlogis,qnbinom,%
qnchisq,qnorm,qpois,qqline,qqnorm,qqplot,qr,Q,qty, qy,qsignrank,%
qt,qtukey,quantile,quasi,quit,qunif,quote,qweibull ,qwilcox,%
rainbow,range,rank,rbeta,rbind,rbinom,rcauchy,rchi sq,Re,read,csv,%
csv2,fwf,readline,socket,real,Recall,rect,reformul ate,regexpr,%
relevel,remove,rep,repeat,replace,replications,rep ort,require,%
resid,residuals,restart,return,rev,rexp,rf,rgamma, rgb,rgeom,R,%
rhyper,rle,rlnorm,rlogis,rm,rnbinom,RNGkind,rnorm, round,row,%
rownames,rowsum,rpois,rsignrank,rstandard,rstudent ,rt,rug,runif,%
rweibull,rwilcox,sample,sapply,save,scale,scan,sca n,screen,sd,se,%
search,searchpaths,segments,seq,sequence,setdiff,s etequal,set,%
setwd,show,sign,signif,sin,single,sinh,sink,solve, sort,source,%
spline,splinefun,split,sqrt,stars,start,stat,stem, step,stop,%
storage,strstrheight,stripplot,strsplit,structure, strwidth,sub,%
subset,substitute,substr,substring,sum,summary,sun flowerplot,svd,%
sweep,switch,symbol,symbols,symnum,sys,status,syst em,t,table,%
tabulate,tan,tanh,tapply,tempfile,terms,terrain,te tragamma,text,%
time,title,topo,trace,traceback,transform,tri,trig amma,trunc,try,%
ts,tsp,typeof,unclass,undebug,undoc,union,unique,u niroot,unix,%
unlink,unlist,unname,untrace,update,upper,url,UseM ethod,var,%
variable,vector,Version,vi,warning,warnings,weight ed,weights,%
which,while,window,write,\%x\%,x11,X11,xedit,xemac s,xinch,xor,%
xpdrows,xy,xyinch,yinch,zapsmall,zip},%
otherkeywords={!,!=,~,$,*,\%,\&,\%/\%,\%*\%,\%\%,<-,<<-,_,/},%
alsoother={._$},%
sensitive,%
morecomment=[l]\#,%
morestring=[d]",%
morestring=[d]'% 2001 Robert Denham
}%

\lstset{language=Renhanced,extendedchars=false,
basicstyle=\footnotesize\ttfamily,
commentstyle=\textsl,
showstringspaces=false,
frame=single, % adds a frame around the code
numbers=left, % where to put the line-numbers
stepnumber=2,
% escapeinside={\%*}{*)},
escapeinside={§}{§}
}


\begin{document}
\begin{lstlisting}[language=Renhanced]
x<-1 # %*\label{lst:eins}*)
x<-1 # §\label{lst:eins}§
\end{lstlisting}
\end{document}

klops
10-07-2013, 13:20
Option escapeinside erlaubt für den Anfang und das Ende jeweils nur ein Zeichen, was in der Anleitung durch die Syntax: escapeinside=&lt;character>&lt;character>, beschrieben wird. Du suchst eventuell escapebegin und escapeend.

nameac
10-07-2013, 17:21
Hi Klops,

in dem Link steht doch das Beispiel zu escapeinside so beschrieben wie ich vorgegangen bin.

klops
10-07-2013, 19:19
Und wem würdest Du mehr glauben: Irgend einem Wiki-Book oder der Paketanleitung? Ich jedenfalls, halte mich im Zweifelsfall an die Paketanleitung.

Wenn Du anderer Meinung bist, kannst Du ja auf der zugehörigen Diskussionsseite mal nachfragen, warum das bei Dir nicht funktioniert.

nameac
11-07-2013, 01:28
In dem Punkt gebe ich dir recht, aber deiner Meinung nach dürfte escapeinside={(*}{*)} nicht funktionieren, das tut es aber.

klops
11-07-2013, 06:55
Ein Zeichen für vorn, eines für hinten, funktioniert. Diese Diskussion ist im übrigen Zeitverschwendung. Ich habe Dir erklärt, warum es nicht geht. Ich habe Dir erklärt, was stattdessen funktionieren müsste. Ich habe fertig.

nameac
11-07-2013, 09:04
Hi Klops,

"(*" bzw. "*)" sind doch jeweils zwei Zeichen, oder nicht?

nameac
23-09-2013, 18:06
Ich versthe das immer noch nicht genau, warum funktioniert denn:


\documentclass[a4paper,fleqn,titlepage,twoside]{scrreprt}
\usepackage{etex}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{scrhack}
\usepackage{listings}
\lstloadlanguages{R}
\lstdefinelanguage{Renhanced}%
{keywords={abbreviate,abline,abs,acos,acosh,action ,add1,add,%
aggregate,alias,Alias,alist,all,anova,any,aov,aper m,append,apply,%
approx,approxfun,apropos,Arg,args,array,arrows,as, asin,asinh,%
atan,atan2,atanh,attach,attr,attributes,autoload,a utoloader,ave,%
axis,backsolve,barplot,basename,besselI,besselJ,be sselK,besselY,%
beta,binomial,body,box,boxplot,break,browser,bug,b uiltins,bxp,by,%
c,C,call,Call,case,cat,category,cbind,ceiling,char acter,char,%
charmatch,check,chol,chol2inv,choose,chull,class,c lose,cm,codes,%
coef,coefficients,co,col,colnames,colors,colours,c ommandArgs,%
comment,complete,complex,conflicts,Conj,contents,c ontour,%
contrasts,contr,control,helmert,contrib,convolve,c ooks,coords,%
distance,coplot,cor,cos,cosh,count,fields,cov,covr atio,wt,CRAN,%
create,crossprod,cummax,cummin,cumprod,cumsum,curv e,cut,cycle,D,%
data,dataentry,date,dbeta,dbinom,dcauchy,dchisq,de ,debug,%
debugger,Defunct,default,delay,delete,deltat,demo, de,density,%
deparse,dependencies,Deprecated,deriv,description, detach,%
dev2bitmap,dev,cur,deviance,off,prev,,dexp,df,dfbe tas,dffits,%
dgamma,dgeom,dget,dhyper,diag,diff,digamma,dim,dim names,dir,%
dirname,dlnorm,dlogis,dnbinom,dnchisq,dnorm,do,dot plot,double,%
download,dpois,dput,drop,drop1,dsignrank,dt,dummy, dump,dunif,%
duplicated,dweibull,dwilcox,dyn,edit,eff,effects,e igen,else,%
emacs,end,environment,env,erase,eval,equal,evalq,e xample,exists,%
exit,exp,expand,expression,External,extract,extrac tAIC,factor,%
fail,family,fft,file,filled,find,fitted,fivenum,fi x,floor,for,%
For,formals,format,formatC,formula,Fortran,forward solve,frame,%
frequency,ftable,ftable2table,function,gamma,Gamma ,gammaCody,%
gaussian,gc,gcinfo,gctorture,get,getenv,geterrmess age,getOption,%
getwd,gl,glm,globalenv,gnome,GNOME,graphics,gray,g rep,grey,grid,%
gsub,hasTsp,hat,heat,help,hist,home,hsv,httpclient ,I,identify,if,%
ifelse,Im,image,\%in\%,index,influence,measures,in herits,install,%
installed,integer,interaction,interactive,Internal ,intersect,%
inverse,invisible,IQR,is,jitter,kappa,kronecker,la bels,lapply,%
layout,lbeta,lchoose,lcm,legend,length,levels,lgam ma,library,%
licence,license,lines,list,lm,load,local,locator,l og,log10,log1p,%
log2,logical,loglin,lower,lowess,ls,lsfit,lsf,ls,m achine,Machine,%
mad,mahalanobis,make,link,margin,match,Math,matlin es,mat,matplot,%
matpoints,matrix,max,mean,median,memory,menu,merge ,methods,min,%
missing,Mod,mode,model,mosaicplot,mtext,mvfft,na,n an,%response,
names,omit,nargs,nchar,ncol,NCOL,new,next,NextMeth od,nextn,%
nlevels,nlm,noquote,NotYetImplemented,NotYetUsed,n row,NROW,null,%
numeric,\%o\%,objects,offset,old,on,Ops,optim,opti mise,optimize,%
options,or,order,ordered,outer,package,packages,pa ge,pairlist,%
pairs,palette,panel,par,parent,parse,paste,path,pb eta,pbinom,%
pcauchy,pchisq,pentagamma,persp,pexp,pf,pgamma,pge om,phyper,pico,%
pictex,piechart,Platform,plnorm,plogis,plot,pmatch ,pmax,pmin,%
pnbinom,pnchisq,pnorm,points,poisson,poly,polygon, polyroot,pos,%
postscript,power,ppoints,ppois,predict,preplot,pre tty,Primitive,%
print,prmatrix,proc,prod,profile,proj,prompt,prop, provide,%
psignrank,ps,pt,ptukey,punif,pweibull,pwilcox,q,qb eta,qbinom,%
qcauchy,qchisq,qexp,qf,qgamma,qgeom,qhyper,qlnorm, qlogis,qnbinom,%
qnchisq,qnorm,qpois,qqline,qqnorm,qqplot,qr,Q,qty, qy,qsignrank,%
qt,qtukey,quantile,quasi,quit,qunif,quote,qweibull ,qwilcox,%
rainbow,range,rank,rbeta,rbind,rbinom,rcauchy,rchi sq,Re,read,csv,%
csv2,fwf,readline,socket,real,Recall,rect,reformul ate,regexpr,%
relevel,remove,rep,repeat,replace,replications,rep ort,require,%
resid,residuals,restart,return,rev,rexp,rf,rgamma, rgb,rgeom,R,%
rhyper,rle,rlnorm,rlogis,rm,rnbinom,RNGkind,rnorm, round,row,%
rownames,rowsum,rpois,rsignrank,rstandard,rstudent ,rt,rug,runif,%
rweibull,rwilcox,sample,sapply,save,scale,scan,sca n,screen,sd,se,%
search,searchpaths,segments,seq,sequence,setdiff,s etequal,set,%
setwd,show,sign,signif,sin,single,sinh,sink,solve, sort,source,%
spline,splinefun,split,sqrt,stars,start,stat,stem, step,stop,%
storage,strstrheight,stripplot,strsplit,structure, strwidth,sub,%
subset,substitute,substr,substring,sum,summary,sun flowerplot,svd,%
sweep,switch,symbol,symbols,symnum,sys,status,syst em,t,table,%
tabulate,tan,tanh,tapply,tempfile,terms,terrain,te tragamma,text,%
time,title,topo,trace,traceback,transform,tri,trig amma,trunc,try,%
ts,tsp,typeof,unclass,undebug,undoc,union,unique,u niroot,unix,%
unlink,unlist,unname,untrace,update,upper,url,UseM ethod,var,%
variable,vector,Version,vi,warning,warnings,weight ed,weights,%
which,while,window,write,\%x\%,x11,X11,xedit,xemac s,xinch,xor,%
xpdrows,xy,xyinch,yinch,zapsmall,zip},%
otherkeywords={!,!=,~,$,*,\%,\&,\%/\%,\%*\%,\%\%,<-,<<-,_,/},%
alsoother={._$},%
sensitive,%
morecomment=[l]\#,%
morestring=[d]",%
morestring=[d]'% 2001 Robert Denham
}%

\lstset{language=Renhanced,extendedchars=false,
basicstyle=\footnotesize\ttfamily,
commentstyle=\textsl,
showstringspaces=false,
frame=single, % adds a frame around the code
numbers=left, % where to put the line-numbers
stepnumber=2,
escapeinside={\{\%}{)},
%escapeinside={§}{§}
}


\begin{document}
\begin{lstlisting}[language=Renhanced]
x<-1 # {%\label{lst:eins})
x<-1 # §\label{lst:eins}§
\end{lstlisting}
\end{document}