如何在rmarkdown演示文稿中将图片放在左侧并将文本放在右侧

13

2
如果有人提出了一个在输出格式为.pdf时有效的解决方案,那将使我非常高兴。 - Gorka
3个回答

12

使用multicol宏包:

---
title: "Untitled"
author: "Martin"
date: "7/9/2017"
output: 
  beamer_presentation: 
    keep_tex: yes
header-includes:
  - \usepackage{multicol}
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```

## R Markdow

\begin{multicols}{2}

  \null \vfill
  \includegraphics[width=.3\textwidth]{unnamed.png}
  \vfill \null

\columnbreak

  \null \vfill
  \begin{itemize}
    \item Item 1
    \item Item 2
  \end{itemize}
  \vfill \null
\end{multicols}

输入图像描述


你知道如何将图片和文本居中吗?我的图片和文本出现在幻灯片的顶部,因此底部有黑色空间。 - wolfsatthedoor
右侧的内容是否可以是项目列表?当我尝试时,会出现执行错误。 - wolfsatthedoor
2
请向下滚动:这是正确的答案 - user000001

10
你可以用 Pandoc 的方式来完成这件事!请参考手册获取更多信息。
---
output: beamer_presentation
---

:::: {.columns}
::: {.column width="60%"}
![giraffe](giraffe.jpg)
:::
::: {.column width="40%"}
["Funny giraffe looking at the side"](https://www.flickr.com/photos/8070463@N03/9594476129) by [Tambako the Jaguar](https://www.flickr.com/photos/8070463@N03) is licensed under [CC BY-ND 2.0](https://creativecommons.org/licenses/by-nd/2.0/?ref=ccsearch&atype=rich)
:::
::::

screenshot


3
我不建议在beamer中使用multicol包,因为beamer有自己的列机制:
---
output: 
  beamer_presentation:
    theme: "CambridgeUS"
    keep_tex: true

---

# test

\begin{columns}[onlytextwidth,T]
  \begin{column}{.45\linewidth}
    \includegraphics[width=\linewidth]{example-image-duck}
  \end{column}
  \begin{column}{.45\linewidth}
    test
  \end{column}
\end{columns}

enter image description here


1
@ideus 使用硬编码宽度并不是一个有用的建议。列使用相对宽度,如果改变纵横比或类似情况,它们将自动调整。如果将其与硬编码长度结合使用,将会破坏布局。 - samcarter_is_at_topanswers.xyz

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接