Search code examples
rmarkdown

How to change the color/theme on rmdformats/readthedown?


I'm generating a report using the rmdformats package in R, with the readthedown format.

How can I change the default overall color?

enter image description here


Solution

  • rmdformats author here.

    To change the default color for titles and other elements, you have to provide a custom CSS file which redefines the default CSS elements defining color.

    If think the following CSS elements should be enough :

    #main .nav-pills > li.active > a,
    #main .nav-pills > li.active > a:hover,
    #main .nav-pills > li.active > a:focus {
        background-color: #22983B;
    }
    
    #main .nav-pills > li > a:hover {
        background-color: #22983B;
    }
    
    h1, h2, h3, h4, h5, h6, legend {
        color: #22983B;
    }
    
    #nav-top span.glyphicon {
        color: #22983B;
    }
    
    #table-of-contents header {
        color: #22983B;
    }
    
    #table-of-contents h2 {
        background-color: #22983B;
    }
    
    #main a {
        background-image: linear-gradient(180deg,#d64a70,#d64a70);
        color: #c7254e;
    }
    
    a:hover {
        color: #3d1308;
    }
    
    a:visited {
        color: #3d1308;
    }
    

    Customize and add this to a custom.css file in your Rmd file directory, and add css: custom.css in your preamble.