Creating your first LaTeX document
Learn how to create your first LaTeX document from scratch. Step-by-step guide for beginners using LaTeX Cloud Studio.
Let’s create your very first LaTeX document! This guide will walk you through the essential steps to get started with LaTeX using LaTeX Cloud Studio.
Time needed: 5 minutes
Prerequisites: Access to LaTeX Cloud Studio
What you’ll learn: Basic document structure, compiling, and viewing output
The Simplest LaTeX Document
Every LaTeX journey begins with a simple “Hello World” document. Here’s the absolute minimum you need:
That’s it! These four lines create a complete LaTeX document.
Understanding Each Line
Let’s break down what each line does:
1. Document Class
This tells LaTeX what kind of document you’re creating. The article
class is perfect for:
- Short documents
- Academic papers
- Reports
- General documents
Other common classes include:
report
- for longer documents with chaptersbook
- for books with parts, chapters, and sectionsletter
- for formal lettersbeamer
- for presentations
2. Document Environment
Everything between these commands is your actual document content. Think of it as the “body” of your HTML page.
Creating a More Complete Document
Let’s expand our document with common elements:
How to Create This in LaTeX Cloud Studio
- Open LaTeX Cloud Studio in your browser
- Create a new document using the “New Document” button
- Copy and paste the code above into the editor
- Click “Compile” to generate your PDF
- View the result in the preview pane
LaTeX Cloud Studio automatically saves your work and provides real-time preview, making it perfect for beginners!
The Document Structure
A LaTeX document has two main parts:
1. The Preamble
Everything before \begin{document}
is the preamble. This is where you:
- Set the document class
- Load packages (extensions)
- Define document information (title, author, date)
- Set up custom commands
- Configure document settings
2. The Document Body
Everything between \begin{document}
and \end{document}
is your content. This includes:
- Text
- Sections and chapters
- Equations
- Figures and tables
- References
Your First Compilation
When you compile a LaTeX document, here’s what happens:
- LaTeX reads your source file (.tex)
- Processes the commands and markup
- Generates a PDF (or other output format)
- Shows any errors if something went wrong
In LaTeX Cloud Studio, this happens automatically when you click “Compile” or enable auto-compilation.
Common Beginner Mistakes
Avoid these common errors:
- Forgetting
\end{document}
- Every document must end with this - Content before
\begin{document}
- Only setup goes in the preamble - Mismatched braces - Every
{
needs a matching}
- Wrong quotes - Use “
Adding More Elements
Comments
Use %
to add comments that won’t appear in the output:
Paragraphs
Leave a blank line to start a new paragraph:
Basic Formatting
Practice Exercise
Try creating this document:
What’s Next?
Now that you’ve created your first document, you can:
- Experiment with different document classes - Try
report
orbook
- Add more sections - Use
\subsection
and\subsubsection
- Include mathematics - Learn about math mode
- Format your text - Explore fonts and styling
- Add images and tables - Make your documents visual
Quick Reference
Command | Purpose | Example |
---|---|---|
\documentclass{} | Set document type | \documentclass{article} |
\begin{document} | Start document content | Required |
\end{document} | End document content | Required |
\title{} | Set document title | \title{My Report} |
\author{} | Set author name | \author{Jane Doe} |
\date{} | Set date | \date{\today} |
\maketitle | Create title block | Place after \begin{document} |
\section{} | Create a section | \section{Introduction} |
% | Comment | % This is a note |
Tips for Success
- Start simple - Don’t try to use every feature at once
- Compile often - Check your work frequently
- Read error messages - They usually point to the exact problem
- Use templates - Build on working examples
- Keep the documentation handy - Reference it as you work
Congratulations! You’ve created your first LaTeX document. This is the foundation for creating professional documents of any complexity. Continue with Choosing a LaTeX Compiler to understand how LaTeX processes your documents.