如何让R Markdown Beamer幻灯片正文顶对齐但章节标题居中?
解决R Markdown Beamer正文顶对齐但章节标题页居中的问题
要实现正文幻灯片全局顶对齐,同时单独的章节标题页保持居中,可以通过添加LaTeX代码重新定义章节标题页的格式,覆盖classoption: t带来的全局顶对齐效果。
具体步骤
在YAML头部之后,插入以下LaTeX代码,重新设置章节标题页的垂直对齐方式:
\makeatletter \renewcommand{\beamer@sectionpage}[1][t]{ \begingroup \centering \begin{beamercolorbox}[sep=12pt,center]{part title} \usebeamerfont{section title}\insertsection\par \end{beamercolorbox} \endgroup } \makeatother
完整示例代码
--- title: "Your Presentation Title" author: "Your Name" date: "`r Sys.Date()`" output: beamer_presentation: classoption: t --- \makeatletter \renewcommand{\beamer@sectionpage}[1][t]{ \begingroup \centering \begin{beamercolorbox}[sep=12pt,center]{part title} \usebeamerfont{section title}\insertsection\par \end{beamercolorbox} \endgroup } \makeatother # Section 1 ## Slide 1 Content here. # Section 2 ## Slide 2 More content here.
原理说明
classoption: t会让所有幻灯片默认顶对齐,包括自动生成的章节标题页。- 上述LaTeX代码重新定义了
\beamer@sectionpage命令,强制章节标题页内容居中显示,同时不影响其他正文幻灯片的顶对齐设置。
内容的提问来源于stack exchange,提问作者jms202
相关产品推荐
相关产品推荐

