【问题标题】:Trouble Making Text italic when rendering an HTML document from Rmd via RStudio通过 RStudio 从 Rmd 渲染 HTML 文档时无法将文本设置为斜体
【发布时间】:2016-12-17 13:01:55
【问题描述】:

我正在尝试在 RStudio 中从 Rmd 创建一个 ioslides 演示文稿,但斜体和粗体格式似乎不起作用(星号和双星号)。如果我渲染成 HTML,它们就可以工作。

我可以使用 CSS 更改文本颜色,但我不能将文本加粗或斜体。在下面的代码中,在这两种情况下(ioslides_presentation 和 html_document),单词“Markdown”都是橙色的,但只有在 html_document 的情况下,文本才会变成斜体。

我在装有最新版本 RStudio 的 Mac 上运行。

CSS 文件:

.mystuff {
    color: orange;
}

Rmd 文件:

---
title: "Untitled"
output:
  ioslides_presentation:
    css: styles.css
date: "12/16/2016"
---


## R Markdown 

This is an R *<span class="mystuff">Markdown</span>* document.
Markdown is a simple formatting syntax for authoring HTML, PDF,
and MS Word documents. For more details on using R Markdown see
<http://rmarkdown.rstudio.com>

【问题讨论】:

    标签: html css rstudio italic ioslides


    【解决方案1】:

    我相信这里的问题是 &lt;em&gt; 文本的默认 ioslides 样式实际上并没有将其斜体化。默认的 ioslides 样式有:

    html, body, div, span, applet, object, iframe,
    h1, h2, h3, h4, h5, h6, p, blockquote, pre,
    a, abbr, acronym, address, big, cite, code,
    del, dfn, em, img, ins, kbd, q, s, samp,
    small, strike, strong, tt, var,
    b, u, i, center,
    dl, dt, dd, ol, ul, li,
    fieldset, form, label, legend,
    table, caption, tbody, tfoot, thead, tr, th, td,
    article, aside, canvas, details, embed,
    figure, figcaption, footer, header, hgroup,
    menu, nav, output, ruby, section, summary,
    time, mark, audio, video {
        margin: 0;
        padding: 0;
        border: 0;
        font: inherit;
        font-size: 100%;
        vertical-align: baseline;
    }
    

    特别是,font: inherit; 位会覆盖通常应用于&lt;em&gt; 元素的默认font-style: italic; CSS 样式。

    您应该能够在您的班级上使用明确的font-style: italic; 来解决此问题。

    【讨论】:

    • 谢谢,解决了。
    【解决方案2】:

    同样的想法,只是在您的自定义 styles.css

    中强制使用斜体
    em {
        font-style: italic !important;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-23
      • 2021-04-27
      • 1970-01-01
      • 2017-12-26
      • 2021-06-08
      • 2021-01-05
      • 1970-01-01
      • 2017-07-10
      相关资源
      最近更新 更多