I would like to make cross-references to images and tables generated from knitr code chunk in the same way as to standard figures and tables. In a standard figure I use control sequence \label
, but i don`t know how to put it into a code chunk. (My document contains also standard figures. Therefore I want to have one numbering of all figures and other one for all tables, no matter how they were generated.)
My code:
\documentclass[a4paper,12pt, english]{article}
\usepackage[colorlinks=true,
linkcolor=gray,
urlcolor=blue,
citecolor=gray,
]{hyperref}
\usepackage{graphicx}
\begin{document}
<<chunk_image, results="asis">>=
plot(iris)
@
<<chunk_table, results="asis">>=
library(xtable)
print(xtable(head(iris)))
@
Some text about the image (see \autoref{chunk_image})
\\ Some text about the table (see \autoref{chunk_table})
\end{document}
The outptut I want to get:
Some text about the image (see Figure 1)
Some text about the table (see Table 1)