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

# 義大利文

## 簡介

本文說明如何排版義大利文：啟用重音字元（如 à、è、é、ì 等）的正確排版，並提供對特定語言功能（例如斷字）的支援。如果你正在尋找如何在單一文件中使用多種語言，例如英文和義大利文，請參閱 [國際語言支援](/latex/zh-tw/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} %新增 2cm 的空白

\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/33b64d5bd59ee8f9bfec3fe0385e7fbc99a4b9ea)

### 文字檔：整數與字元

任何文字檔，例如 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/)。更多資訊請參閱 [2018 年 4 月的 LaTeX News 期刊](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}`，還有其他優點：

* LaTeX 預設的 OT1 字型（「輸出」）編碼是 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/32ac4093a985476c44fb0a464aca86adcff8de94)

### 複製與貼上的範例

以下這個最小範例未使用 `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-tw/zi-xing/03-xelatex.md)
* [引號與引號符號的排版](/latex/zh-tw/yu-yan/04-typesetting-quotations.md)
* [國際語言支援](/latex/zh-tw/yu-yan/03-international-language-support.md)
* [中文](/latex/zh-tw/yu-yan/06-chinese.md)
* [法文](/latex/zh-tw/yu-yan/07-french.md)
* [德文](/latex/zh-tw/yu-yan/08-german.md)
* [希臘文](/latex/zh-tw/yu-yan/09-greek.md)
* [阿拉伯文](/latex/zh-tw/yu-yan/05-arabic.md)
* [日文](/latex/zh-tw/yu-yan/11-japanese.md)
* [韓語](/latex/zh-tw/yu-yan/12-korean.md)
* [葡萄牙文](/latex/zh-tw/yu-yan/13-portuguese.md)
* [俄文](/latex/zh-tw/yu-yan/14-russian.md)
* [西班牙文](/latex/zh-tw/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-tw/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.
