Reputation: 51
<<newChunk,echo=FALSE,comment=NA,background=NA>>=
x <- "\\includegraphics[width=\\maxwidth]{figure/Kompetenz1.pdf}"
cat(x)
@
If I run this r code in my .Rnw file I will get the following output in my .tex file:
\begin{knitrout}
\definecolor{shadecolor}{rgb}{1, 1, 1}\color{fgcolor}\begin{kframe}
\begin{verbatim}
\includegraphics[width=\maxwidth]{figure/Kompetenz1.pdf}
\end{verbatim}
\end{kframe}
\end{knitrout}
How can I get just the \includegraphics{...} without any environment in my .tex file?
Upvotes: 4
Views: 1049
Reputation: 51
The answer from @baptiste was right.
Why I was using a Knitr chunk was to loop over some values. Here is my example code:
<<Ueberblick, echo = FALSE, results = 'asis'>>=
for(i in 1:nrow(Kompetenzen)){
cat(paste("\\includegraphics[width=\\maxwidth]figure/Kompetenz.pdf}",i," \\newline ",sep=""))
}
@
Thanks for the help!
Upvotes: 1
Reputation: 1803
I am not sure why you are using Knitr in the first place. It looks like your just trying to include a PDF in your latex document. To do that I would use the command:
\includepdf[pages=-]{figure/Kompetenz1.pdf}
or
\includegraphics[width=\maxwidth]{figure/Kompetenz1.pdf}
In your Rnw file. No need for a Knitr chunk here.
Upvotes: 1