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

# 在 Overleaf 的 LaTeX 文档中插入表情符号

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

## 表情符号字符和 Overleaf 编辑器

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

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

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

如下面的示例所示，你可以使用 LaTeX 宏包提供的合适字体和命令来插入表情符号。

## 单色表情符号

你可以使用 `\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 字体插入单色表情符号：

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

或

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

[在 Overleaf 中打开此单色表情符号示例](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)

你可以在 [这个网页](https://unicode.org/emoji/charts/emoji-list.html).

## 彩色表情符号

如果你想使用彩色表情符号，请看看 `[emoji](https://www.ctan.org/pkg/emoji)` 宏包，它使用 LuaLaTeX + HarfBuzz 文本排版引擎来正确访问彩色表情符号字体。你需要 [将项目的编译器改为 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{leaves}
\emoji{rose}

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

\end{document}
```

[在 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（Common Locale Data Repository）名称 [这里](https://unicode.org/emoji/charts/emoji-list.html)，但请记得把名称中的空格替换为连字符。或者，你也可以在 [该 `emoji` 宏包文档](http://texdoc.net/pkg/emoji) 本身中查找。

## 选择不同的表情符号字体

在 Overleaf 中，默认的表情符号字体是 Noto Color Emoji。你可以选择不同的表情符号字体：

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

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

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

\begin{document}
\setemojifont{TwemojiMozilla}
以下是使用 \texttt{emoji} 宏包和 LuaLaTeX 的彩色表情符号：
\emoji{leaves}
\emoji{rose}

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

\end{document}
```

[在 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)
* [表情符号 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://ayakaleaf-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.
