4
votes

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)

1
Don't use the centering environment. Instead just call \centering.Werner
I changed my code, works nicely, but if I may ask, what's the difference ?Guillaume
\centering is a declaration, even though you can use it as an environment. If you do, it provides a limit scope, and this seems to defeat the purpose in your case, since you're using it twice within the same environment.Werner

1 Answers

10
votes

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.