> 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/shu-xue/07-operators.md).

# 运算符

数学模式中的字符通常以斜体显示，但有时某些函数名需要不同的格式，这可以通过使用 LaTeX 中定义的运算符来实现。

## 引言

三角函数、对数及其他函数可以通过一些特殊命令写入文档，如下例所示：

```latex
数学运算符示例：
\[
    \sin(a + b) = \sin a \cos b + \cos a \sin b
.\]
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Mathematical+operators+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0AExamples+of+mathematical+operators%3A%0A%5C%5B%0A++++%5Csin%28a+%2B+b%29+%3D+%5Csin+a+%5Ccos+b+%2B+%5Ccos+a+%5Csin+b%0A.%5C%5D%0A%5Cend%7Bdocument%7D)

此示例生成以下输出：

![Newsincos.png](/files/c2d915966222a12b173ed4ae86cd8b2bbc85819b)

这些命令会以直立（罗马）体而不是斜体显示函数名称。

## 不同上下文中的运算符

某些运算符可以接受以特殊方式处理的参数，例如极限。

```latex
\documentclass{article}
\usepackage{amsmath}
\begin{document}
极限记号测试
\[
    \lim_{h \to 0 } \frac{f(x+h)-f(x)}{h}
.\]
这个运算符在与……一起使用时会发生变化
文本 \( \lim_{h \to 0} (x-h) \)。
\end{document}
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Mathematical+operators+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bamsmath%7D%0A%5Cbegin%7Bdocument%7D%0ATesting+notation+for+limits%0A%5C%5B%0A++++%5Clim_%7Bh+%5Cto+0+%7D+%5Cfrac%7Bf%28x%2Bh%29-f%28x%29%7D%7Bh%7D%0A.%5C%5D%0AThis+operator+changes+when+used+alongside+%0Atext+%5C%28+%5Clim_%7Bh+%5Cto+0%7D+%28x-h%29+%5C%29.%0A%5Cend%7Bdocument%7D)

此示例生成以下输出：

![OperatorsEx2.png](/files/58277cf1102f1f256674567e69baaaf69458cf78)

该宏包 `amsmath` 该宏需要 `\to`；如果没有这个宏包， `\rightarrow` 必须使用。

注意极限声明可以包含下标。参见 [参考指南](#reference-guide) 以获取可用运算符的完整列表。

某些语言可能会添加或更改一些命令，请查看 [主页](/latex/zh-cn/readme.md) 以获取特定语言的文章。

## 定义你自己的运算符

如果你需要添加一个自定义运算符以直立体而不是斜体显示，请使用 `\DeclareMathOperator`

```latex
\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator{\arctg}{arctg}
\begin{document}
反正切的用户自定义运算符：
\[
    \arctg \frac{\pi}{3} = \sqrt{3}
.\]
\end{document}
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Example+defining+an+operator\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bamsmath%7D%0A%5CDeclareMathOperator%7B%5Carctg%7D%7Barctg%7D%0A%5Cbegin%7Bdocument%7D%0AUser-defined+operator+for+arctangent%3A%0A%5C%5B%0A++++%5Carctg+%5Cfrac%7B%5Cpi%7D%7B3%7D+%3D+%5Csqrt%7B3%7D%0A.%5C%5D%0A%5Cend%7Bdocument%7D)

此示例生成以下输出：

![OperatorsEx3.png](/files/80bc6c58b35ae39771a15521237f6d75a18d66a0)

命令 `\DeclareMathOperator` 接受两个参数，第一个是新运算符的名称，第二个是要显示的文本。要使该命令生效，你必须导入宏包 **amsmath** 在导言区中使用

```latex
\usepackage{amsmath}
```

如果你需要定义的运算符使用下标，该命令可以稍作修改，例如 `\lim` 运算符，在这种情况下请使用 `\DeclareMathOperator*`.

## 参考指南

**数学运算符完整列表**

| 运算符       | 显示为         |
| --------- | ----------- |
| `\cos`    | $$\cos$$    |
| `\csc`    | $$\csc$$    |
| `\exp`    | $$\exp$$    |
| `\ker`    | $$\ker$$    |
| `\limsup` | $$\limsup$$ |
| `\min`    | $$\min$$    |
| `\sinh`   | $$\sinh$$   |
| `\arcsin` | $$\arcsin$$ |
| `\cosh`   | $$\cosh$$   |
| `\deg`    | $$\deg$$    |
| `\gcd`    | $$\gcd$$    |
| `\lg`     | $$\lg$$     |
| `\ln`     | $$\ln$$     |
| `\Pr`     | $$\Pr$$     |
| `\sup`    | $$\sup$$    |
| `\arctan` | $$\arctan$$ |
| `\cot`    | $$\cot$$    |
| `\det`    | $$\det$$    |
| `\hom`    | $$\hom$$    |
| `\lim`    | $$\lim$$    |
| `\log`    | $$\log$$    |
| `\sec`    | $$\sec$$    |
| `\tan`    | $$\tan$$    |
| `\arg`    | $$\arg$$    |
| `\coth`   | $$\coth$$   |
| `\dim`    | $$\dim$$    |
| `\liminf` | $$\liminf$$ |
| `\max`    | $$\max$$    |
| `\sin`    | $$\sin$$    |
| `\tanh`   | $$\tanh$$   |

## 进一步阅读

更多信息请参见

* [数学表达式](/latex/zh-cn/shu-xue/01-mathematical-expressions.md)
* [下标和上标](/latex/zh-cn/shu-xue/02-subscripts-and-superscripts.md)
* [分数和二项式](/latex/zh-cn/shu-xue/05-fractions-and-binomials.md)
* [数学模式中的间距](/latex/zh-cn/shu-xue/08-spacing-in-math-mode.md)
* [积分、求和与极限](/latex/zh-cn/shu-xue/09-integrals-sums-and-limits.md)
* [数学模式中的显示样式](/latex/zh-cn/shu-xue/10-display-style-in-math-mode.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/shu-xue/07-operators.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.
