I want to knit a report such that the header is similar to the image below.
I encountered three problems currently
please find the minimal reproducible example below (note that I have commented the online image because I don't know how to correctly code it)
---
output: pdf_document
geometry: margin=0.25in
classoption:
- landscape
---
```{r, echo=FALSE, results='asis'}
for (i in unique(iris$Species)) {
cat("\\newpage")
# cat('\n![](https://bookdown.org/yihui/rmarkdown/images/hex-rmarkdown.png)\n')
cat("\n#", "Iris Species Summary", "\\hfill", paste0("Exhibit ", grep(i, unique(iris$Species)), ".1"))
cat("\n##", i, "\\hfill", "(Gross)")
cat("\n######", "(000's)", "\\hfill", as.character(Sys.Date()))
}
```
Centering Images You can use the knitr include_graphics() function along with the fig. align='center' chunk option. This technique has the benefit of working for both HTML and LaTeX output. You can add CSS styles that center the image (note that this technique works only for HTML output).
There are two ways to render an R Markdown document into its final output format. If you are using RStudio, then the “Knit” button (Ctrl+Shift+K) will render the document and display a preview of it. Note that both methods use the same mechanism; RStudio's “Knit” button calls rmarkdown::render() under the hood.
Code results can be inserted directly into the text of a . Rmd file by enclosing the code with `r ` .
Inline code enables you to insert R code into your document to dynamically updated portions of your text.
All your three questions can be solved by including html
elements.
The RMarkdown is essentially a Markdown, you can include html elements in the file.
you can either use html by:
```{r echo=FALSE}
knitr::asis_output(htmltools::htmlPreserve("
<div>
<div>block 2
</div>
</div>
"))
```
Or
<!--html_preserve-->
<div>
<div>block 3
</div>
</div>
<!--/html_preserve-->
Then you can use the html to change the layout and font in the documents, basically you need to learn to write simple html code, not hard just a lot of googling.
Sorry for not write out the code for you with your examples, it should be straightforward. The reference is here, which is a closed GitHub issue: https://github.com/rstudio/rmarkdown/issues/326.
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With