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

如何在Quarto PDF文档左上角添加大学Logo?

在Quarto中将大学Logo放置在文档左上角的解决方案

你当前的配置用了titling包但把图片放在了居中环境里,所以无法调整到左上角。以下几种方法可以实现需求:

方法1:修改titling包的标题前置设置

去掉原配置里的center环境,改用左对齐的flushleft,同时可调整垂直位置:

---
title: "test"
header-includes:
- \usepackage{titling}
# 左对齐放置Logo,用\\[-\baselineskip]调整与标题的间距
- \pretitle{\begin{flushleft}\LARGE\includegraphics[width=4cm]{nantesuniv.png}\\[-\baselineskip]}
- \posttitle{\end{flushleft}}
output: 
  pdf_document:
    toc: true
format: pdf
documentclass: report
papersize: letter
---

这种方法适合仅在标题页左上角放置Logo的场景。

方法2:用textpos包做绝对定位

如果需要更精确控制Logo的位置(比如距离页面边缘的具体厘米数),可以用textpos包:

---
title: "test"
header-includes:
- \usepackage{textpos}
# 设置定位单位为厘米,网格大小可按需调整
- \TPGrid[1cm,1cm]{20}{20}
# 在页面左上角(x=1cm,y=1cm)放置宽度4cm的Logo
- \AtBeginDocument{\begin{textblock}{4}(1,1)\includegraphics[width=4cm]{nantesuniv.png}\end{textblock}}
output: 
  pdf_document:
    toc: true
format: pdf
documentclass: report
papersize: letter
---

括号里的(1,1)代表x轴1cm、y轴1cm的位置,你可以根据需求修改数值。

如果需要每一页的左上角都显示Logo,适合用页眉设置:

---
title: "test"
header-includes:
- \usepackage{fancyhdr}
- \pagestyle{fancy}
# 清空默认页眉页脚内容
- \fancyhf{}
# 将Logo放在页眉左侧(左上角)
- \lhead{\includegraphics[width=3cm]{nantesuniv.png}}
# 如果只需要第一页显示,替换成\thispagestyle{fancy}
- \AtBeginDocument{\pagestyle{fancy}}
output: 
  pdf_document:
    toc: true
format: pdf
documentclass: report
papersize: letter
---

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.02 21:45:34