> 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/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/6c96f27bf850caffe7a99acccfb1bfb20878ce85)

這些指令會以正體（羅馬）文字而非斜體輸出函數名稱。

## 不同情境中的運算子

某些運算子可以接受以特殊方式處理的參數，例如極限。

```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/d3f73af46ab9a56f77fdcae9e7dee581565974fe)

套件 `amsmath` 是巨集所需的 `\to`；若沒有此套件，則必須使用 `\rightarrow` 。

請注意，極限定義可以包含下標。請參閱 [參考指南](#reference-guide) 以取得可用運算子的完整清單。

某些語言可能會新增或變更某些指令，請查看 [主頁](/latex/zh-tw/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/443522e7c7c900f9707d7b1b11300228c07eb780)

指令 `\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-tw/shu-xue/01-mathematical-expressions.md)
* [下標與上標](/latex/zh-tw/shu-xue/02-subscripts-and-superscripts.md)
* [分數與二項式係數](/latex/zh-tw/shu-xue/05-fractions-and-binomials.md)
* [數學模式中的間距](/latex/zh-tw/shu-xue/08-spacing-in-math-mode.md)
* [積分、加總與極限](/latex/zh-tw/shu-xue/09-integrals-sums-and-limits.md)
* [數學模式中的顯示樣式](/latex/zh-tw/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-tw/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.
