> 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/yu-yan/10-italian.md).

# 意大利语

## 引言

本文介绍如何排版意大利语文本：启用重音字符的正确排版，如 à、è、é、ì 等，并支持连字符规则等语言特定功能。如果你想了解如何在同一文档中使用不止一种语言，例如英语和意大利语，请参见 [国际语言支持](/latex/zh-cn/yu-yan/03-international-language-support.md) 文章。

## 使用 pdfLaTeX 的意大利语示例

我们将从下面这个 pdfLaTeX 示例开始，你可以通过代码下方的链接在 Overleaf 中打开它。

```latex
\documentclass{article}

%\usepackage[utf8]{inputenc} 已不再需要（自 2018 年起）

%设置字体（输出）编码
%--------------------------------------
\usepackage[T1]{fontenc} %LuaLaTeX 或 XeLaTeX 不需要
%--------------------------------------

%意大利语特定命令
%--------------------------------------
\usepackage[italian]{babel}
%断字规则
%--------------------------------------
\usepackage{hyphenat}
\hyphenation{mate-mati-ca recu-perare}

\begin{document}
\tableofcontents

\vspace{2cm} %添加 2 厘米空白

\begin{abstract}
这是对……内容的简短摘要
以意大利语编写的文档。
\end{abstract}

\section{引言部分}
这是第一节，我们可以添加
一些附加内容，而且一切
都能正确排版。此外，如果某个单词
太长并且必须被截断
babel 将尝试正确地断开
这取决于语言。

\section{定理部分}
这一节是为了看看与命令一起使用时会发生什么
文本，定义

\[ \lim x =  \sin{\theta} + \max \{3.52, 4.22\} \]
\end{document}
```

[在 Overleaf 中打开这个 pdfLaTeX 示例。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Sample+document+in+Italian\&snip=%5Cdocumentclass%7Barticle%7D%0A%0A%25%5Cusepackage%5Butf8%5D%7Binputenc%7D+is+no+longer+required+%28since+2018%29%0A%0A%25Set+the+font+%28output%29+encoding%0A%25--------------------------------------%0A%5Cusepackage%5BT1%5D%7Bfontenc%7D+%25Not+needed+by+LuaLaTeX+or+XeLaTeX%0A%25--------------------------------------%0A%0A%25Italian-specific+commands%0A%25--------------------------------------%0A%5Cusepackage%5Bitalian%5D%7Bbabel%7D%0A%25Hyphenation+rules%0A%25--------------------------------------%0A%5Cusepackage%7Bhyphenat%7D%0A%5Chyphenation%7Bmate-mati-ca+recu-perare%7D%0A%0A%5Cbegin%7Bdocument%7D%0A%5Ctableofcontents%0A%0A%5Cvspace%7B2cm%7D+%25Add+a+2cm+space%0A%0A%5Cbegin%7Babstract%7D%0AQuesto+%C3%A8+un+breve+riassunto+dei+contenuti+del+%0Adocumento+scritto+in+italiano.%0A%5Cend%7Babstract%7D%0A%0A%5Csection%7BSezione+introduttiva%7D%0AQuesta+%C3%A8+la+prima+sezione%2C+possiamo+aggiungere+%0Aalcuni+elementi+aggiuntivi+e+tutto+%0Adigitato+correttamente.+Inoltre%2C+se+una+parola+%0A%C3%A8+troppo+lunga+e+deve+essere+troncato+%0Ababel+cercher%C3%A0+per+troncare+correttamente+%0Aa+seconda+della+lingua.%0A%0A%5Csection%7BTeoremi+Sezione%7D%0AQuesta+sezione+%C3%A8+quello+di+vedere+cosa+succede+con+i+comandi+%0Atesto+definendo%0A%0A%5C%5B+%5Clim+x+%3D++%5Csin%7B%5Ctheta%7D+%2B+%5Cmax+%5C%7B3.52%2C+4.22%5C%7D+%5C%5D%0A%5Cend%7Bdocument%7D)

此示例生成以下输出：

![OL2italian1.png](/files/e87a11c4f67c7010883b359461429fc03240bef0)

### 文本文件：整数与字符

