【问题标题】:Change global font size in bookdown bs4 HTML book?在bookdown bs4 HTML书中更改全局字体大小?
【发布时间】:2021-10-15 03:56:57
【问题描述】:

我创建了一本bs4 主题的书。但是,我没有运气将全局字体大小更改为更小。

_output.yml 文件中,我添加了以下bslib 选项:font_scalefont-size-base,但对字体大小没有任何影响。

尝试 #1

bookdown::bs4_book:
  css: bs4_style.css
  theme:
    primary: "#4C566A"
    font_scale: 0.6

尝试 #2

bookdown::bs4_book:
  css: bs4_style.css
  theme:
    primary: "#4C566A"
    font-size-base: "0.5rem"

【问题讨论】:

    标签: r r-markdown bookdown bslib


    【解决方案1】:

    我也尝试设置font_scale,但似乎不起作用。我的解决方案是在 html 的头部添加一个 CSS 片段。

    CSS 代码保存在文件css.html 中,内容如下:

    <style>
    #content {
        font-size: 0.95rem;
    }
    </style>
    

    那么在.output.yml中,可以通过以下方式将CSS片段添加到header中:

    bookdown::bs4_book:
      .. other settings ..
      includes:
        in_header: [css.html]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-01-19
      • 1970-01-01
      • 1970-01-01
      • 2011-04-03
      • 2015-04-25
      • 2010-10-27
      • 2020-02-24
      • 2020-05-24
      相关资源
      最近更新 更多