0

I am using RStudio with a Bookdown template and am trying to place my table in the middle of the page. I am using the position command as per the example code developer's page to center-align the table. Upon knitting to HTML, the table remains left-aligned.

This is what I tried at first:

```{r table-test, echo = FALSE}

# To get started
library(knitr)
library(kableExtra)
dt <- mtcars[1:5, 1:6]

# Now to the example...
# Note that the position is not the default "left" but rather "center"
kable(dt) %>%
  kable_styling(bootstrap_options = "striped", full_width = F, position = "center")```

I also tried placing <center> before the R chunk and </center> afterwards. In both cases, the table remains left-aligned. In addition, the full_width = T command does not make a difference as the table remains as before.

This is the YAML header:

title: "Integration"
author:
- Nitram
date: "updated on `r Sys.Date()`"
output: bookdown::pdf_book
bibliography: EC-biblio.bib
always_allow_html: yes
description: Nitram
documentclass: book
github-repo: https://gitlab.uni.edu/
link-citations: yes
biblio-style: apalike
site: bookdown::bookdown_site
advisor: Advisor
unitname:
  faculty: School
  institute: Institute
  laboratory: Lab
preface: |
  `r paste(readLines("_00-preface.Rmd"), collapse = '\n  ')`
abstract: |
  `r paste(readLines("_00-abstract.Rmd"), collapse = '\n  ')`
resume: |
  `r paste(readLines("_00-resume.Rmd"), collapse = '\n  ')`
acknowledgements: |
  `r paste(readLines("_00-acknowledgements.Rmd"), collapse = '\n  ')`

How can I center-align my table?


PS: since this may be a bug, I have reported it here.

Martin
  • 401
  • 6
  • 15

0 Answers0