Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unwanted white space with knitr+booktabs package

Tags:

r

latex

knitr

I want to include a table in my latex document that I create using knitr package. I "call" the table using:

\begin{table}[H]
\begin{centering}
<<r second part}>>=
kable(Per_cond, booktabs=T,row.names=F)
@
\par\end{centering}
\begin{centering}
\protect\caption{Summary of plate}
\par\end{centering}
\label{Table}
\end{table}

The results is amazing as usual, but as you can see below, some white space is added after every 5 rows.

enter image description here

When created with booktabs=F those white spaces disappear (second image).

enter image description here

Do you know a way to get rid of those white spaces or (even better) to select where they appear (in this case if they would come after every 4 rows, they would nicely separate my conditions) ? Thank you for your help.

(RStudio 0.98.1062, knitr v 1.9, MikTex 2.9, booktabs packaged 2005-05-04)

like image 379
Guillaume Avatar asked Dec 25 '22 21:12

Guillaume


1 Answers

Looking at the source of kable, it calls knitr:::kable_latex if you're using LaTeX. Then, looking at that source, it has the following argument and default:

linesep = if (booktabs) c("", "", "", "", "\\addlinespace")

So, I'm guessing if you explicitly pass

linesep = c("", "", "", "\\addlinespace")

you'll get spaces every 4 lines as desired.

like image 93
Gregor Thomas Avatar answered Dec 27 '22 10:12

Gregor Thomas