【问题标题】:importing font type for html output using knitr使用knitr导入html输出的字体类型
【发布时间】:2019-11-09 12:28:36
【问题描述】:

我正在尝试导入以下要在我的 html 输出中使用的字体。它们已包含在我的 .css 文件中,但它不起作用。

@import url('https://fonts.googleapis.com/css?family=Josefin+Sans:300,300i,400,400i,600,600i,700,700i');
@import url('https://fonts.googleapis.com/css?family=Fira+Sans:300,300i,400,400i,500,500i,600,600i,700,700i');
@import url('https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600');

h1, h2, h3 {
  font-family: 'Josefin Sans, serif';
  font-weight: normal;
}

body {
  font-family: 'Fira Sans', serif;
}

.remark-code, .remark-inline-code { 
  font-family: 'Source Code Pro', monospace;
}

我的 YAML 如下所示:

---
title: "title"
subtitle: "subtitle"
author:  "author"
date: "date"
output:
  html_document:
    toc: true # table of content true
    toc_float: true
    depth: 3  # upto three depths of headings (specified by #, ## and ###)
    number_sections: false  ## if you want number sections at each table header
    css: [style.css]
    highlight: zenburn  # specifies the syntax highlighting style
    fig.retina: 3
    self_contained: yes
---

为什么我的 html 输出没有使用指定的字体?任何帮助都非常受欢迎!

【问题讨论】:

    标签: html css rstudio r-markdown knitr


    【解决方案1】:

    在您的代码中进行以下更改

    h1, h2, h3 {
      font-family: 'Josefin Sans', serif;
      font-weight: normal;
    }
    
    Right Way ->  font-family: 'Josefin Sans', serif;
    Wrong Way ->  font-family: 'Josefin Sans, serif';
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-30
      • 2011-11-11
      • 2020-10-09
      • 2012-02-24
      • 2014-03-18
      • 2019-06-16
      相关资源
      最近更新 更多