jsmath
jsmath

Reputation: 131

fonts to html output Rmarkdown

When I used \textsf{what} in the following document, "what" disappears in the output file. What should I do to prevent the problem while changing the font of "what"? Thanks!

title: "test"
author: test 
date: 11/23/2020
link-citations: yes
output:
  bookdown::html_document2: default
---

\textsf{what}

Upvotes: 0

Views: 1116

Answers (2)

Daniel_j_iii
Daniel_j_iii

Reputation: 3242

I believe \textsf{what} is latex syntax, which is for PDF output. You are rendering to HTML in your example.

as the @stefan suggested inline CSS in your Rmarkdown it would look like this

---
title: "test"
author: test 
date: 11/23/2020
link-citations: yes
output:
  bookdown::html_document2: default
---


<style>
body, p {
  background-color: lightgray;
  color: black; 
  font-family: Arial Black;
}
</style>

what

I used Arial Black for the example to showcase the effects below.

enter image description here

Upvotes: 1

stefan
stefan

Reputation: 124183

If you want to change the font when rendering to html output you colud use some inline CSS e.g.

<p style = "font-family: Times New Roman; color: red;">what</p>

will print "what" in red using Times New Roman.

Upvotes: 1

Related Questions