覆盖 rmarkdown 主题以更改 html 页面宽度
Override rmarkdown theme in order to change html page width
我正在尝试将 rmarkdown 的输出扩大到 html。我一直在尝试 this solution with no success (although I'm using the cerulean theme, that should be responsive according to comments). Also tried adding a css
element as described - 没有效果。
我怎样才能使这个工作?
使用您的样式创建一个文件styles.css
:
<style>
.main-container {
width: 100%;
max-width: unset;
}
</style>
并将其包含在您的 rmarkdown as described here:
---
output:
html_document:
css: styles.css
---
这两个选项都适合我。
上面的答案没有用,所以我花了很多时间来解决这个问题。看来您不能再将原始 CSS 转储到 rmarkdown 文档中并将其正确包含在内。
这个解决方案对我有用。请注意,我必须修改 body 和主容器的最大宽度,它作为一个块放置在 yaml header.
之后
```{css, echo=FALSE}
body .main-container {
max-width: 1280px !important;
width: 1280px !important;
}
body {
max-width: 1280px !important;
}
```
这里是如何正确集成 css 的参考:https://bookdown.org/yihui/rmarkdown/language-engines.html#javascript-and-css
我找不到需要修改的各种属性的任何参考,我从 Chrome 开发人员控制台中找到了所有内容。
我正在尝试将 rmarkdown 的输出扩大到 html。我一直在尝试 this solution with no success (although I'm using the cerulean theme, that should be responsive according to comments). Also tried adding a css
element as described
我怎样才能使这个工作?
使用您的样式创建一个文件styles.css
:
<style>
.main-container {
width: 100%;
max-width: unset;
}
</style>
并将其包含在您的 rmarkdown as described here:
---
output:
html_document:
css: styles.css
---
这两个选项都适合我。
上面的答案没有用,所以我花了很多时间来解决这个问题。看来您不能再将原始 CSS 转储到 rmarkdown 文档中并将其正确包含在内。
这个解决方案对我有用。请注意,我必须修改 body 和主容器的最大宽度,它作为一个块放置在 yaml header.
之后 ```{css, echo=FALSE}
body .main-container {
max-width: 1280px !important;
width: 1280px !important;
}
body {
max-width: 1280px !important;
}
```
这里是如何正确集成 css 的参考:https://bookdown.org/yihui/rmarkdown/language-engines.html#javascript-and-css
我找不到需要修改的各种属性的任何参考,我从 Chrome 开发人员控制台中找到了所有内容。