Search code examples
htmlrr-markdownline-breaks

RMarkdown - Is there a way to easily add space after each tabset?


I'm using R Markdown to create reports, and I use tabsets (.{tabset}) to show several results, without having to print them one below the other. Like this:

# First session {.tabset}    

## A    
First result

## B    
Second result

# Next session

Now, let's say I want 4 line breaks before my second session, as I used tabset, I have to specify the line breaks after each tabset. Like this:

# First session {.tabset}    

## A    
First result
<br /><br /><br /><br />

## B    
Second result
<br /><br /><br /><br />

# Next session

With 2 tabsets, it's ok, but sometimes I have 10 or more. Q/ Is there a way to add the line breaks only once, before the next session, without having to repeat the specification under each tabset ?


Solution

  • You can address this using CSS. By adding bottom margin on the tab-content HTML element, you systematically create white space there. To do this, add the style part on top of your markdown file. You may choose the optimal amount of pixels for your need

    <style>
    .tab-content{
        margin-bottom: 50px;
    }
    </style>
    # First session {.tabset}    
    
    ## A    
    First result
    
    ## B    
    Second result
    
    # Next session