user2101601
user2101601

Reputation: 111

Using in line r code as part of a R markdown header

I wish to use in line R code as part of a header in a r markdown file. However when i knit the file the fonts used on the header are different. How can I ensure the fonts are the same. A simple example is below.

`r 1+1`  Header 
-------------------------

Upvotes: 11

Views: 6679

Answers (2)

Greg Snow
Greg Snow

Reputation: 49640

Without a reproducible example it is hard to be precise, but one thing you might want to consider is to use the results="asis" chunk option in your R code so that the results are not wrapped in a code markup block. I am not sure how this works with inline commands, but you could use a regular R block and have it create the entire header from the R code, something like:

```r results="asis"
cat('# ', 1+1, " Header")
```

Upvotes: 2

Brandon Bertelsen
Brandon Bertelsen

Reputation: 44638

You can wrap content in backticks to denote r code inline, as follows:

## Title `r 1+1` Header

Upvotes: 9

Related Questions