> 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/latex-wen-ti/01-how-can-i-typeset-text-in-cyrillic-e.g.-in-russian.md).

# 如何用西里尔字母排版文本（例如俄语）？

## 引言

要在 Overleaf 中排版西里尔文文本，你需要加载一些额外的宏包——具体使用哪些宏包取决于你所使用的编译器：pdfLaTeX、XeLaTeX、LuaLaTeX 或 LaTeX（即 DVI 转 PDF）。

## 使用 pdfLaTeX 或 LaTeX 排版西里尔文

如果你使用 pdfLaTeX 或 LaTeX 作为编译器，那么下面的做法可行：

```latex
\documentclass{article}
\usepackage[T2A,T1]{fontenc}
\usepackage[main=english,russian]{babel}
\begin{document}
这是英文，这里是俄文：\textcyrillic{Здравствуй, мир!}
\end{document}
```

[在 Overleaf 中打开此 `pdfLaTeX` Overleaf 中的示例。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Typesetting+Cyrillic+text\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%5BT2A%2CT1%5D%7Bfontenc%7D%0A%5Cusepackage%5Bmain%3Denglish%2Crussian%5D%7Bbabel%7D%0A%5Cbegin%7Bdocument%7D%0AThis+is+English+and+this+is+Russian%3A+%5Ctextcyrillic%7B%D0%97%D0%B4%D1%80%D0%B0%D0%B2%D1%81%D1%82%D0%B2%D1%83%D0%B9%2C+%D0%BC%D0%B8%D1%80%21%7D%0A%5Cend%7Bdocument%7D)

此示例生成以下输出：

![LaTeX 中排版的俄文西里尔字母](/files/239e239b7109d5a84f823820e82f87911bfe2963)

## 使用 XeLaTeX 或 LuaLaTeX 排版西里尔文

XeLaTeX 和 LuaLaTeX 编译器内置支持 UTF-8 编码文本，因此无需使用 `\inputenc` 宏包（`\usepackage[utf8]{inputenc}`。自 2018 年以来，也不再需要使用 `\usepackage[utf8]{inputenc}` 在 pdfLaTeX 中也是如此——请参见 [《LaTeX News》2018 年 4 月刊](https://www.latex-project.org/news/2018/04/10/issue28-of-latex2e-news-released/) 以及 Overleaf 博客文章 [*TeX Live 升级——2019 年 9 月*](https://www.overleaf.com/blog/tex-live-upgrade-september-2019).

对于 XeLaTeX 或 LuaLaTeX， [`polyglossia` 宏包](https://ctan.org/pkg/polyglossia?lang=en) 可能会很有用，尤其是如果你想选择自定义字体。

```latex
\documentclass{article}
\usepackage{polyglossia}
\setmainlanguage{english}
\setotherlanguage{russian}
\newfontfamily{\russianfont}[Script=Cyrillic]{CMU Serif}
\begin{document}
这是英文，这里是俄文：\textrussian{Здравствуй, мир!}
\end{document}
```

[在 Overleaf 中打开此 LuaLaTeX 示例。](https://www.overleaf.com/docs?engine=lualatex\&snip_name=Cyrillc+text+typeset+with+LuaTeX\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bpolyglossia%7D%0A%5Csetmainlanguage%7Benglish%7D%0A%5Csetotherlanguage%7Brussian%7D%0A%5Cnewfontfamily%7B%5Crussianfont%7D%5BScript%3DCyrillic%5D%7BCMU+Serif%7D%0A%5Cbegin%7Bdocument%7D%0AThis+is+English+and+this+is+Russian%3A+%5Ctextrussian%7B%D0%97%D0%B4%D1%80%D0%B0%D0%B2%D1%81%D1%82%D0%B2%D1%83%D0%B9%2C+%D0%BC%D0%B8%D1%80%21%7D%0A%5Cend%7Bdocument%7D)

这个 LuaLaTeX 示例会生成以下输出：

![使用 LuaLaTeX 排版的西里尔文文本](/files/1ac1008a8592f64d78f7e59a104f90e3442e064d)

## 提示：如何切换 LaTeX 编译器

请注意，你可以通过点击左上角的 **菜单** 按钮并更改 **编译器** 设置来切换到 XeLaTeX 或 LuaLaTeX——下面的简短视频将向你展示如何操作。

{% embed url="<https://www.filepicker.io/api/file/ikMVZIu9S6SurOfUPO34>" %}

## 一些相关的 Overleaf 文章

* [俄语](/latex/zh-cn/yu-yan/14-russian.md)
* [国际语言支持](/latex/zh-cn/yu-yan/03-international-language-support.md)
* [使用 polyglossia 和 fontspec 在 Overleaf 上进行多语言排版](/latex/zh-cn/yu-yan/01-multilingual-typesetting-on-overleaf-using-polyglossia-and-fontspec.md)
* [在 XeLaTeX 中使用字体](/latex/zh-cn/zi-ti/03-xelatex.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/latex-wen-ti/01-how-can-i-typeset-text-in-cyrillic-e.g.-in-russian.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.
