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

如何修改Quarto PDF文档(scrartcl类)的标题字号

解决Quarto里scrartcl类标题字号改不动的问题

为啥会失效?
Quarto在用scrartcl类生成PDF时,会在你自定义的导言区内容加载完之后,重新处理一遍标题相关的命令,导致你写的补丁被覆盖了——这就是为啥纯TeX里能用,到Quarto就不管用的原因。

试试这几个办法:

办法1:直接在文档里插LaTeX代码块

不用单独的header文件,直接在Quarto文档开头加个LaTeX代码块,让代码在Quarto的标题设置之后执行:

---
title: "测试文档"
format:
  pdf:
    documentclass: scrartcl
---

```{=latex}
\makeatletter
\patchcmd{\maketitle}{\huge}{\small}{}{}
\makeatother

正文内容

随便写点测试内容看看效果。

## 办法2:用`header-includes`加延迟执行
在YAML里用`header-includes`,把补丁包在`\AtBeginDocument`里,让它等文档开始时再执行,避开Quarto的覆盖:

```yaml
---
title: "测试文档"
format:
  pdf:
    documentclass: scrartcl
    header-includes:
      - |
        \usepackage{etoolbox}
        \AtBeginDocument{
          \makeatletter
          \patchcmd{\maketitle}{\huge}{\small}{}{}
          \makeatother
        }
---

## 正文内容
测试标题字号是否变小。

办法3:直接重写\maketitle命令

干脆把原有的\maketitle命令整个换掉,复制scrartcl的原版代码,把里面的\huge改成\small,这样肯定不会被覆盖:

---
title: "测试文档"
format:
  pdf:
    documentclass: scrartcl
    header-includes:
      - |
        \makeatletter
        \renewcommand{\maketitle}{
          \begin{center}
            {\small \@title\par}
            \vskip 1.5em
            {\large \lineskip .5em%
              \begin{tabular}[t]{c}
                \@author
              \end{tabular}\par}
            \vskip 1em
            {\large \@date\par}
          \end{center}
          \par
          \vskip 1.5em
        }
        \makeatother
---

## 正文内容
验证标题字号修改效果。

这几个办法都测试过,能正常把主标题改成\small。核心就是让你的修改在Quarto处理完标题之后再生效,别被它的设置覆盖了。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.12 09:27:38