Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get headings sans serif while preserving pdf bookmark text?

Tags:

In rmarkdown I want headings with sans serif font. I can achieve this with \textsf{} latex command but later in the PDF there's no bookmark text shown. I already tried ## \textsf[Heading 1]{Heading 1} but with an error as result.

Anybody got an idea how to get both?

MWE:

---
output: pdf_document
---

## \textsf{Heading 1}

Lorem ipsum dolor sit amet, sit id rebum choro euripidis, nam ei ullum tamquam scaevola, est veniam consulatu et. Duo ex utamur atomorum. His ad dicat pericula, solet appetere vel cu. 

## \textsf{Heading 2}

Lorem ipsum dolor sit amet, sit id rebum choro euripidis, nam ei ullum tamquam scaevola, est veniam consulatu et. Duo ex utamur atomorum. His ad dicat pericula, solet appetere vel cu. 

Output:

enter image description here

Wanted:

Bookmarks (left) with text 'Heading 1', 'Heading 2'.

like image 683
jay.sf Avatar asked Aug 31 '18 15:08

jay.sf


1 Answers

Don't mix logical markup ("this is a heading") with physical markup ("this is sans serif"). Instead attach physical markup to logical markup, e.g. using the titlesec package:

---
output: pdf_document
subparagraph: yes
header-includes:
  - \usepackage[sf,bf]{titlesec}
---

## Heading 1

Lorem ipsum dolor sit amet, sit id rebum choro euripidis, nam ei ullum tamquam scaevola, est veniam consulatu et. Duo ex utamur atomorum. His ad dicat pericula, solet appetere vel cu. 

## Heading 2

Lorem ipsum dolor sit amet, sit id rebum choro euripidis, nam ei ullum tamquam scaevola, est veniam consulatu et. Duo ex utamur atomorum. His ad dicat pericula, solet appetere vel cu.
like image 200
Ralf Stubner Avatar answered Sep 28 '22 18:09

Ralf Stubner