Search code examples
rlatexr-markdownkablekableextra

How to remove the automatic table title from kable table in R Markdown


I currently have a R Markdown file where I have some table exporting to LaTex with the knitr package and the kable() function. The problem is that when I knit, there is some automatic titles add to my tables such as :

Table 1: My Title

When I would like to have :

My title

Here is a sample of my code :

kable(import_data, "latex", longtable = T, caption = "Description of Data") 
%>% kable_styling(latex_options = c("striped", "repeat_header")))

Even if my title is correct, the output will be Table 1: Description of Data.

Anyone can help me with this please?


Solution

  • This can be quite useful when you have a lot of table to avoid the automatic Table 1: on all of your LaTex table in R Markdown. I suggest you use this code :

    \usepackage[labelformat = empty]{caption}

    I personnally simply add this code to a .sty file that I import into R. You can also add it directly into your R Setup. This will give you the output you are looking for :

    Caption : Description of Data.

    Tell me if that's work for you.

    Note : I know this is working very well for LaTex/PDF table with kable() but I guess it is also working with the LaTex/HTML table too.