0

I would like to write an article using R markdown. I would like to change the text type to typewriter.

I tried this but does not work.

p.caption {
  color: #777;
  margin-top: 10px;
}
p code {
  white-space: inherit;
}
pre {
  word-break: normal;
  word-wrap: normal;
}
pre code {
  white-space: inherit;
}
/* Whole document: */
body{
  font-family: typewriter;
  font-size: 16pt;
}
/* Headers */
h1,h2,h3,h4,h5,h6{
  font-size: 24pt;
}

Any help, please?

Mary
  • 78
  • 1
  • 11
  • 2
    Are you rendering to HTML? Is there anything in your code elsewhere or any local assets that would make this CSS recognize `typewriter` as a font family? If you're relying on a CSS generic, that would be `monospace`, not `typewriter` – camille Aug 25 '19 at 19:05
  • @camille Thank you so much for your comment. I really appreciate it. I am rendering to phf document. – Mary Aug 25 '19 at 19:24
  • The code you have here is CSS, which is only applied to HTML. To style how a file is rendered to PDF, you need to make changes that will be meaningful to Latex. [Here's one](https://stackoverflow.com/q/50539913/5325862) of several SO posts on setting fonts – camille Aug 25 '19 at 19:36

1 Answers1

0

Add this in the Rmd file before the first chunk :

<style>
div.fontdoc { font-family: typewriter;}
</style>
<div class = "fontdoc">
  • This would work if 1. the OP were rendering to HTML, and 2. `typewriter` were a recognized font family they had loaded. They're rendering to PDF, and whether that's pointing to a valid font family is unclear – camille Aug 25 '19 at 19:37