> 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/75-inserting-emojis-in-latex-documents-on-overleaf.md).

# 在 Overleaf 文档中插入 emoji

*注意： `[twemojis](https://www.ctan.org/pkg/twemojis)` 软件包不包含在* [*TeX Live*](/latex/zh-cn/lei-wen-jian/02-overleaf-and-tex-live.md)*中，因此无法在 Overleaf 上使用。*

## Emoji 字符和 Overleaf 编辑器

Overleaf 不能存储包含以下内容的文件： [NUL 字符](https://en.wikipedia.org/wiki/Null_character) 或编辑包含 Unicode 的 [基本多文种平面（BMP）](https://en.wikipedia.org/wiki/Plane_\(Unicode\)).

Unicode 将许多 emoji 字符分配到了基本多文种平面之外的码位：它们编码在 [第 1 平面](https://en.wikibooks.org/wiki/Unicode/Character_reference/1F000-1FFFF)中，这意味着它们的码位范围是 U+10000–U+1FFFF，具体为 U+1F000–U+1FFFF。这对任何希望将 emoji 字符复制并粘贴到 Overleaf 编辑器中的人都有一个重要影响。目前，Overleaf 的文本编辑器只能处理基本多文种平面内的字符，不过我们希望未来的升级能引入对非 BMP 字符的支持。

如果你将 😀 之类的 emoji，或任何其他非 BMP 字符，粘贴到 Overleaf 编辑器中，它会被转换为字符 ��。不过，你可以上传包含非 BMP UTF-8 序列的文本文件：这些文件不能在 Overleaf 编辑器中直接编辑，但你可以使用适当的 LaTeX 文件包含命令将这些文件插入到文档中。

如下面的示例所示，你可以使用 LaTeX 软件包提供的合适字体和命令插入 emoji。

## 单色 emoji

你可以使用 `\symbol` 或 `\char` 命令与 `fontspec`, [XƎLaTeX 或 LuaLaTeX](/latex/zh-cn/zhi-shi-ku/026-changing-compiler.md) 以及合适的字体。例如，不使用 [`emoji` 宏包](https://ctan.org/pkg/emoji?lang=en)，你仍然可以使用 Symbola 字体插入单色 emoji：

```latex
飘落的叶子：{\fontspec{Symbola}\symbol{"1F343}}

或

落叶：{\fontspec{Symbola}\char"1F343}
```

&#x20;[在 Overleaf 中打开此单色 emoji 示例](https://www.overleaf.com/docs?engine=lualatex\&snip_name=Monochrome+emoji\&snip=%5Cdocumentclass%5B12pt%5D%7Barticle%7D%0A%5Cusepackage%7Bfontspec%7D%0A%5Cusepackage%7Bparskip%7D%0A%0A%5Cbegin%7Bdocument%7D%0AFalling+leaves%3A+%7B%5Cfontspec%7BSymbola%7D%5Csymbol%7B%221F343%7D%7D%0A%0Aor%0A%0AFalling+leaves%3A+%7B%5Cfontspec%7BSymbola%7D%5Cchar%221F343%7D%0A%5Cend%7Bdocument%7D)

这将得到如下输出 ![Symbola-falling-leaves.png](/files/5a715560f205cad74daf455db668bea2f54bae8d)

你可以在以下位置查找 emoji 的码位： [这个网页](https://unicode.org/emoji/charts/emoji-list.html).

## 彩色 emoji

如果你想使用彩色 emoji，请看看 `[emoji](https://www.ctan.org/pkg/emoji)` 软件包，它使用 LuaLaTeX + HarfBuzz 文本排版引擎来正确访问彩色 emoji 字体。你需要 [将项目的编译器改为 LuaLaTeX](/latex/zh-cn/zhi-shi-ku/026-changing-compiler.md)。然后你就可以加载 `emoji` 包，并写入 `\emoji{leaves}`.

```latex
\documentclass[12pt]{article}
\usepackage{emoji}

\begin{document}

以下是使用 \texttt{emoji} 软件包和 LuaLaTeX 的彩色 emoji：
\emoji{leaves}
\emoji{rose}

你可以使用 emoji 修饰符：
\emoji{woman-health-worker-medium-skin-tone}
\emoji{family-man-woman-girl-boy}
\emoji{flag-malaysia}
\emoji{flag-united-kingdom}

\end{document}
```

&#x20;[在 Overleaf 中查看此实时示例](https://www.overleaf.com/docs?engine=lualatex\&snip_name=colour+emojis+using+LuaLaTeX\&snip=%5Cdocumentclass%5B12pt%5D%7Barticle%7D%0A%5Cusepackage%7Bemoji%7D%0A%0A%5Cbegin%7Bdocument%7D%0A%0AThese+are+colour+emojis+using+the+%5Ctexttt%7Bemoji%7D+package+and+LuaLaTeX%3A%0A%5Cemoji%7Bleaves%7D%0A%5Cemoji%7Brose%7D%0A%0AYou+can+use+emoji-modifiers%3A%0A%5Cemoji%7Bwoman-health-worker-medium-skin-tone%7D%0A%5Cemoji%7Bfamily-man-woman-girl-boy%7D%0A%5Cemoji%7Bflag-malaysia%7D%0A%5Cemoji%7Bflag-united-kingdom%7D%0A%0A%5Cend%7Bdocument%7D)

![NotoEmoji-demo.png](/files/07b614bda376b1a34e6a143f12b4db8f9d40ba74)

你可以查询 Unicode CLDR（通用区域设置数据存储库）名称 [这里](https://unicode.org/emoji/charts/emoji-list.html)，但请记得将名称中的空格替换为连字符。或者，你也可以查看 [该 `emoji` 包文档](http://texdoc.net/pkg/emoji) 本身。

## 选择不同的 emoji 字体

在 Overleaf 中，默认的 emoji 字体是 Noto Color Emoji。你可以选择其他 emoji 字体：

```latex
\setemojifont{TwemojiMozilla}
```

![TwemojiMozilla-demo.png](/files/bf3b9ae57fc9ffb164f1c384dd159c11a3c454f8)

```latex
\documentclass[12pt]{article}
\usepackage{emoji}

\begin{document}
\setemojifont{TwemojiMozilla}
以下是使用 \texttt{emoji} 软件包和 LuaLaTeX 的彩色 emoji：
\emoji{leaves}
\emoji{rose}

你可以使用 emoji 修饰符：
\emoji{woman-health-worker-medium-skin-tone}
\emoji{family-man-woman-girl-boy}
\emoji{flag-malaysia}
\emoji{flag-united-kingdom}

\end{document}
```

&#x20;[在 Overleaf 中打开此 TwemojiMozilla 示例](https://www.overleaf.com/docs?engine=lualatex\&snip_name=Colour+emojis+using+the+TwemojiMozilla+font+and+LuaLaTeX\&snip=%5Cdocumentclass%5B12pt%5D%7Barticle%7D%0A%5Cusepackage%7Bemoji%7D%0A%0A%5Cbegin%7Bdocument%7D%0A%5Csetemojifont%7BTwemojiMozilla%7D%0AThese+are+colour+emojis+using+the+%5Ctexttt%7Bemoji%7D+package+and+LuaLaTeX%3A%0A%5Cemoji%7Bleaves%7D%0A%5Cemoji%7Brose%7D%0A%0AYou+can+use+emoji-modifiers%3A%0A%5Cemoji%7Bwoman-health-worker-medium-skin-tone%7D%0A%5Cemoji%7Bfamily-man-woman-girl-boy%7D%0A%5Cemoji%7Bflag-malaysia%7D%0A%5Cemoji%7Bflag-united-kingdom%7D%0A%0A%5Cend%7Bdocument%7D)

## 进一步阅读

* [该 `emoji` 宏包](https://www.ctan.org/pkg/emoji)
* [emoji CLDR 名称和码位列表](https://unicode.org/emoji/charts/emoji-list.html)
* [更改 Overleaf 项目的编译器](/latex/zh-cn/zhi-shi-ku/026-changing-compiler.md)


---

# 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/75-inserting-emojis-in-latex-documents-on-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.
