My question is about the knitr option fig.cap, when using LaTeX. Is it possible to include an \rinline or \Sexpr in the fig.cap character string?
For example, I would like to have something like (I'm using an .Rtex file):
\documentclass{article}
\begin{document}
%% begin.rcode fig.cap="x is \\rinline{x}"
% x <- 5
% p <- seq(0,5)
% q <- x*p
% plot(p,q)
%% end.rcode
\end{document}
I'd really like for that chunk to produce a plot in my .tex document, with a caption reading "x is 5". Instead, it throws an "undefined control sequence" error on pdflatex compilation.
If I don't escape the rinline (i.e. use just \rinline{x}), then it compiles, but the caption is "x is inlinex".
Is what I'm asking possible?
This is my first SO question (used the answers here many times, though. Thanks!), so I'd appreciate any feedback on how to ask better questions.
Thanks for the help!