我使用的是 bookdown
并试图创建一个自定义块,在文本前插入一个固定的文本,例如,在我的文本前插入 "问题:"这个词。我希望它看起来像这样。
"问题"。这是什么意思?
我试着做了以下操作
```{block, type="QUESTION"}
What is the point of this?
```
而且我已经做了CSS样式文件。
.QUESTION {
font-style: italic;
display: inline-block;
}
.QUESTION:before {
font-weight: bold;
content: "Question:";
}
问题是 bookdown
(或pandoc?)将块中的文本用 <p>
和 </p>
所以它不在一条线上,我得到。
问题:
这一切有什么意义?
即,html是这样的。
<div class="QUESTION">
<p>
What is the point of this?
</p>
</div>
如果我手动删除 <p>
从html中提取代码,或将 <div>
语句内的 <p>
括号,这看起来就像我所希望的那样。
有没有办法在bookdown里把这些内嵌起来(就像内嵌r代码一样)?
谢谢你
我强烈建议使用有栅栏的 Div
块,而不是 block
引擎 织物. 你可以找到 更多关于前者的信息在这里. 对于你的问题, Div
块将是。
```{css, echo=FALSE}
.QUESTION {
font-style: italic;
display: inline-block;
}
.QUESTION > :first-child:before {
font-weight: bold;
content: "Question: ";
}
```
::: {.QUESTION}
What is the point of this?
Another paragraph.
:::