LaTeX forum ⇒ Generalhow to write knitr tables in multi-columns

LaTeX specific issues not fitting into one of the other forums of this category.
royer11
Posts: 4
Joined: Tue Jul 23, 2019 12:20 am

how to write knitr tables in multi-columns

Postby royer11 » Thu Aug 22, 2019 8:01 pm

Hello, I have difficulties in making the tables print aligned because there is little data in column.


code header
  1. \documentclass[12pt]{extbook}
  2. \usepackage{amsmath,amssymb,amsfonts,latexsym,cancel}
  3. \usepackage[T1]{fontenc}
  4. \usepackage[utf8]{inputenc}
  5. \usepackage{multicol} %----
  6. \usepackage{graphicx}
  7. \usepackage{overpic}
  8. \usepackage{booktabs}
  9. \usepackage{longtable}
  10. \usepackage{array}
  11. \usepackage{multirow}
  12. \usepackage{wrapfig}
  13. \usepackage{float}
  14. \usepackage{colortbl}
  15. \usepackage{pdflscape}
  16. \usepackage{tabu}
  17. \usepackage{threeparttablex}
  18. \usepackage[normalem]{ulem}
  19. \usepackage{makecell}
  20. \usepackage[usenames,dvipsnames]{xcolor}

and body
  1. \begin{document}
  2. \section{Hi and table data}
  3.  
  4. \begin{multicols}{3}
  5. <<results='hold',echo=FALSE>>=
  6. library(kableExtra)
  7. muestra = sample(10:60,size=80,replace=TRUE)
  8. tabla = data.frame(n=c(1:10), y=muestra[1:10])
  9. kable(tabla,"latex", longtable = T,booktabs=T,caption="List of peoples") %>%
  10. kable_styling(latex_options= c("repeat_header"), font_size = 8)
  11. @
  12. %==================================
  13. <<results='hold',echo=FALSE>>=
  14. library(kableExtra)
  15. muestra = sample(10:60,size=80,replace=TRUE)
  16. tabla = data.frame(n=c(11:21), y=muestra[11:21])
  17. kable(tabla,"latex", longtable = T,booktabs=T) %>%
  18. kable_styling(latex_options= c("repeat_header"), font_size = 8)
  19. @
  20. %===================================
  21.  
  22. <<results='hold',echo=FALSE>>=
  23. library(kableExtra)
  24. muestra = sample(10:60,size=80,replace=TRUE)
  25. tabla = data.frame(n=c(11:21), y=muestra[11:21])
  26. kable(tabla,"latex", longtable = T,booktabs=T) %>%
  27. kable_styling(latex_options= c("repeat_header"), font_size = 8)
  28. @
  29. %====================
  30. %and continue until n = c(71:80)
  31. \end{multicols}
  32. \end{document}

I had thought of using multicols but it turns out that it generates error and I have also tried minipage but it does not print as I wish.

Objetive
Image

Return to “General”

Who is online

Users browsing this forum: Google [Bot] and 6 guests