任何文本文件，例如 LaTeX 输入 `.tex` 文件，不过是一个由数值（整数）组成的流，这些数值被用作表示文本字符的机制；因此，处理文本文件就涉及扫描（读取/处理）一系列整数值。然而，一个重要问题随之而来： *表示* 文本字符；那么，处理文本文件就涉及扫描（读取/处理）一系列整数值。然而，一个重要问题随之而来： *究竟是哪一组字符* 实际上由某个特定文本文件中包含的整数值表示？换句话说，这些整数值是如何被 *编码*：从文本文件中的整数到它们本应表示的相应字符，正确（预期的）“映射”（编码）是什么？ *表示*?

文本文件可以在无数计算环境中生成：跨越不同国家/洲，使用各种不同的设备、操作系统和编辑工具。文本文件的创建者在生成并存储用于表示文本文件中各个字符的整数值序列时，可能会根据本地需求，例如语言，使用或应用不同的文本编码。如果生成的文本文件始终停留在使用相同编码的兼容技术生态系统内，这或许能正常工作，但当这些文件被传输到完全不同的环境时会怎样呢——因为许多文本文件并不包含任何指示其生成时所用编码的信息。

显然，文本数据的生产者（创建者）和消费者（用户）必须以某种方式就所使用的编码（映射）达成一致，否则 *编码错误* 就很可能由于文件中的整数数据与其被假定表示的字符集合不匹配而出现。除了将文本文件中的整数值正确映射到字符之外，随后对这些字符进行任何视觉显示都需要某种字体，它能够提供数据（字形，甚至位图），以输出所需字符的可视化表示。

### 输入编码：inputenc、UTF-8 以及 2018 年 LaTeX 的一项变更

从历史上看，各种 8 位编码曾被用于生成/处理文本文件，包括 LaTeX 输入。长话短说，LaTeX 的开发者创建了 `inputenc` 宏包以解决编码问题——使使用各种编码创建的文本文件能够在不同的 LaTeX 安装之间传输。

然而，随着时间推移，用户/软件开发者逐渐从多种 8 位编码转向使用 Unicode 及其 UTF-8 编码方案，后者成为文本文件编码的事实标准。2018 年之前，要处理 UTF-8 编码文件，LaTeX 文档导言区会包含这一行

```latex
\usepackage[utf8]{inputenc}
```

