我可以将正文与边注对齐吗?

时间:2019-12-20 19:12:35

标签: css r latex r-markdown tufte

我正在使用tufte R包来创建带有边距注释的html文档。我的一些保证金票据是相当高的数字。例如:

<select name="Items[]">
    @foreach (var option in Model.SelectList1Options)
    {
        <option value="@option.Value">@option.Text</option>
    }
</select>

illustration of problem

在降价促销中有可能吗?我的CSS技能/知识有限。

1 个答案:

答案 0 :(得分:1)

我知道了。对于那些非常了解CSS的人来说很简单,但是对于那些不太了解CSS的人来说很简单。边距注释是使用float属性创建的。您可以使用float属性来禁止将浮动元素添加到文本的一侧。

我创建了一个新的“清除”类,用于清除右侧的元素:

<style>
  .cleared {clear: right;}
</style>

然后,每当我希望文本跳到下一个图时,我都会创建一个已清除类的div:

<div class = "cleared"></div>

完整示例如下:

---
title: Big sidenote
output:
  tufte::tufte_html: default
---

<style>
  .cleared {clear: right;}
</style>

```{r setup, include=FALSE}
library(tufte)
# invalidate cache when the tufte version changes
knitr::opts_chunk$set(tidy = FALSE, cache.extra = packageVersion('tufte'))
options(htmltools.dir.version = FALSE)
```


```{r fig.margin = TRUE, fig.cap="Fig1. My margin figure is kind of tall.", echo=FALSE}
plot(mtcars)
```

Here is paragraph 1. It's pretty short and it's associated with Fig 1.

<div class = "cleared"></div>

```{r fig.margin = TRUE, fig.cap="Fig 2. Related to the second paragraph.", echo=FALSE}
plot(subset(mtcars, cyl==6))
```

I'd like this paragraph to start in line with Fig 2.

结果:

enter image description here