Skip to content

Instantly share code, notes, and snippets.

View ComradeMashkov's full-sized avatar
🐈‍⬛
Focusing

ComradeMashkov

🐈‍⬛
Focusing
View GitHub Profile
@burchill
burchill / stop_floating_figures.md
Last active July 31, 2024 00:39
How to make figures and text stay in the order you wrote them in R Markdown when convert to LaTeX!

Keep figures and text in the order you wrote them

Want to keep the order of figures and text the way you wrote them in R Markdown when you convert to LaTeX? Tired of having to insert \FloatBarrier after every chunk you want plotted?

Just use knitr's hooks! Let's look at how we can do it:

Adding the placeins LaTeX package

First, you need to add the placeins LaTeX package to the header of your R Markdown file with \usepackage{placeins}. This lets you use the \FloatBarrier LaTeX command.