在同一PDF页面上的部分标题和面向景观的图

发布于 2025-02-09 01:18:41 字数 1312 浏览 2 评论 0原文

在Knitr生成的PDF中,我想在同一页面上与景观格式显示的图形标题。

如果我这样做,

---
title: "Untitled"
output: pdf_document
date: '2022-06-21'
header-includes:
  - \usepackage{pdflscape}
---
# Section title
\begin{landscape}
```{r pressure, out.extra= 'angle=0', echo = F}
plot(pressure)
```
\end{landscape}

绘图出现在与“部分标题”不同的页面上,因为\ begin {Landscape}显然启动了一个

---
title: "Untitled"
output: pdf_document
date: '2022-06-21'
header-includes:
  - \usepackage{pdflscape}
---
\begin{landscape}
# Section title
```{r pressure, out.extra= 'angle=0', echo = F}
plot(pressure)
```
\end{landscape}

页面

! You can't use `macro parameter character #' in vertical mode.
l.74 #
       Section title 

Error: LaTeX failed to compile sectionTitle.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See sectionTitle.log for more info.
Execution halted

则 ,不起作用

---
title: "Untitled"
output: pdf_document
date: '2022-06-21'
header-includes:
  - \usepackage{pdflscape}
---
\begin{landscape}

# Section title

```{r pressure, echo=FALSE}
plot(pressure)
```
\end{landscape}

Inside a knitr-generated PDF, I want to have the section title on the same page as a figure displayed in landscape format.

If I do this

---
title: "Untitled"
output: pdf_document
date: '2022-06-21'
header-includes:
  - \usepackage{pdflscape}
---
# Section title
\begin{landscape}
```{r pressure, out.extra= 'angle=0', echo = F}
plot(pressure)
```
\end{landscape}

The plot appears on a different page than "Section title" as \begin{landscape} apparently starts a new page

But if I do this

---
title: "Untitled"
output: pdf_document
date: '2022-06-21'
header-includes:
  - \usepackage{pdflscape}
---
\begin{landscape}
# Section title
```{r pressure, out.extra= 'angle=0', echo = F}
plot(pressure)
```
\end{landscape}

I am getting an error message

! You can't use `macro parameter character #' in vertical mode.
l.74 #
       Section title 

Error: LaTeX failed to compile sectionTitle.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See sectionTitle.log for more info.
Execution halted

Edit: this syntax, leaving empty lines around the section heading, is not working

---
title: "Untitled"
output: pdf_document
date: '2022-06-21'
header-includes:
  - \usepackage{pdflscape}
---
\begin{landscape}

# Section title

```{r pressure, echo=FALSE}
plot(pressure)
```
\end{landscape}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

转瞬即逝 2025-02-16 01:18:41

只需应用Yihui的评论,该评论链接到 bookdown文档听起来很复杂,但真的很容易!

---
title: "Untitled"
output: pdf_document
date: '2022-06-21'
header-includes:
  - \usepackage{pdflscape}
---

::: {.landscape data-latex=""}

# Section title

```{r pressure, echo=FALSE}
plot(pressure)
```
:::

Just applying Yihui's comment that links to the bookdown documentation, to show that it sounds complex but is really easy!

---
title: "Untitled"
output: pdf_document
date: '2022-06-21'
header-includes:
  - \usepackage{pdflscape}
---

::: {.landscape data-latex=""}

# Section title

```{r pressure, echo=FALSE}
plot(pressure)
```
:::
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文