This is a quick list of tips/commands I have found useful when tidying up the resulting Rmd files when converted from the LaTeX source.
Sections
A chapter or section is simply marked with hashtags and automatically given a reference label for example # First Chapter
would give a section named ‘First Chapter’ with the ID label first-chapter
.
You can give your own ID label to a section or chapter by using # First Chapter {#bananaboots}
where the label you give it can be anything you like.
Any subsections are simply denoted ## First Subsection
and ### First subsubsection
and so on (they can also be labelled in the same way).
Equations
LaTeX commands can be used for equations including the $ notation. To label an equation you can use:
\begin{equation}
e^i\pi + 1 = 0
(\#eq:euler)
\end{equation}
An equation array is also easy to include and label:
\begin{equation}
\begin{aligned}
\sin^2(\theta) + \cos^2(\theta) &= 1\\
\sec^2(\theta) - \tan^2(\theta) &= 1
\end{aligned}
(\#eq:array)
\end{equation}
Figures
The figures convert well, generally, as long as the file paths are correct. You will get the Markdown command that lloks something like this:
![Figure caption](figure.png){width=100%}
But if you want a little more control and to include a label, you can use something like this:
```{r echo=FALSE, label, out.width='70%', fig.show='hold', fig.cap='This is the caption'}knitr::include_graphics("figure.png")
```
Tables
Again these tend to convert well, but again if you want to start from scratch or include a bit more control and labels, I found this works:
Table: (\#tab:tablelabel) The interesting caption.
|Column 1|Column 2|Column 3|
|:-----|:-----|-----:|
|Row 1|a|b|
|Row 2|c|d|
The |:—| sets the alignment for the column.
Cross-referencing
After labelling your sections they can be referred to using \@ref(bananaboots)
.
Equations can be referenced using \@ref(eq:euler)
, figures \@ref{fig:label}
and tables \@ref{tab:tablelabel}
.
Miscellaneous formatting I found useful
Centre test, figure, table etc:
::: center
![caption](figure.png){width=50%}
:::
Display:
::: tmframed
This sentence is displayed.
:::
Bold text:
___Something bold___
Italic text:
* This is rendered in italics *
Display in a box:
:::: {.textbox data-latex=""}
$$e^i\pi + 1 = 0$$
:::
The properties of the box can be specified in the style.css file for the project.