You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在R Markdown PDF幻灯片标题页标题下方插入图片(作者上方)

解决Beamer标题页标题下方插入图片的问题

问题根源

你遇到的\if@titlepage未定义错误,是因为titling包与beamer文档类不兼容。titling是为标准LaTeX文档类(如article、report)设计的,而beamer有一套独立的标题页渲染机制,两者混用会触发命令冲突。

正确解决方案:重定义Beamer标题页模板

直接利用beamer自带的模板定制功能,精准控制标题、图片、作者信息的位置,无需依赖titling包。修改后的最小工作示例(MWE)如下:

---
title: "Your Presentation Title"
author: "Your Name"
date: "`r Sys.Date()`"
output:
  beamer_presentation:
header-includes:
  - \setbeamertemplate{title page}{%
      \vbox{}
      \vfill
      \begingroup
        \centering
        \usebeamerfont{title}\inserttitle\par
        \vskip1em  # 标题与图片之间的间距
        \includegraphics[width=2in,height=2in]{images/my-title-image}\par
        \vskip1em  # 图片与作者之间的间距
        \usebeamerfont{author}\insertauthor\par
        \usebeamerfont{date}\insertdate\par
        \vfill
      \endgroup
    }
---

# Section 1

## Slide 1

Content here.

# Section 2

## Slide 2

More content here.

说明

  • 这个方法直接重写beamer的标题页模板,按照标题→图片→作者→日期的顺序排版,完全适配beamer的渲染逻辑,不会出现兼容性问题。
  • 你可以通过调整\vskip1em的值来修改标题与图片、图片与作者之间的间距,1em可替换为其他长度单位(如0.5cm)。

内容的提问来源于stack exchange,提问作者jms202

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 17:48:15