rkableextrapkgdown

How to make tables appear with desired kableExtra theme on pkgdown website?


I am using pkgdown to build my package website. However, when utilizing kableExtra::kable_classic for my final table shown in my website in the Customizing with KableExtra section of my vignette titled "Introduction to panelsummary", I expected my website to return a LaTeX booktabs style as it shows in the kableExtra vignette under the table name: "Recreating booktabs style table".

However, as shown, I do not get such a result—the table has undesirable lines, is not centered (which can't seem to be fixed with fig.align in the RMD file), and really doesn't look similar at all to the booktabs style I was expecting.

I am expecting this might have to do with the bootstrap theme that is being used...but I have not found a good help file that explains how to deal with this sort of issue.


Solution

  • The issue is indeed that the HTML environment <table> generated by kable() inherits CSS properties (in particular, properties of the table CSS class) from the vignette's bootstrap theme that have precedence over kableExtra styles.

    I don't think this is solvable using kable/kableExtra functions but you could use jQuery to remove the table class from those tables that have the .lightable-classic class and fix the display style. Simply include the code chunk below:

    ```{js}
    $( document ).ready(function() {
      $(".lightable-classic").removeClass("table").css("display", "table");
    });
    ```
    

    The regression summary should then look like this:

    enter image description here