Basics

A LaTeX document is structured in two main parts:

  1. The preamble part for initialization purposes A LaTeX preamble is a section of a LaTeX document that precedes the main content and provides instructions and settings for how the document should be formatted and compiled. It typically includes commands that specify the document class, packages to be used, document title, author information, formatting options, and other settings that affect the overall appearance and behavior of the document.

👉 Everything before \\begin{document}

  1. The main part of the document with the content The main part of a LaTeX document is the section that follows the preamble and contains the actual content of the document. This is where you would include your text, equations, figures, tables, and any other elements that make up the substance of your document.

👉 Starting with \\begin{document} and ending with \\end{document}

Code examples

% Preamble of the document
\\documentclass[10pt]{article}

\\usepackage[a4paper,hmargin=3cm,vmargin=3cm]{geometry}
\\usepackage[utf8]{inputenc}
\\usepackage[T1]{fontenc}
\\usepackage[english]{babel}
\\usepackage[english]{varioref}
\\usepackage[noabbrev,english]{cleveref}

\\begin{document} % Main part of the document starts here

% document contents
Latex is amazing!

\\end{document}
% Preamble of the document
\\documentclass[10pt]{article}

\\usepackage[letterpaper, hmargin=1in, vmargin=1in]{geometry}
\\usepackage[utf8]{inputenc}
\\usepackage[T1]{fontenc}
\\usepackage[ngerman]{babel}
\\usepackage[ngerman]{varioref}
\\usepackage[noabbrev,german]{cleveref}

\\begin{document} % Main part of the document starts here

% document contents
Latex is amazing!

\\end{document}

How does OneLatex handle the preamble and the main part?

Preamble

The \\documentclass command is inserted during the conversion process based on the settings at the beginning of the LaTeX code. Adjust the settings if you want to change the parameters of the command.

The rest of the preamble must be written in OneNote. Technically, it doesn't matter where you place your preamble commands in OneNote. OneLatex will go through each page of the section when loading the notebook and insert the text into the preamble that is highlighted in orange or has a “Project-A” tag.

However, for a better overview of the preamble content, it is recommended to create a separate page at the beginning of the OneNote section for initialization purposes only (see Step 2: Create a OneNote page for Initializiation purposes for more details).

Main Part

OneLatex automatically inserts the commands \\begin{document} and \\end{document} at the beginning and end of the main part.

Text from the OneNote notebook, with the exception of text with a green, orange or blue background color (remarks) or with the tag “Project A”, will be included in the main part.

Text with a yellow background color or with the tag “Project B” will be interpreted as native LaTeX code during the conversion process.