In the following minimum example, it seems that it is fine to use cat to print out headings and kables / plots from r. But I can't print out simple text. It gets formatted in to the extreme right hand side, apparently into the margin. Here's the min example:
```{r echo=FALSE, results="asis"}
if (TRUE) {
cat(paste0("\n", "### 2.1 The Health Standards\n"))
cat("\nLow indoor temperatures are associated with increased risks of respiratory")
monkeyr::who_guidance_kable()
}
```
And the output is like this:
Additional info: In the yaml header, I have put:
output:
distill::distill_article:
toc: true
toc_depth: 2
theme: theme.css
And the css file is as follows:
/* base variables */
/* Edit the CSS properties in this file to create a custom
Distill theme. Only edit values in the right column
for each row; values shown are the CSS defaults.
To return any property to the default,
you may set its value to: unset
All rows must end with a semi-colon. */
/* Optional: embed custom fonts here with `@import` */
/* This must remain at the top of this file. */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans');
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono');
html {
/*-- Main font sizes --*/
--title-size: 48px;
--body-size: 1.0rem;
--code-size: 14px;
--aside-size: 12px;
--fig-cap-size: 13px;
/*-- Main font colors --*/
--title-color: #000000;
--header-color: rgba(0, 0, 0, 0.8);
--body-color: rgba(0, 0, 0, 0.8);
--aside-color: rgba(0, 0, 0, 0.6);
--fig-cap-color: rgba(0, 0, 0, 0.6);
/*-- Specify custom fonts ~~~ must be imported above --*/
--heading-font: "IBM Plex Sans", sans-serif;
--mono-font: "IBM Plex Mono", monospace;
--body-font: "IBM Plex Sans", sans-serif;
--navbar-font: "IBM Plex Sans", sans-serif; /* websites + blogs only */
}
/*-- ARTICLE METADATA --*/
d-byline {
--heading-size: 0.6rem;
--heading-color: rgba(0, 0, 0, 0.5);
--body-size: 0.8rem;
--body-color: rgba(0, 0, 0, 0.8);
}
/*-- ARTICLE TABLE OF CONTENTS --*/
.d-contents {
--heading-size: 18px;
--contents-size: 13px;
}
/*-- ARTICLE APPENDIX --*/
d-appendix {
--heading-size: 15px;
--heading-color: rgba(0, 0, 0, 0.65);
--text-size: 0.8em;
--text-color: rgba(0, 0, 0, 0.5);
}
/*-- WEBSITE HEADER + FOOTER --*/
/* These properties only apply to Distill sites and blogs */
.distill-site-header {
--title-size: 18px;
--text-color: rgba(255, 255, 255, 0.8);
--text-size: 15px;
--hover-color: white;
--bkgd-color: #0F2E3D;
}
.distill-site-footer {
--text-color: rgba(255, 255, 255, 0.8);
--text-size: 15px;
--hover-color: white;
--bkgd-color: #0F2E3D;
}
/*-- Additional custom styles --*/
/* Add any additional CSS rules below */
/* Change appearance of headers */
Is there user error going on here? N.B the use case is to extend this to allow conditional inclusion of text and plots etc...
Extra Detail:
I've extended my testing of this to add kables and plots inside a loop:
```{r echo=FALSE, results="asis"}
if (TRUE) {
cat(paste0("\n", "## ", section_number, ".X Testing Loops ", mytempVarTitle))
target_var_vec <- c("room", "tenure")
for (i in 1:2) {
# target_var <- "room"
reg_data <- monkeyr::get_reg_data(wranged_devices, wrangled_obs, target_reading = "temp")
boxplot <- monkeyr::get_reg_boxplot(reg_data, target_var_vec[i])
print(boxplot)
cat(paste0("\n", "#### Box Plot ", section_number, ".", i, " : ", target_var_vec[i]), "\n")
reg_kable <- monkeyr::get_reg_kable(reg_data, target_var_vec[i])
print(reg_kable)
cat(paste0("\n", "#### Kable ", section_number, ".", i, " : ", target_var_vec[i]), "\n")
exposure_chart_data <- monkeyr::get_exposure_chart_data(wrangled_obs, wrangled_devices, target_var_vec[i])
exposure_plot <- monkeyr::get_exposure_plot(exposure_chart_data, target_var_vec[i])
print(exposure_plot)
cat(paste0("\n", "#### Plot ", section_number, ".", i, " : ", target_var_vec[i], "\n"))
}
# BAIL TO FOCUS ON TEST
knitr::knit_exit("</body></html>")
}
```
The results seem almost random. If I add in an extra "\n" or a "
" one of the captions will go into the margin like the text above.

