akhmed answer was absolutely amazing!
I made an slighly modification for Rmd to get caption first and to generalize for every chunk in the document.
We have to add these lines at the beginning:
knit_hooks$set(plot = function(x, options, .notes = notes, .sources = sources) {
paste("\n\n\\begin{figure}\n",
"\\includegraphics[width=\\maxwidth]{",
opts_knit$get("base.url"), paste(x, collapse = "."),
"}\n",
"\\caption{",options$fig.cap,"}","\\label{fig:",opts_current$get("label"),"}","\\textsc{}",
"\n\\textsc{Notas} -- ",.notes,
"\n\\textsc{Fuentes} -- ", .sources,
"\n\\end{figure}\n",
sep = '')
})
Then in every chunk we only write the notes and sources of the plot
notes = "Notes to explain the plot"
sources = "Explain the sources"
Again, thanks a lot akhmed!!
Pd: I use "\\textsc{}" to generate an space among caption and notes & sources.
It would be nice to generalize this to use subcaptions with many figures in the same plot.