> 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-ji-chu/03-bold-italics-and-underlining.md).

# 加粗、斜体和下划线

## 引言

简单的文本格式化有助于突出文档中的重要概念，并使其更易读。使用斜体、粗体或下划线文字可以改变读者的感知。

本文将解释三种基本的文本格式化工具：斜体、粗体和下划线。让我们从一个例子开始：

```latex
其中一些 \textbf{最伟大的}
在 \underline{科学} 中的发现
是由 \textbf{\textit{偶然}}发现的。
```

[在 Overleaf 中打开这个 LaTeX 片段。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=text+formatting+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0ASome+of+the+%5Ctextbf%7Bgreatest%7D+%0Adiscoveries+in+%5Cunderline%7Bscience%7D+%0Awere+made+by+%5Ctextbf%7B%5Ctextit%7Baccident%7D%7D.%0A%5Cend%7Bdocument%7D)

下方图示显示了这段 LaTeX 代码的输出——Overleaf 链接会自动添加文档导言区：

![斜体、粗体和下划线示例](/files/7e25e8e77154997629472f1f7e426ec2aed70fed)

如你所见，基本命令有三种，而且它们可以嵌套以获得组合效果。

注意：来自纯 TeX 的原始文本格式化命令， `\it` （斜体化）和 `\bf` （粗体）在 LaTeX 文档中仍然有效，但不建议使用，因为它们不会保留之前的样式。例如，使用这些旧命令时，你不能同时应用斜体和粗体。

## 斜体文本

