I need to insert a text file into LaTeX. But text file names are different for different projects. So I want to define text file name as a variable and refer to the variable when inserting the text
I tried the code as below. But
\VerbatimInput[baselinestretch=1,fontsize=\footnotesize]{{\myfile}}
doesn't work. Only
\VerbatimInput[baselinestretch=1,fontsize=\footnotesize]{abc.txt}
Could anyone give me some guide?
\usepackage{fancyvrb}
<<text, echo=F>>=
targetvar<-'abc'
textfile<-paste(targetvar,'.txt',sep='')
@
\newcommand{\myfile}{\Sexpr{textfile}}
\VerbatimInput[baselinestretch=1,fontsize=\footnotesize]{{\myfile}}
*.texfile that will then be compiled by LaTeX. – Josh O'Brien May 10 '12 at 20:53{{\myfile}}- why do you take 2{? Can you try\VerbatimInput[baselinestretch=1,fontsize=\footnotesize]{\myfile}– knut May 10 '12 at 21:19