Reputation: 340
I am using the kable()
function of knitr package to produce a nice book quality table in a pdf document. The output is as below where the table is placed on the left.
I want to place the table at the center as below.
I would appreciate if anyone can give some advice. I know I can do it using xtable
. Is there any way I can do it directly using kable?
The complete reproducible knitr code (.Rnw file) is as below;
\documentclass{article}
\usepackage{booktabs}
\begin{document}
<<results='asis'>>=
library(knitr)
kable(head(women), format='latex', booktabs=TRUE)
@
\end{document}
Upvotes: 17
Views: 25460
Reputation: 7836
With kableExtra
, you can set the alignment by using:
kable(head(women), "latex", booktabs = T) %>%
kable_styling(position = "center")
http://haozhu233.github.io/kableExtra/awesome_table_in_pdf.pdf
Upvotes: 23