r - Custom output hooks in knitr -


i trying create chunk hook can produce \floatfoot{} part of output chunk.

hopefully following example makes clear trying achieve:

1. .rnw file

here knitr file.

\documentclass[a4paper]{article} \title{learn moar knitr!} \author{foo bar} \date{\today}  \usepackage{blindtext} \usepackage{floatrow} \begin{document} \blindtext  <<label=plotwithnotes, fig.lp='fig:', fig.cap='this figure'>>= plot(rnorm(100), rbinom(n = 100, size = 1, prob = 0.5)) @  \end{document} 

2. latex chunk

\begin{figure}[] \includegraphics[width=\maxwidth]{figure/plotwithnotes} \caption[this figure]{this figure\label{fig:plotwithnotes}} \end{figure} 

3. floatfoot

the markup \floatfoot{} provided floatrow package produces footnote graph, , show use, modify latex chunk above.

\begin{figure}[] \includegraphics[width=\maxwidth]{figure/plotwithnotes} \caption[this figure]{this figure\label{fig:plotwithnotes}} \floatfoot{\emph{note:} footer plot , contains information plot.} \end{figure} 

is there way can generate text inside floatfoot above using chunk option?

i made start on writing such function, can't work:

<<echo = true, include = false>>= fnouthookinsertfoot = function(x = null, options = null) {   # find location of \end{figure}   gsub('\\end{figure}', '\\floatfoot{some text.}\\end{figure}',         x, fixed = true)  } # fnouthookinsertfoot() knit_hooks$set(plot = fnouthookinsertfoot) @ 


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -