Chapter 5 Figures
5.1 Adding figures
Figures and captions can be included, but the syntax is quite different to LaTeX.
Assuming that you would add a figure to a LaTeX document with the following code:
\begin{figure}
\begin{centering}
\includegraphics[width=0.7\textwidth]{Images/ho-tension.png}
\caption{This is a figure caption.}
\label{fig:ho-plot}
\end{centering}
\end{figure}
To include the figure in markdown the syntax is as follows:
```
{r echo=FALSE, ho-plot, out.width='70%', fig.show='hold', fig.cap="This is a figure caption."}
knitr::include_graphics("Images/ho-tension.png")
```
Important parts of this command:
echo=FALSE
prevents the code being used to display the figure being shown.ho-plot
is your figure label.out-width
is the output width of the figure.fig.cap
is the figure caption.knitr::include_graphics
gives the location of the image file.
5.3 Figure numbering and referencing
Figures with labels and captions are numbered according to the section (e.g. Fig 5.1 in this case).
To reference a figure use the syntax
where fig:label
would be fig:ho-plot
in this case.
You can cross reference between sections/chapters, so make sure to use unique figure labels.