> For the complete documentation index, see [llms.txt](https://ayakaleaf-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://ayakaleaf-pro.ayaka.space/latex/zh-cn/zhi-shi-ku/075-how-to-paste-formatted-content-into-overleaf.md).

# 如何将格式化内容粘贴到 Overleaf 中

*请注意：粘贴带格式内容是一项新功能，我们正在持续改进，以确保它在多种场景下都能良好工作。我们也非常欢迎你对此提出反馈，你可以在* [*此调查问卷*](https://docs.google.com/forms/d/e/1FAIpQLSc7WcHrwz9fnCkUP5hXyvkG3LkSYZiR3lVJWZ0o6uqNQYrV7Q/viewform)*.*

你可以粘贴带格式内容，包括 [表格](#pasting-tables-into-your-overleaf-project), [图片](#pasting-images-into-your-overleaf-project), [带样式文本](#pasting-styled-text-into-your-overleaf-project)、以及 [列表](#pasting-lists-into-your-overleaf-project) 到我们的 **可视化编辑器** 并使用 Ctrl+V（在 Windows/Linux 上）或 Cmd+V（在 MacOS 上）保留格式。

你粘贴的内容将在 **可视化编辑器** 而在 **代码编辑器** 你将能够看到 Overleaf 为你生成的 LaTeX 代码。（不要试图将格式化文本粘贴到 **代码编辑器** 里哦！）

你可以将内容粘贴到 **可视化编辑器** 从多种来源，包括 Google 文档， [Microsoft 365](https://www.microsoft.com/en-us/microsoft-365) （原 Microsoft Office）， [LibreOffice](https://www.libreoffice.org/)，以及网站。目前不支持从 PDF 文档中粘贴带格式内容。为了使用微软工具获得最佳效果，请使用在线版本，不过桌面应用程序也同样支持。

在将带格式内容粘贴到 **可视化编辑器**之后，你会看到一个下拉菜单，可让你将粘贴的（带格式）内容改回纯文本（无格式）：

![格式化文本粘贴到 Overleaf 时显示的菜单图片"](/files/2498350a347c0d5f78ebee90f101c4c2db1154c9)

* **无格式粘贴** 将格式化文本转换为纯文本。
* **带格式粘贴** 切换回带格式文本。

## 粘贴纯文本

你可以粘贴 *无格式纯文本* 到 **可视化编辑器** 或 **代码编辑器** 通过使用以下组合键：

* Windows/Linux: Ctrl+Shift+V
* MacOS: Cmd+Shift+V

## 所需的 LaTeX 宏包

为了支持将图片和其他内容粘贴到 Overleaf，你需要将以下宏包添加到你的 [LaTeX 文档导言区](/latex/zh-cn/latex-ji-chu/01-learn-latex-in-30-minutes.md#the-preamble-of-a-document):

* [`hyperref`](https://ctan.org/pkg/hyperref?lang=en)：用于支持 [超链接](/latex/zh-cn/wen-dang-jie-gou/09-hyperlinks.md) 中包含的内容。
* [`graphicx`](https://ctan.org/pkg/graphicx)：提供 [`\includegraphics` 命令](/latex/zh-cn/latex-ji-chu/01-learn-latex-in-30-minutes.md#adding-images) 使用粘贴到你项目中的图形所需的支持。

## 将表格粘贴到你的 Overleaf 项目中

**可视化编辑器** 无法完全保留粘贴到你项目中的每个表格的形式和样式，但你仍然可以通过粘贴在其他应用程序中创建的各种表格来节省时间和精力。

**可视化编辑器** 尝试保留并预览以下表格元素：

* 水平合并的单元格（跨越多列）
* 应用于单元格的边框
* 表格单元格内文本的格式
* 表格标题和表头

**可视化编辑器** 还可以让你 [修改粘贴的表格](/latex/zh-cn/zhi-shi-ku/067-how-to-generate-and-insert-latex-tables-in-overleaf.md#editable)，例如编辑单元格内容或添加行和列。你也可以切换到 **代码编辑器** 进行修改，包括设置控制表格的 LaTeX 参数 [在排版文档中的位置](https://learn.overleaf.com/learn/Inserting_Images#Positioning).

### 粘贴表格示例

以下视频演示了从维基百科粘贴表格——请注意超链接和文本样式是如何保留的。

{% embed url="<https://videos.ctfassets.net/nrgyaltdicpt/2ENPw4QceCpzglQafnkFWU/f7be441c53822a37aa9d9d192fd43410/PastedTable.mp4>" %}

## 将图片粘贴到你的 Overleaf 项目中

你可以将单张图片粘贴到 **可视化编辑器** 和 **代码编辑器** （但仅 **可视化编辑器** 提供图片预览）。 [粘贴多张图片](#can-i-paste-multiple-images) 目前不受支持。

![显示“从电脑上传”弹窗窗口的图片](/files/c4679533d10bf031eb9353ff5c27aaa707e63d05)

你可以：

* 为用于保存粘贴图片的文件命名。
* 选择保存它的项目文件夹。
* 决定是否使用图注。
* 决定是否包含标签（用于引用表格）。
* 配置图片宽度（作为……的一个分数 `\\linewidth`).

你粘贴的任何图片都会以 .png 文件的形式保存在你的 Overleaf 项目中。随后，它会通过自动生成的 LaTeX 代码插入到你的文档中。 **可视化编辑器** 将提供粘贴图片的预览，但 **代码编辑器** 只会显示 LaTeX 代码。

### 粘贴图片示例

图片可以从许多来源复制，包括网页，但这个视频片段演示了从 [GIMP](https://www.gimp.org/) 并将其粘贴到 **可视化编辑器**。请注意使用了 **代码编辑器** 来设置自定义图片宽度为 `0.85\linewidth`.

{% embed url="<https://videos.ctfassets.net/nrgyaltdicpt/3v01l6iGqXyAD4zaSosGbN/be53d9dad5fa4cb95b8177ec69c01cf3/PastingAnImage.mp4>" %}

视频演示中使用的图片复制自一篇 [关于人口密度的维基百科条目](https://en.wikipedia.org/wiki/World_population#/media/File:Population_Density,_v4.11,_2020_\(48009093621\).jpg).

## 将带样式文本粘贴到你的 Overleaf 项目中

为保留下面列出的项目的格式，请将它们粘贴到 Overleaf 的 **可视化编辑器** 中，使用 Ctrl+V（在 Windows/Linux 上）或 Cmd+V（在 MacOS 上）：

* 标题
* **粗体文本**
* *斜体文本*
* [超链接](http://www.google.com)
* 代码块（例如用 `HTML 中的标签包裹）`
* `符号，例如：&、%、…、$50.00`

` 粘贴带格式文本示例。下一个视频片段演示了从 Google 文档复制并粘贴带格式文本。将列表粘贴到你的 Overleaf 项目中。项目符号列表和编号列表可以粘贴到 Overleaf 的`` `` `**`可视化编辑器`**` `` ``使用 Ctrl+V（在 Windows/Linux 上）或 Cmd+V（在 MacOS 上）。粘贴列表示例。下一个视频片段演示了从浏览器页面和 LibreWriter 文档复制并粘贴多级项目符号和编号列表。请注意，粗体和斜体文本也得到了保留。描述列表。可视化编辑器还支持创建和编辑描述列表。关于粘贴带格式内容的常见问题。我可以使用拖放吗？ `**`可视化编辑器`**` ``支持使用拖放上传 .png、.jpg 或 .pdf 格式的图片，但不能用于添加带格式内容，带格式内容必须通过粘贴方式添加。我可以粘贴多张图片吗？目前还不能同时将多张图片粘贴到`` `**`可视化编辑器`**` ``或`` `**`代码编辑器`**`。如果你粘贴的内容包含多张图片，则只会粘贴文本部分。图片必须逐个粘贴，这样的好处是你可以分别对每一张进行配置。`


---

# 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://ayakaleaf-pro.ayaka.space/latex/zh-cn/zhi-shi-ku/075-how-to-paste-formatted-content-into-overleaf.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.
