如何解决在使用 rmarkdown 生成的投影仪演示文稿中垂直居中对齐列的内容
如何在`rmarkdown::beamer_presentation 中垂直居中对齐多列的内容?
正如对 this SO post 的回答的评论中所建议的那样,我尝试了 ::: {.column width="30%"}
,但它对我不起作用。
如果有一种简单的方法可以针对每一列以不同的方式对齐内容,那也将非常有用(例如,c1:顶部,c2:中间,c3:底部,c4:中间) .
MWE
---
output:
bookdown::pdf_book:
base_format: rmarkdown::beamer_presentation
slide_level: 2
keep_tex: true
---
## Figures in columns top-aligned
::: columns
:::: {.column width="30%"}
```{r top-p-5,echo=FALSE,out.width='30%'}
plot(pressure[1:5,])
```
::::
:::: {.column width="30%"}
```{r top-p-10,out.width='50%'}
plot(pressure[1:10,])
```
::::
:::: {.column width="30%"}
```{r top-p-all,out.width='100%'}
plot(pressure[1:nrow(pressure),])
```
::::
:::
## Figures in columns center-aligned (not working)
::: columns
::: {.column width="30%"}
```{r center-p-5,])
```
:::
::: {.column width="30%"}
```{r center-p-10,])
```
:::
::: {.column width="30%"}
```{r center-p-all,])
```
:::
:::
解决方法
您可以使用 :::: {.columns align=center}
来获得中心对齐
---
output:
bookdown::pdf_book:
base_format: rmarkdown::beamer_presentation
slide_level: 2
keep_tex: true
---
## Figures in columns top-aligned
::: columns
:::: {.column width="30%"}
```{r top-p-5,echo=FALSE,out.width='30%'}
plot(pressure[1:5,])
```
::::
:::: {.column width="30%"}
```{r top-p-10,out.width='50%'}
plot(pressure[1:10,])
```
::::
:::: {.column width="30%"}
```{r top-p-all,out.width='100%'}
plot(pressure[1:nrow(pressure),])
```
::::
:::
## Figures in columns center-aligned (not working)
:::: {.columns align=center}
::: {.column width="30%"}
```{r center-p-5,])
```
:::
::: {.column width="30%"}
```{r center-p-10,])
```
:::
::: {.column width="30%"}
```{r center-p-all,])
```
:::
::::
,
为了补充来自@samcarter_is_at_topanswers.xyz 的有用答案,可以采用以下方法来以不同方式对齐每列中的内容:
---
output:
bookdown::pdf_book:
base_format: rmarkdown::beamer_presentation
slide_level: 2
keep_tex: true
---
```{r echo=FALSE}
# CHECK PANDOC VERSION
library(rmarkdown)
if (pandoc_available())
cat("pandoc",as.character(pandoc_version()),"is available\n (pandoc >2.11.2 is required)")
```
## Figures in columns center-aligned (set for all columns at once)
:::: {.columns align=center}
::: {.column width="30%"}
```{r center-p-5,])
```
:::
::::
## Figures in columns aligned differently (set for separately for each column)
:::: {.columns}
::: {.column width="30%" align=center}
center
```{r 3-center-p-5,])
```
:::
::: {.column width="30%" align=top}
top
```{r 3-top-p-10,])
```
:::
::: {.column width="30%" align=bottom}
bottom
```{r 3-bottom-p-all,])
```
:::
::::
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。