代码之家  ›  专栏  ›  技术社区  ›  David

xaringan metropolis代码输出中没有连字

  •  1
  • David  · 技术社区  · 6 年前

    我正在使用xaringan(metropolis theme)为R教学准备一些幻灯片,因此我希望看到代码“原样”。Xaringan目前在代码中使用连字,我认为这看起来不错,但当把语言教给一个从零开始的人时,这确实很糟糕。

    给你举个例子 <- 呈现为

    enter image description here

    != 呈现为

    enter image description here

    有办法解决这个问题吗?

    MWE看起来是这样的(删除metropolis字体会删除连字,当然会更改字体)

    ---
    output:
      xaringan::moon_reader:
        lib_dir: libs
        css: [default, metropolis, metropolis-fonts]
        nature:
          highlightStyle: github
          highlightLines: true
          highlightSpans: true
          countIncrementalSlides: false
    ---
    
    ```{r}
    x <- 1:10
    x[1] != x[2]
    ```
    
    1 回复  |  直到 6 年前
        1
  •  2
  •   David    6 年前

    透过 metropolis theme ,给出了使用以下css的解决方案 Fira Code 菲拉·莫诺。

    我的css.css

    .remark-code, .remark-inline-code {
       font-family: 'Fira Mono', 'Lucida Console', Monaco, monospace;
       font-size: 80%;
    }
    

    演示文稿.Rmd

    ---
    output:
      xaringan::moon_reader:
        lib_dir: libs
        css: [default, metropolis, metropolis-fonts, mycss.css]
        nature:
          highlightStyle: github
          highlightLines: true
          highlightSpans: true
          countIncrementalSlides: false
    ---
    
    No change in fonts here
    
    ```{r}
    x <- 1:10
    x[1] != x[2]
    ```