较长的部分的短标题在Beamer演示文稿中标题R Markdown(Pandoc)

发布于 2025-02-03 01:26:11 字数 1108 浏览 4 评论 0原文

我正在研究由几个部分组成的beamer_presentation。该部分标题太长了,无法适应剑桥标题。我已经尝试了来自相关乳胶来源的几个选项来使用本节的一些简短标题(例如“第1章”,而不是“第1章,具有非常非常every的长标题” \ atbeginSection。 {\ title [简短标题] {long title}}),但无法弄清楚如何在R Markdown Yaml的标头中管理此问题。我通过在Markdown中设置截面标题

---
title: Title for the whole presentation
subtitle: 'Presentation'
author: 
- Author

institute: "Institution"
date: " `r format(Sys.Date(), '%B %d, %Y')`"
output:
  beamer_presentation:
    latex_engine: xelatex
    toc: true
    highlight: tango
    theme: "CambridgeUS"
    colortheme: "lily"
    fonttheme: "serif"
    slide_level: 3
    keep_tex: true
header-includes:
  - \setbeamertemplate{navigation symbols}{}
  - \AtBeginDocument{\title[Presentation]{Title for whole presentation}}
  - \renewcommand{\raggedright}{\leftskip=0pt \rightskip=0pt plus 0cm}
  - \def\sectionname{Chapter}
  - \AtBeginSubsection{}

---

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


# Chapter 1 with a very-very-very-very-very long title
## Intro

### The first page

I am working on a beamer_presentation which consists of several sections. The section titles are too long to fit into the CambridgeUS headline. I have already tried several options from related latex sources to use some short title for the section (say just "Chapter 1" instead of "Chapter 1 with a very-very-very-very-very long title" by \AtBeginSection{\title[Short title]{Long title}}) but yet can't figure out how to manage this in header-includes of R Markdown YAML. I set the section title through # in Markdown

---
title: Title for the whole presentation
subtitle: 'Presentation'
author: 
- Author

institute: "Institution"
date: " `r format(Sys.Date(), '%B %d, %Y')`"
output:
  beamer_presentation:
    latex_engine: xelatex
    toc: true
    highlight: tango
    theme: "CambridgeUS"
    colortheme: "lily"
    fonttheme: "serif"
    slide_level: 3
    keep_tex: true
header-includes:
  - \setbeamertemplate{navigation symbols}{}
  - \AtBeginDocument{\title[Presentation]{Title for whole presentation}}
  - \renewcommand{\raggedright}{\leftskip=0pt \rightskip=0pt plus 0cm}
  - \def\sectionname{Chapter}
  - \AtBeginSubsection{}

---

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


# Chapter 1 with a very-very-very-very-very long title
## Intro

### The first page

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

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

发布评论

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

评论(1

謌踐踏愛綪 2025-02-10 01:26:11

在Beamer中,这是微不足道的,您可以使用\ section [简短版本] {long version}。但是Markdown使这项简单的工作非常困难。

但是,您可以这样欺骗这样的标记:(

---
title: Title for the whole presentation
subtitle: 'Presentation'
author: 
- Author

institute: "Institution"
date: " `r format(Sys.Date(), '%B %d, %Y')`"
output:
  beamer_presentation:
    latex_engine: xelatex
    toc: false
    highlight: tango
    theme: "CambridgeUS"
    colortheme: "lily"
    fonttheme: "serif"
    slide_level: 3
    keep_tex: true
header-includes:
  - \setbeamertemplate{navigation symbols}{}
  - \AtBeginDocument{\title[Presentation]{Title for whole presentation}}
  - \renewcommand{\raggedright}{\leftskip=0pt \rightskip=0pt plus 0cm}
  - \def\sectionname{Chapter}
  - \AtBeginSubsection{}

---

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

```{=latex}
\tableofcontents[hideallsubsections]
\end{frame}
\section[short version for headline]{Chapter 1 with a very-very-very-very-very long title}
\subsection[short subsection for headline]{Intro}
\begin{frame}
\frametitle{The first page}
```

some text

请小心放置此命令的位置,否则您可能最终会出现空的额外帧 - 这就是为什么我必须关闭自动TOC并手动插入它...)

In beamer, this is trivial, you can use \section[short version]{long version}. But Markdown makes such an easy job excruciatingly difficult.

However you can trick markdown like this:

---
title: Title for the whole presentation
subtitle: 'Presentation'
author: 
- Author

institute: "Institution"
date: " `r format(Sys.Date(), '%B %d, %Y')`"
output:
  beamer_presentation:
    latex_engine: xelatex
    toc: false
    highlight: tango
    theme: "CambridgeUS"
    colortheme: "lily"
    fonttheme: "serif"
    slide_level: 3
    keep_tex: true
header-includes:
  - \setbeamertemplate{navigation symbols}{}
  - \AtBeginDocument{\title[Presentation]{Title for whole presentation}}
  - \renewcommand{\raggedright}{\leftskip=0pt \rightskip=0pt plus 0cm}
  - \def\sectionname{Chapter}
  - \AtBeginSubsection{}

---

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

```{=latex}
\tableofcontents[hideallsubsections]
\end{frame}
\section[short version for headline]{Chapter 1 with a very-very-very-very-very long title}
\subsection[short subsection for headline]{Intro}
\begin{frame}
\frametitle{The first page}
```

some text

(be careful where you place this command, otherwise you might end up with empty extra frames - that's why I had to switch off the automatic toc and insert it manually...)

enter image description here

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