惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

宝玉的分享
宝玉的分享
NISL@THU
NISL@THU
E
Exploit-DB.com RSS Feed
L
LINUX DO - 热门话题
L
Lohrmann on Cybersecurity
K
Kaspersky official blog
Project Zero
Project Zero
Cisco Talos Blog
Cisco Talos Blog
T
The Exploit Database - CXSecurity.com
P
Palo Alto Networks Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
S
Schneier on Security
G
GRAHAM CLULEY
The Hacker News
The Hacker News
T
Threat Research - Cisco Blogs
Scott Helme
Scott Helme
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
P
Privacy & Cybersecurity Law Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Cyberwarzone
Cyberwarzone
C
CERT Recently Published Vulnerability Notes
T
Tor Project blog
AWS News Blog
AWS News Blog
Simon Willison's Weblog
Simon Willison's Weblog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
爱范儿
爱范儿
P
Privacy International News Feed
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
S
Securelist
G
Google Developers Blog
The Last Watchdog
The Last Watchdog
Google Online Security Blog
Google Online Security Blog
美团技术团队
F
Fortinet All Blogs
小众软件
小众软件
Recorded Future
Recorded Future
V
Visual Studio Blog
B
Blog RSS Feed
H
Help Net Security
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Google DeepMind News
Google DeepMind News
Blog — PlanetScale
Blog — PlanetScale
博客园 - 聂微东
Stack Overflow Blog
Stack Overflow Blog
Martin Fowler
Martin Fowler
Latest news
Latest news
Spread Privacy
Spread Privacy
H
Heimdal Security Blog

博客园 - marsggbo

Eurosys26 | FineMoE如何用「细粒度」打破MoE推理的显存-延迟死局 LoRA fine-tune吞吐量提升1.96倍!LoRAFusion如何把内存带宽浪费和pipeline bubble一起干掉 Fast26 | LLM 推理启动慢?华为用一个「可编程 Page Cache」把模型加载砍了 79% KV Cache 的两层存储到底卡在哪?FAST'26 这篇论文给出了答案 NeurIPS24 | 把Dense LLM变身MoE还提速 ICML25 | EPIC:KV Cache 复用的「编译-链接」范式(附可运行代码复现) KV Cache 复用的第三条路:FAST 2026 CacheSlide 是怎么解决 Agent 推理的位置漂移问题的 MoE 推理的内存墙,被一块多芯粒芯片打穿了? KVCOMM:让多 Agent 系统的 KV Cache 真正“通起来”,TTFT 直接砍掉 7.8 倍 NSDI26 | DroidSpeak让不同 LLM 之间共享 KV Cache TokenDance 解决多 Agent LLM 推理的 KV Cache 冗余问题 当 AI 开始学会"记住":LLM Agent 记忆系统的统一视角 【转载】ACM MM 投稿论文模板修改成投稿模式 尝试从源头理解 SVD 原理和计算 LLM 场景下的强化学习技术扫盲 Tmux ctrl+B快捷键失效处理办法 对抗训练综述学习笔记 【转知乎回答】一文看懂 LLaMA 中的旋转式位置编码(Rotary Position Embedding) 二进制中为什么负数是正数取反再加一 leetcode 常见题型代码总结 Prompt-Tuning、P-Tuning和Prefix-Tuning区别和代码实现【转】 Deepspeed ZeRO系列算法原理+通信开销详解 NSCC集群使用笔记 Huggingface Transformers实现张量并行的小坑 set/get_output_embeddings Pytorch 如何使用 storage 实现参数 offload? TACC 集群使用笔记 图解 vLLM 的推理调度策略 大模型推理框架 vLLM 源码解析(二):Block 模块分配和管理 OpenAI 的视频生成大模型Sora的核心技术详解(一):Diffusion模型原理和代码详解 大模型推理框架 vLLM 源码解析(一)
解决 Overleaf 中插入 PDF 图片失败的问题:排查与修复
marsggbo · 2025-04-19 · via 博客园 - marsggbo

