> 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/da/latex-fejl/13-latex-error-can-be-used-only-in-preamble.md).

# LaTeX-fejl: Kan kun bruges i præamblen

Denne fejl vises, når du har inkluderet en pakke eller klasse i hoveddelen af dit dokument i stedet for i præamblen. Dokumentets præambel består af alt, der er skrevet før **`\begin{document}`**. I præamblen definerer du den type dokument, du skriver, sproget og flere andre elementer. For eksempel vil en normal dokumentpræambel se sådan ud:

```latex
\documentclass[12pt, letterpaper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}

\title{Første dokument}
\author{Hubert Farnsworth \thanks{finansieret af ShareLaTeX-teamet}}
\date{Februar 2014}
```

Hvis du skriver **`\usepackage{...}`** i dokumentets hoveddel (efter **`\begin{document}`**) i stedet for i præamblen, vil du generere fejlmeddelelsen vist nedenfor.

main.tex, linje 7

LaTeX-fejl: Kan kun bruges i præamblen.

Se LaTeX-manualen eller LaTeX Companion for en forklaring. Skriv H for øjeblikkelig hjælp. ... l.4 \usepackage {amsmath} Din kommando blev ignoreret. Skriv I for at erstatte den med en anden kommando, eller fortsætte uden den. \[1

For at rette denne fejl skal du sørge for, at alle **`\usepackage{...}`** kommandoer, såvel som **`\documentclass[...]{...}`**, er skrevet før **`\begin{document}`**. For at lære mere om, hvordan man strukturerer et dokument i LaTeX, så tjek vores [dokumentationen](/latex/da/latex-grundlaeggende/01-learn-latex-in-30-minutes.md).


---

# 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/da/latex-fejl/13-latex-error-can-be-used-only-in-preamble.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.
