I am fairly new to Hugo (academic). I am building using R Markdown. In my .rmd file, I produce a table and print this with kable, with position set to center. This works in a normal .rmd file, but my table remains left aligned in the served site. Any ideas how I can centre align the table? See a reproducible example of the R code inside my .rmd file.
I am unsure how I would use an CSS class to centre it. Google wasn’t of much help. If you are aware of a guide that might point me in the right direction, I would really appreciate it.
If you have a public repository for this site, I can take a look at your code. There is a ‘table’ class set on the table element, so you could define some CSS properties for the table class to center it. Having said that, I’m not sure why it isn’t already centered, because style="margin-left: auto; margin-right: auto;" should do the trick. Maybe something is overriding those styles. I’d have to see the code and site itself to diagnose further.
Ok, I didn’t see anything obvious in any of the CSS. There is a lot going on there, between the theme styles, Bootstrap and styles in the HTML elements. I would inspect the table in browser and try to figure out what is controlling the alignment. Is it element, is it an important override somewhere in theme or Bootstrap, etc. If you get this hosted online somewhere I can look too, but that’s how I would go about figuring out what’s in control. Honestly, I use Tailwinds now for everything and it is so nice to have utility classes right in the element that you are looking at. There isn’t any guessing what is controlling the layout.