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

如何在LaTeX中用\includepdf插入的PDF页面上添加内容?

在插入的PDF页面添加自定义文本(基于pdfpages包)

你可以直接在pagecommand参数中写入任意LaTeX内容,不局限于页码。下面是几种实用的实现方式:

1. 简单添加固定位置文本

如果只需要在某个大致位置添加文本,比如居中偏上/下,可以用垂直间距调整位置:

\usepackage{pdfpages}

\begin{document}
% 插入外部PDF第1页,同时添加居中的大字号文本
\includepdf[
    pages=1,
    pagecommand={
        \centering
        \vspace*{6cm} % 调整这个值改变垂直位置
        \Huge \textbf{这是自定义的水印文本}
        % 保留页码
        \vfill
        \thispagestyle{plain}
    }
]{你的外部PDF文件.pdf}
\end{document}

2. 精确定位文本(textpos包)

用textpos包可以通过坐标精准控制文本位置:

\usepackage{pdfpages}
\usepackage[absolute,overlay]{textpos} % 启用绝对定位

\begin{document}
\includepdf[
    pages=1,
    pagecommand={
        % 定义文本块:宽度12cm,位置(3cm, 10cm)(从页面左上角开始计算)
        \begin{textblock*}{12cm}(3cm,10cm)
            \large \textcolor{blue}{精准定位在这里的文本}
        \end{textblock*}
        % 保留原有页码样式
        \thispagestyle{your-custom-pagestyle}
    }
]{你的外部PDF文件.pdf}
\end{document}

3. 更灵活的定位(tikz包)

tikz支持基于页面相对位置的定位(比如页面中心、角落),适合需要自适应页面的场景:

\usepackage{pdfpages}
\usepackage{tikz}

\begin{document}
\includepdf[
    pages=1,
    pagecommand={
        \begin{tikzpicture}[remember picture,overlay]
            % 在页面中心添加红色大文本
            \node at (current page.center) {\Huge \textcolor{red}{居中提示文本}};
            % 在右下角添加小文本,偏移1cm
            \node at (current page.south east) [anchor=south east, xshift=-1cm, yshift=1cm] {右下角标注};
        \end{tikzpicture}
        % 保留页码
        \thispagestyle{plain}
    }
]{你的外部PDF文件.pdf}
\end{document}

关键提示

  • pagecommand里可以写任何合法的LaTeX代码,包括字体大小、颜色、段落格式等
  • 如果需要保留原文档的页码样式,记得加入\thispagestyle{你的页码样式}(比如plain、fancy等)
  • 定位时,textpos适合固定坐标,tikz适合相对页面位置的自适应定位

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.25 07:22:30