要将文本设为斜体很简单，使用 `\textit` (`\emph`）命令：

```latex
其中一些最伟大的
科学领域的发现
是 \textit{偶然}发现的。
```

[在 Overleaf 中打开这个 LaTeX 片段。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=italic+text+formatting+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0ASome+of+the+greatest+%0Adiscoveries+in+science+%0Awere+made+by+%5Ctextit%7Baccident%7D.%0A%5Cend%7Bdocument%7D)

下方图示显示了这段 LaTeX 代码的输出——Overleaf 链接会自动添加文档导言区：

![斜体文本示例](/files/b8f38b34a4ac2ba9f106e04cbff7f1f7662de86b)

## 粗体文本

要将文本设为粗体，请使用 `\textbf` 命令设置为特定值：

```latex
其中一些 \textbf{最伟大的}
科学领域的发现
是偶然发现的。
```

[在 Overleaf 中打开这个 LaTeX 片段。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=bold+text+formatting+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0ASome+of+the+%5Ctextbf%7Bgreatest%7D+%0Adiscoveries+in+science+%0Awere+made+by+accident.%0A%5Cend%7Bdocument%7D)

下方图示显示了这段 LaTeX 代码的输出——Overleaf 链接会自动添加文档导言区：

![Textformattingex3.png](/files/136b55d2aee66cfb751e50473194f3d208dbf3e9)

## 下划线文本

要给文本添加下划线，请使用 `\underline` 命令设置为特定值：

```latex
其中一些最伟大的
在 \underline{科学} 中的发现
是偶然发现的。
```

[在 Overleaf 中打开这个 LaTeX 片段。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=underline+text+formatting+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0ASome+of+the+greatest+%0Adiscoveries+in+%5Cunderline%7Bscience%7D+%0Awere+made+by+accident.%0A%5Cend%7Bdocument%7D)

下方图示显示了这段 LaTeX 代码的输出——Overleaf 链接会自动添加文档导言区：

![下划线文本示例](/files/c6912984e745a2727e217235dbc004cde19aa22a)

## 强调文本

可以使用 `\emph` 命令来强调文本。有时 `\emph` 命令的行为与 `\textit`相同，但并不完全一样：

```latex
其中一些最伟大的 \emph{发现}
在科学领域
是偶然发现的。

\textit{其中一些最伟大的 \emph{发现}
在科学领域
是偶然发现的。}

\textbf{其中一些最伟大的 \emph{发现}
在科学领域
是偶然发现的。}
```

[在 Overleaf 中打开这个 LaTeX 片段。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=emphasizing+text+formatting+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0ASome+of+the+greatest+%5Cemph%7Bdiscoveries%7D+%0Ain+science+%0Awere+made+by+accident.%0A%0A%5Ctextit%7BSome+of+the+greatest+%5Cemph%7Bdiscoveries%7D+%0Ain+science+%0Awere+made+by+accident.%7D%0A%0A%5Ctextbf%7BSome+of+the+greatest+%5Cemph%7Bdiscoveries%7D+%0Ain+science+%0Awere+made+by+accident.%7D%0A%5Cend%7Bdocument%7D)

下方图示显示了这段 LaTeX 代码的输出——Overleaf 链接会自动添加文档导言区：

![强调文本示例](/files/93ab1cfb1105531912a0354819074e60dac6fb24)

该 `\emph` 命令对其参数的实际作用取决于上下文——在普通文本中，被强调的文本会变为斜体，但如果在斜体文本中使用，这种行为会反过来——见上面的示例。此外，一些宏包，例如 [Beamer](/latex/zh-cn/yan-shi-wen-gao/01-beamer.md)，会改变 `\emph` 命令。

## 完整示例集

下面的示例汇集了本文中的各种代码片段，方便你在 Overleaf 中一次性打开它们。

```latex
第一个示例：粗体、斜体和下划线：

其中一些 \textbf{最伟大的}在 \underline{科学} 中的发现是由 \textbf{\emph{偶然}}作出的。

\vspace{1.5cm}

斜体文本示例：

其中一些最伟大的发现是 \emph{偶然}发现的。

\vspace{1.5cm}

粗体文本示例：

其中一些 \textbf{最伟大的}发现是偶然发现的。

\vspace{1.5cm}

下划线文本示例：

其中一些最伟大的发现是在 \underline{科学} 领域中偶然发现的。

\vspace{1.5cm}

不同上下文中的强调文本示例：

其中一些最伟大的 \emph{发现}是在科学领域偶然发现的。

\textit{其中一些最伟大的 \emph{发现}是在科学领域偶然发现的。}

\textbf{其中一些最伟大的 \emph{发现}是在科学领域偶然发现的。}
```

[在 Overleaf 中打开这段 LaTeX 代码。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=text+formatting+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Ctitle%7BBold%2C+Italics+and+Underline%7D%0A%5Cauthor%7BAn+example+from+Overleaf%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cmaketitle%0AFirst+example%2C+bold%2C+italics+and+underline%3A%0A%0ASome+of+the+%5Ctextbf%7Bgreatest%7D+discoveries+in+%5Cunderline%7Bscience%7D+were+made+by+%5Ctextbf%7B%5Cemph%7Baccident%7D%7D.%0A%0A%5Cvspace%7B1.5cm%7D%0A%0AExample+of+italicized+text%3A+%0A%0ASome+of+the+greatest+discoveries+in+science+were+made+by+%5Cemph%7Baccident%7D.%0A%0A%5Cvspace%7B1.5cm%7D%0A%0AExample+of+boldface+text%3A%0A%0ASome+of+the+%5Ctextbf%7Bgreatest%7D+discoveries+in+science+were+made+by+accident.%0A%0A%5Cvspace%7B1.5cm%7D%0A%0AExample+of+underlined+text%3A%0A%0ASome+of+the+greatest+discoveries+in+%5Cunderline%7Bscience%7D+were+made+by+accident.%0A%0A%5Cvspace%7B1.5cm%7D%0A%0AExample+of+emphasized+text+in+different+contexts%3A%0A%0ASome+of+the+greatest+%5Cemph%7Bdiscoveries%7D+in+science+were+made+by+accident.%0A%0A%5Ctextit%7BSome+of+the+greatest+%5Cemph%7Bdiscoveries%7D+in+science+were+made+by+accident.%7D%0A%0A%5Ctextbf%7BSome+of+the+greatest+%5Cemph%7Bdiscoveries%7D+in+science+were+made+by+accident.%7D%0A%5Cend%7Bdocument%7D)

## 进一步阅读

更多信息请参见

* [段落和换行](/latex/zh-cn/latex-ji-chu/02-paragraphs-and-new-lines.md)
* [列表](/latex/zh-cn/latex-ji-chu/04-lists.md)
* [段落格式](/latex/zh-cn/ge-shi-hua/04-articles-how-to-change-paragraph-spacing-in-latex.md)
* [换行与空白](/latex/zh-cn/ge-shi-hua/05-line-breaks-and-blank-spaces.md)
* [LaTeX2ε 不那么简短的介绍](http://www.ctan.org/tex-archive/info/lshort/)


---

# 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-ji-chu/03-bold-italics-and-underlining.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.
