> For the complete documentation index, see [llms.txt](https://overleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://overleaf-pro.ayaka.space/latex/zh-cn/wen-da/04-can-i-add-inline-or-margin-comments-to-the-pdf.md).

# 我可以在 PDF 中添加行内或页边注释吗？

是的，你可以使用 [`todonotes` 宏包](https://ctan.org/pkg/todonotes?lang=en) （此处已涵盖）或阅读我们关于 [旁注](/latex/zh-cn/ge-shi-hua/15-margin-notes.md)，其中讨论了 [`\marginpar` 命令](/latex/zh-cn/ge-shi-hua/15-margin-notes.md#the-5cmarginpar-command) 和 [`marginnote` 宏包](/latex/zh-cn/ge-shi-hua/15-margin-notes.md#an-alternative-to-5cmarginpar-the-marginnote-package).

## 加载 todonotes 宏包

要使用 `todonotes` 宏包，请将以下一行添加到文档导言区：

```latex
\usepackage[colorinlistoftodos]{todonotes}
```

该 `colorinlistoftodos` 选项会在待办事项列表中添加小的彩色方块（见下文），有助于区分不同类型。

* **注意**：强烈建议读者浏览 [`todonotes` 文档](http://mirrors.ctan.org/macros/latex/contrib/todonotes/todonotes.pdf) ，以了解宏包选项、实用命令和有帮助的示例。

使用以下命令添加注释：

```latex
\todo{这是一条会显示在边距中的注释}
```

## 使用 todonotes 宏包的示例

下面是一个基础示例，帮助你快速上手：它展示了多种注释样式，并通过命令生成待办事项列表

```latex
\listoftodos[你的列表标题...]
```

它接受一个可选参数，括在 `[...]`中，用于排版注释列表的标题。

```latex
\documentclass[a4paper]{article}
\usepackage[colorlinks]{hyperref}
\usepackage[colorinlistoftodos]{todonotes}
\begin{document}
\listoftodos[我需要完成的事项列表]

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nulla
\todo{普通待办注释。} urna. Maecenas interdum nunc in augue.
Mauris quis massa in ante tincidunt mollis. Proin imperdiet.
Donec porttitor pede id est. Sed in ante. Integer id arcu. Nam
lectus nisl, posuere sit amet, imperdiet ut, tristique ac, lorem.
In erat. In commodo enim. \todo[color=blue!40]{不同颜色的待办注释。}%
Phasellus libero ipsum, tempor a, pharetra consequat, pellentesque
sit amet, sem. Praesent ut augue luctus elit adipiscing ultricies.
Vestibulum suscipit cursus leo. Nullam molestie justo.

Morbi dui. Morbi convallis mi sed sem. Nulla convallis lacus vitae
risus. Phasellus adipiscing. Nullam tortor. Sed laoreet aliquam
ante. Vestibulum diam. Pellentesque nec leo. Pellentesque velit.
\todo[nolist]{仅在边距中显示而不在
待办列表中显示的待办注释。}%
Praesent congue mi eu ipsum cursus fringilla. Etiam leo erat,
tristique et, pharetra eget, mollis vitae, velit. In hac habitasse
\todo[size=\small, color=green!40]{一个小字号的注释。}%
platea dictumst. In quam nibh, facilisis et, laoreet non, facilisis
tempus, justo. Class aptent taciti sociosqu ad litora torquent per
conubia nostra, per inceptos himenaeos.

\todo[inline]{测试 测试}

Donec nulla lectus, faucibus sit amet, auctor non, consectetuer
quis, pede. Nullam dictum. Nullam suscipit, ligula in scelerisque
\todo[noline]{不带返回正文连线的注释。}%
posuere, sapien purus rutrum magna, vitae pharetra leo quam vel
tortor. Donec eleifend condimentum sapien. Etiam sed orci. Aliquam
\todo[inline, color=red!50]{行内待办注释。}%
tempor. Pellentesque egestas tortor id eros. Donec mauris justo,
commodo id, pellentesque id, eleifend non, mi. Duis venenatis
sagittis metus. Donec tempus metus id lacus. Praesent vel diam.
Morbi nec ante. Vestibulum varius felis ac lacus. Nulla vitae neque
\todo[inline, color=green!40]{不带返回正文连线的注释。}%
in nibh bibendum volutpat. Quisque accumsan diam. Aenean ultricies
nisl ac lacus. Aliquam posuere. Aenean venenatis tortor in felis.
\end{document}
```

&#x20;在 Overleaf 中打开此示例

此示例生成以下输出：

![在 Overleaf 上演示 todonotes 宏包](/files/e659b76db6ac554600dc85d0b0262545f3bc43cd)

## 进一步阅读

* 该 [`todonotes` 文档](http://mirrors.ctan.org/macros/latex/contrib/todonotes/todonotes.pdf) 包含宏包选项、实用命令和有帮助的示例信息。
* Overleaf 上关于 [旁注](/latex/zh-cn/ge-shi-hua/15-margin-notes.md) 讨论了 [`\marginpar` 命令](/latex/zh-cn/ge-shi-hua/15-margin-notes.md#the-5cmarginpar-command) 和 [`marginnote` 宏包](/latex/zh-cn/ge-shi-hua/15-margin-notes.md#an-alternative-to-5cmarginpar-the-marginnote-package).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://overleaf-pro.ayaka.space/latex/zh-cn/wen-da/04-can-i-add-inline-or-margin-comments-to-the-pdf.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