读者可能会注意到，上面的示例并未包含这一行 `\usepackage[utf8]{inputenc}` 在文档导言区：这是为什么呢？这是由于 LaTeX 在 2018 年引入的一项重要变更：将 UTF-8 切换为默认 *输入* 编码。使用 pdfLaTeX 排版且采用 UTF-8 编码文本的文档，包括在 Overleaf 上创建和排版的文档，已不再 *需要* 需要包含 `\usepackage[utf8]{inputenc}` 但 [这样做也无妨](https://www.latex-project.org/news/2018/04/10/issue28-of-latex2e-news-released/)。更多信息请参见 [《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)。在 Overleaf 上创建的所有文本文件都使用 UTF-8 编码。

### 输出编码：fontenc 宏包

为了正确排版输入文件中的字符，这些字符需要映射到文档排版所使用字体中相应的 *输出字形* （glyphs，字形）。这种“输出编码”由另一个名为 `fontenc`.

要使用 `fontenc` 请在文档导言区包含以下行，使用一种编码，例如 [T1 编码](http://mirrors.ctan.org/macros/latex/base/encguide.pdf)，它支持基于拉丁字母的语言中的重音字符：

```latex
\usepackage[T1]{fontenc}
```

使用 `T1` 字体编码，通过 `\usepackage[T1]{fontenc}`，还有其他好处：

* 默认的 OT1 LaTeX 字体（“输出”）编码是 7 位，这意味着它只能编码 128 个字符，并不包含（也不启用）对字体中真正的重音字符字形（glyphs）的访问。 `OT1` 编码会使 TeX 引擎通过将基础字符与一个叠加并偏移的重音字符组合来“伪造”重音字符。
* 如果 TeX 引擎不得不采用 *构造* 重音字符，这会影响从 PDF 中复制/粘贴文本：复制包含构造出的重音字符的文本将导致 *两个独立字符* 被粘贴出来：基础字符和重音符号字符。使用 `T1` 编码可以避免这种情况。
* 使用 `T1` 编码以访问真正的重音字符，还能改进断字。

### LaTeX 的 T1 字体编码

下表列出了 `T1` 字体编码。它转载自文档第 22 页 *LaTeX 字体编码* 它是 [可在 CTAN 上获得](http://mirrors.ctan.org/macros/latex/base/encguide.pdf).

![](/files/ae2a0f637da90dbdbe806876941dbb701d996043)

### 复制和粘贴示例

下面这个不使用 `fontenc`的最小示例，演示了复制/粘贴包含重音字符的文本时的问题。

```latex
\documentclass{article}
\begin{document}
cercherà（OT1 编码）

{
\fontencoding{T1}\selectfont cercherà（T1 编码）
}
\end{document}
```

[在 Overleaf 中打开此示例。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Demonstrating+copy+and+paste+with+font+encodings\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0Acercher%C3%A0+%28OT1+encoding%29%0A%0A%7B%0A%5Cfontencoding%7BT1%7D%5Cselectfont+cercher%C3%A0+%28T1+encoding%29%0A%7D%0A%5Cend%7Bdocument%7D)

第一段文本使用 LaTeX 的默认 `OT1` 编码排版，因此会出现“伪造”的重音字符。下面这段 LaTeX 代码：

```latex
\fontencoding{T1}\selectfont
```

切换为使用 `T1` 编码，这会使 LaTeX 排版出重音字符字形。如果你复制上面示例生成的 PDF 中的文本，你应该会看到类似下面的内容：

cercher\`a（OT1 编码） cercherà（T1 编码）

请注意 `OT1` 以 编码的文本并不包含真正的重音字符，而使用 `T1` 编码的文本则包含。复制/粘贴的结果也可能取决于你用来查看 PDF 并从中复制/粘贴包含重音字符文本的应用程序。

## 语言特定的宏包和命令

为了扩展 LaTeX 的默认功能，提供正确的断字以及文档元素名称的翻译，请导入 `babel` 宏包，并使用 `意大利语` 语言选项。

```latex
\usepackage[italian]{babel}
```

正如你在 [使用 pdfLaTeX 的示例](#italian-example-using-pdflatex)中所见，文中使用的是意大利语版本的“Sommario”和“Indice”，而不是“Abstract”和“Contents”。

## 断字

该 `babel` 宏包通常能很好地提供语言特定的断字功能，但如果某个单词无法正确断字，还有一些宏包可以辅助。例如，你可以在导言区添加 `hyphenat` 宏包到你的导言区：

```latex
 \usepackage{hyphenat}
 \hyphenation{mate-mati-ca recu-perare}
```

第一条命令将导入宏包 `hyphenat` ，第二行是一个由空格分隔的单词列表，并为其定义了断字规则。另一方面，如果你希望某个 *单词* 不要被自动断开，请使用 `{\nobreak word}` 命令。

## 进一步阅读

更多信息请参见

* [使用 XƎLaTeX 支持现代字体](/latex/zh-cn/zi-ti/03-xelatex.md)
* [排版引号和引号符号](/latex/zh-cn/yu-yan/04-typesetting-quotations.md)
* [国际语言支持](/latex/zh-cn/yu-yan/03-international-language-support.md)
* [中文](/latex/zh-cn/yu-yan/06-chinese.md)
* [法语](/latex/zh-cn/yu-yan/07-french.md)
* [德语](/latex/zh-cn/yu-yan/08-german.md)
* [希腊语](/latex/zh-cn/yu-yan/09-greek.md)
* [阿拉伯语](/latex/zh-cn/yu-yan/05-arabic.md)
* [日语](/latex/zh-cn/yu-yan/11-japanese.md)
* [韩语](/latex/zh-cn/yu-yan/12-korean.md)
* [葡萄牙语](/latex/zh-cn/yu-yan/13-portuguese.md)
* [俄语](/latex/zh-cn/yu-yan/14-russian.md)
* [西班牙语](/latex/zh-cn/yu-yan/15-spanish.md)
* [LaTeX2ε 不那么简短的介绍](http://www.ctan.org/tex-archive/info/lshort/)
* [WikiBooks 上的 LaTeX/国际化](http://en.wikibooks.org/wiki/LaTeX/Internationalization)
* [WikiBooks 上的 LaTeX/特殊字符](http://en.wikibooks.org/wiki/LaTeX/Special_Characters)


---

# 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/yu-yan/10-italian.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.
