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: 7
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
\documentclass[12pt]{extbook}
\usepackage{amsmath,amssymb,amsfonts,latexsym,cancel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{multicol} %----
\usepackage{graphicx}
\usepackage{overpic}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{array}
\usepackage{multirow}
\usepackage{wrapfig}
\usepackage{float}
\usepackage{colortbl}
\usepackage{pdflscape}
\usepackage{tabu}
\usepackage{threeparttablex}
\usepackage[normalem]{ulem}
\usepackage{makecell}
\usepackage[usenames,dvipsnames]{xcolor}

and body
\begin{document}
\section{Hi and table data}

\begin{multicols}{3}
<<results='hold',echo=FALSE>>=
library(kableExtra)
muestra = sample(10:60,size=80,replace=TRUE)
tabla = data.frame(n=c(1:10), y=muestra[1:10])
kable(tabla,"latex", longtable = T,booktabs=T,caption="List of peoples") %>%
kable_styling(latex_options= c("repeat_header"), font_size = 8)
@
%==================================
<<results='hold',echo=FALSE>>=
library(kableExtra)
muestra = sample(10:60,size=80,replace=TRUE)
tabla = data.frame(n=c(11:21), y=muestra[11:21])
kable(tabla,"latex", longtable = T,booktabs=T) %>%
kable_styling(latex_options= c("repeat_header"), font_size = 8)
@
%===================================

<<results='hold',echo=FALSE>>=
library(kableExtra)
muestra = sample(10:60,size=80,replace=TRUE)
tabla = data.frame(n=c(11:21), y=muestra[11:21])
kable(tabla,"latex", longtable = T,booktabs=T) %>%
kable_styling(latex_options= c("repeat_header"), font_size = 8)
@
%====================
%and continue until n = c(71:80)
\end{multicols}
\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: No registered users and 12 guests