Closed ashinonyx closed 6 hours ago
Seems like its related to the underscores in the caption. Are you trying to italicize these words? What happens if you use two asterisks instead (e.g., Sample sizes of observational data for *Panthera tigris* and *Panthera leo*
)? The rendering of Markdown captions to LaTeX is handled by https://github.com/mattwarkentin/torontodown/blob/master/R/render_caption.R, which is not a function I wrote.
If this doesn't fix things, my suggestion would be to use LaTeX syntax for italicizing.
The underscores indeed seem to be the issue. Unfortunately for whatever reason, the asterisks don't render as italics but rather as, e.g., *Panthera tigris*
(iirc that's why I used the underscores in the first place, since I usually use asterisks).
If I try to use LaTeX syntax, I get the following error:
(*) NOTE: I saw chunk options " echo=FALSE, out.width="90%", fig.cap="Growth curve for wild \emph{Panthera tigris}.""
please go to https://yihui.org/knitr/options
(it is likely that you forgot to quote "character" options)
Error: '\e' is an unrecognized escape in character string starting ""Growth curve for wild \e"
Try adding escape = FALSE
to the knitr::kable()
function.
You may also need to add some extra backslashes, because R and backslashes don't play nicely together.
No luck on either case.
This example works for me:
table1 <- tibble::tibble(Taxon = c("_Panthera tigris_", "_Panthera leo_", "_Panthera tigris altaica_",
"_Panthera tigris jacksoni_", "_Panthera tigris sumatrae_",
"_Panthera tigris tigris_", "_Panthera leo krugeri_", "_Panthera leo leo_",
"_Panthera leo massaica_", "_Panthera leo melanochaita_",
"_Panthera leo persica_", "_Panthera leo senegalensis_"),
Origin = c("wild", "wild",
"captive", "captive", "captive", "captive",
"captive", "captive", "captive", "captive", "captive", "captive"))
table1 |>
mutate(
Taxon = str_remove_all(Taxon, '_'),
Taxon = paste0('\\textit{', Taxon, '}')
) |>
knitr::kable(
caption = "Sample sizes of observational data for \\textit{Panthera tigris} and \\textit{Panthera leo}",
escape = FALSE)
I had to trim down the data because I didn't have access to some required objects for the full data set. But this hopefully will provide some guidance.
Alright, I'm having a new issue now!
When I try to render, I get the following error:
This is one of the code blocks that throws this error:
I'm also attaching the log file here. Reynolds_Ashley_R_2023_PhD_thesis.log
If I render the Rmd file outside of the thesis project, the table code blocks run and render just fine, so it seems to be an issue with bookdown/torontodown. I know of this issue and have tried the fixes there, to no avail.
(Not related to the error, but how would I go about removing the chapter title or using an abbreviated title in the header? Most of my chapter titles are too long to fit in the header space, so it looks ugly as of right now)