在写科研文稿时,我们经常需要插入结构图、模型图等 PDF 格式的矢量图。但在 Overleaf 中,我遇到了一个较难定位的问题:使用 \includegraphics 插入 PDF 图片时,编译无报错,但无法显示图片甚至生成 PDF 文件失败。提示如下信息

No PDF
This compile didn’t produce a PDF. This can happen if:
There is an unrecoverable LaTeX error. If there are LaTeX errors shown below or in the raw logs, please try to fix them and compile again.
The document environment contains no content. If it’s empty, please add some content and compile again.
This project contains a file called output.pdf. If that file exists, please rename it and compile again.

本文记录这一问题的背景、排查过程与最终解决方案,希望对遇到类似问题的用户有所帮助。


1. 问题背景

文档中使用如下方式插入图像:

\usepackage{graphicx}
\graphicspath{{figures/.../}}

...

\begin{figure}
    \centering
    \includegraphics[width=\linewidth]{prune_structure.pdf}
    \caption{结构化剪枝示意图}
    \label{fig:pruning}
\end{figure}

其中 prune_structure.pdf 是一张矢量格式的图像,在本地查看没有问题,并没有损坏。

2. 问题现象

在 Overleaf 中:
• 使用 Fast Compile 模式时,文档可以编译成功,但图片显示为空白;
• 使用 Normal Compile 模式时,编译直接失败,并提示:

This compile didn’t produce a PDF.

日志中没有明确的错误信息,定位困难。

3. 排查过程

以下是我尝试过的排插步骤:

    1. 确认路径正确:
    • 日志显示图像被正确找到:File: figures/.../prune_structure.pdf Graphic file (type pdf)
    1. 注释图像代码:
    • 注释掉 figure 环节后,PDF 成功生成,说明问题出在图像本身。
    1. 确认 PDF 未损坏:
    • 图片可以在本地打开,也可以在 Overleaf 文件预览中正常显示,说明文件不是损坏的。
    1. 加入调试信息:
    • 添加 \listfiles,确认使用的是 XeLaTeX,图像类型正确,依然无法定位问题。

原因分析

最后问 chatgpt 和上网查资料,终于找到这个诡异的问题的原因了,就是因为Overleaf 使用 XeLaTeX 编译时,某些 PDF 图像的边界框信息(bounding box / crop box)不规范,可能会导致渲染器加载失败。特别是使用某些工具导出的图(如绘图工具、Python 库等)经常出现这种兼容性问题。这个问题光靠肉眼去检查 PDF 根本不可能看出来。折腾了我一上午这破玩意。

4. 解决方案:使用 pdfcrop 清理边界信息

我用的是Macbook,所以好像自带 pdfcrop命令。使用如下命令重新生成裁剪后的 PDF:

pdfcrop -xetex prune_structure.pdf
mv prune_structure-crop.pdf prune_structure.pdf

这样处理后,重新上传至 Overleaf,即可成功插入图像并正常编译生成 PDF。

每次都这么敲键盘怪累的,我们可以自动化命令简化操作。只需要把下面的代码添加到 .bashrc 或 .zshrc,我用的是后者:

# ~/.zshrc
pdfclean() {
    if [ $# -ne 1 ]; then
        echo "Usage: pdfclean <filename.pdf>"
        return 1
    fi
    local input="$1"
    local base="${input%.pdf}"
    pdfcrop -xetex "$input" "${base}-crop.pdf" && mv "${base}-crop.pdf" "$input"
}

然后使用:

pdfclean prune_structure.pdf

即可一键清理图像并替换原文件。

5. 总结

当 Overleaf 中插入 PDF 图片后出现“无错误但无法显示”或“编译失败”的现象时,建议优先考虑图片的边界信息问题。使用 pdfcrop -xetex 是一个有效且高效的解决方案,能显著提高在线 LaTeX 平台对 PDF 图像的兼容性。

参考