> For the complete documentation index, see [llms.txt](https://ayakaleaf-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://ayakaleaf-pro.ayaka.space/latex/zh-cn/lei-wen-jian/01-understanding-packages-and-class-files.md).

# 理解宏包和类文件

LaTeX 文档中的默认格式由……决定 **类** 该文档所使用的。这种默认外观可以通过……来更改，并且可以通过……添加更多功能。 **宏包**。类文件名具有 **.cls** 扩展名，宏包文件名具有 **.sty** 扩展名。

## 类与宏包之间的区别

有时，在决定是编写宏包还是类时，很难做出选择。基本规则是：如果你的文件包含控制某种特殊类型文档的逻辑结构外观的命令，那么它就是一个类。否则，如果你的文件添加的是与文档类型无关的功能，也就是说，可用于书籍、报告、文章等；那么它就是一个宏包。

例如，如果某家公司需要带有品牌标识的报告，这些报告使用一种特殊字体，并且在页脚中包含公司的徽标；那么你需要一个新的类。

如果公司需要一个新命令，使在文档中突出显示重要句子更容易，那么在这种情况下，一个新的宏包就能满足需求。

## 进一步阅读

更多信息请参见

* [编写你自己的宏包](/latex/zh-cn/lei-wen-jian/03-writing-your-own-package.md)
* [编写你自己的类](/latex/zh-cn/lei-wen-jian/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://ayakaleaf-pro.ayaka.space/latex/zh-cn/lei-wen-jian/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.
