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

# LaTeX-feil: Kan bare brukes i innledningen

Denne feilen vises når du har inkludert en pakke eller klasse i hoveddelen av dokumentet ditt, i stedet for i preamblen. Preamblen til dokumentet består av alt som er skrevet før **`\begin{document}`**. I preamblen definerer du typen dokument du skriver, språket og flere andre elementer. For eksempel vil en normal dokumentpreambel se slik ut:

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

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

Hvis du skriver **`\usepackage{...}`** i hoveddelen av dokumentet (etter **`\begin{document}`**) i stedet for i preamblen, vil du generere feilmeldingen vist nedenfor.

main.tex, linje 7

LaTeX-feil: Kan bare brukes i preamblen.

Se LaTeX-manualen eller LaTeX Companion for en forklaring. Skriv H for umiddelbar hjelp. ... l.4 \usepackage {amsmath} Kommandoen din ble ignorert. Skriv I for å erstatte den med en annen kommando, eller fortsette uten den. \[1

For å rette denne feilen, sørg for at alle **`\usepackage{...}`** kommandoer, så vel som **`\documentclass[...]{...}`**, er skrevet før **`\begin{document}`**. For å lære mer om hvordan du strukturerer et dokument i LaTeX, sjekk ut vår [dokumentasjonen](/latex/no/grunnleggende-latex/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/no/latex-feil/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.
