I'm using the posterdown
package in R to generate a HTML Poster and render it as a PDF.
I have a table in my Rmd file, however the caption is really small. Is there a way to increase the size of the caption?
Secondly, I would also like to move the title and affiliation in the header slightly down (so that its more in the center of the header. Is there a way to do that?
Here is a snippet of my Rmd file
---
title: Here is my title
author:
- name: Name and Surname
affiliation:
address: Department, University
column_numbers: 3
logoright_name: https://raw.githubusercontent.com/brentthorne/posterdown/master/images/betterhexlogo.png
logoleft_name: https://raw.githubusercontent.com/brentthorne/posterdown/master/images/betterhexlogo.png
output:
posterdown::posterdown_html:
self_contained: false
knit: pagedown::chrome_print
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
# Intro
```{r table1, echo = FALSE, warning = FALSE, message = FALSE, results = 'asis', fig.pos='!h'}
library(tidyverse)
library(kableExtra)
col_1 <- c(1,2,3)
col_2 <- c(4,5,6)
col_3 <- c(7,8,9)
data.frame(col_1, col_2, col_3) %>%
kable(format='html',booktabs=TRUE, caption = "This is the caption", escape=F) %>%
kable_styling(font_size = 45)
```
`````
For the title, you have several options. The easiest is certaintly to insert a <br>
before the title in the YAML at the top of your document. This will insert a line return before your title.
Alternatively, you could insert a CSS block to alter the style of the h1
tag:
```{css, echo=FALSE}
h1 {
padding-top: 40px
}
```
In principle, you should be able to include this kind of CSS block to change the style of any HTML element. However, kableExtra
seems to hard code the font size and to ignore CSS, so this solution only works for some style elements. One hacky solution is to manually substitute the font size in the raw HTML using gsub
or some other similar mechanism:
```{css, echo=FALSE}
.table caption {
color: red;
font-weight: bold;
}
```
```{r table1, echo = FALSE, warning = FALSE, message = FALSE, results = 'asis', fig.pos='!h'}
library(kableExtra)
col_1 <- c(1,2,3)
col_2 <- c(4,5,6)
col_3 <- c(7,8,9)
data.frame(col_1, col_2, col_3) %>%
kbl(format = 'html',
escape = FALSE,
caption = "This is the caption") %>%
kable_styling(font_size = 45) %>%
gsub("font-size: initial !important;",
"font-size: 45pt !important;",
.)
```