First, I make two Waffleplots (I think I did it with ggplot)
(...)
waffle_school <- make_waffle(schoolsoort, StudentId)
(...)
waffle_bench <- make_waffle(schoolsoort, benchStudentId)
(...)
using some function:
make_waffle <- function(variableCol, uniqueIdentifiers, numberRowsWaffle = 5, deleteZeros=1) {
(...)
waffle <- waffle(categ_table, colors = Kleuren_schoolsoort[names(Kleuren_schoolsoort) %in% names(categ_table)], rows = numberRowsWaffle) +
theme(legend.position = "bottom") + colScale #+ guides(fill=guide_legend(ncol=4, byrow=TRUE))
return(waffle)
}
Then I actually show the plots at some point in the text
{r Waffleplot-school, fig.height = 2.5, fig.margin=TRUE, fig.cap="\\textcolor{TIGcaptioncolor}{Leerlingen per schoolsoort 21/22 op jullie school}"}
waffle_school
and
{r Waffleplot-landelijk, fig.height = 2.5, fig.margin=TRUE, fig.cap=cap1}
waffle_bench
}
which I later want to refer to in my text, by saying: "In Figure \ref{fig:Waffleplot-school} you can see (..) and in Figure \ref{fig:Waffleplot-landelijk} you see (...)."
This leaves me with question marks in the actual reference in de pdf. By the way, I use pdflatex as a renderer.
Also, this is a part of the yaml header that my main Rmd file has, which I run from another R file.
---
output:
pdf_document:
number_sections: true
keep_tex: true
fig_caption: yes
latex_engine: pdflatex
extra_dependencies: ["flafter"]
then, I call the Rmd file with the pictures and text (incl. references) in it, which has the following header:
---
title: "SchoolInBeeld"
author: "Marja"
date: "`r Sys.Date()`"
bookdown::pdf_document2
---
I have seen the notation \@ref{}, which yielded the exact reference latex call instead of the reference itself: "\ref{fig:Waffleplot-school}". Also, I have visited many questions on this, like
I feel like the output format is the problem though. Something like me trying to use bookdown things but cannot figure out how to call that package.
FYI, I am fluent in Latex, but relatively new to R.
can you try this:
---
output:
bookdown::pdf_document2:
number_sections: true
keep_tex: true
fig_caption: yes
latex_engine: pdflatex
extra_dependencies: ["flafter"]