> 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/lei-bie-dang/01-understanding-packages-and-class-files.md).

# 了解套件與類別檔

LaTeX 文件中的預設格式設定由 **類別** 所使用的類別決定。這種預設外觀可以透過 **套件**。類別檔案名稱具有 **.cls** 副檔名，套件檔案名稱具有 **.sty** 副檔名。

## 類別與套件之間的差異

有時候在決定要撰寫套件還是類別時很難做出選擇。基本原則是：如果你的檔案包含控制某種特殊文件類型之邏輯結構外觀的命令，那麼它就是類別。否則，如果你的檔案增加的是與文件類型無關的功能，也就是說可用於書籍、報告、文章等等；那麼它就是套件。

例如，如果某公司需要帶有品牌識別的報告，使用特殊字型並且在頁尾放置公司標誌；你就需要一個新的類別。

如果該公司需要一個新命令，讓你更容易在文件中強調重要句子，在這種情況下，新的套件就能派上用場。

## 延伸閱讀

更多資訊請參見

* [撰寫你自己的套件](/latex/zh-tw/lei-bie-dang/03-writing-your-own-package.md)
* [撰寫你自己的類別](/latex/zh-tw/lei-bie-dang/04-writing-your-own-class.md)
* [供類別與套件作者使用的 LaTeX2ε](http://www.latex-project.org/guides/clsguide.pdf)


---

# 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/lei-bie-dang/01-understanding-packages-and-class-files.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.
