html - 通过 RStudio 从 Rmd 渲染 HTML 文档时,无法将文本设置为斜体

标签 html css rstudio italic ioslides

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

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

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

CSS 文件:

.mystuff {
    color: orange;
}

路径文件:

---
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>

最佳答案

我认为这里的问题是 <em> 的默认 ioslides 样式text 实际上并没有将其斜体化。默认的 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;位覆盖默认 font-style: italic; CSS 样式通常应用于 <em>元素。

你应该能够通过明确的 font-style: italic; 来解决这个问题在你的课上。

关于html - 通过 RStudio 从 Rmd 渲染 HTML 文档时,无法将文本设置为斜体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41198850/

相关文章:

c++ - Rcpp Armadillo : RStudio says "exp" is ambiguous

r - 如何忽略 _bookdown.yml 以使用自己的 YAML header 呈现章节?

html - 即使在鼠标离开后使用 CSS 中的动画或过渡属性保持下拉菜单处于事件状态(可见)

php - CSS边框比图片大

jquery获取属性

Html 代码在 IE 8 中工作,不适用于其他浏览器。形状的宽度我不起作用

java - 错误 : SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length

html - 如何使用CSS去除轮廓虚线边框

html - 为什么即使我有内联 block ,div 元素在调整大小时也会分开?

r - 是否有 Rstudio 键盘快捷键来打开包含您编写的函数的源代码的文件?