Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to control caption placement for figures in KnitR?

Tags:

r

latex

knitr

Is there a way to specify the placement of captions for figures generated by R using KnitR? I'm hoping that there's something functionally equivalent to xtable()'s caption.placement option.

A minimal working example is provided below.

\documentclass[12pt, english, oneside]{amsart}
\begin{document}

The caption for Figure \ref{fig:plot} is placed below the figure. Could we place it above, instead?
<<plot, echo=FALSE, fig.cap="Default caption placement is below the figure.">>=
plot(x=0, y=0)
@

\end{document}
like image 976
Gregory Avatar asked Oct 22 '22 16:10

Gregory


1 Answers

This would likely be best to deal with in the latex style for all figures, but you can customize figures with hooks. The fig.env chunk option controls the environment the block is inserted into. You could always make your own version of figure with your own formatting.

like image 197
jamie.f.olson Avatar answered Oct 24 '22 10:10

jamie.f.olson