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

# Understanding packages and class files

The default formatting in LaTeX documents is determined by the **class** used by that document. This default look can be changed and more functionalities can be added by means of a **package**. The class file names have the **.cls** extension, the package file names have the **.sty** extension.

## Difference between classes and packages

Sometimes it's hard to make a decision when it comes to choose whether to write a package or a class. The basic rule is that if your file contains commands that control the look of the logical structure of a special type of document, then it's a class. Otherwise, if your file adds features that are independent of the document type, i.e. can be used in books, reports, articles and so on; then it's a package.

For instance, if a company needs branded reports that use a special font and have the logo of the company in the footer; you need a new class.

If the company needs a new command that makes easier to highlight important sentences within a document, a new package will work in this scenario.

## Further reading

For more information see

* [Writing your own package](/latex/class-files/03-writing-your-own-package.md)
* [Writing your own class](/latex/class-files/04-writing-your-own-class.md)
* [LaTeX2ε for class and package writers](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/class-files/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.
