rmarkdown pagebreak /whitespace conditional to output generated HTML, pdf


In my Rmd, I would like to produce multiple format outputs (HTML, pdf). I would like some pagebreak after some sections in a pdf while vertical whitespace in case of HTML. Is it possible to detect and conditionally set something in the Rmd to create whitespace in HTML output and pagebreak in case of a pdf when they are rendered?

Thank you

I am not sure what you mean by vertical whitespace exactly. However, here are some resource about what could be useful.

You can easily insert content based on the output format. See

Conditionnal asis engine can be useful too

About pagebreak, know there is a special usage of \pagebreak that will create a pagebreak in PDF and in HTML. For HTML, the pagebreak will appear when printing the webpage (see doc)

Also, you could be interested in pagedown which allow you to create PDF content from HTML, and the HTML view is paginated as the PDF will be.

Hope it helps.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.