Technical Guide

Master the .tex File.

A .tex file is plain text code that builds beautiful documents. It is the secret tool used by smart people to create perfect books, math papers, and reports.

What is a .tex file?

A .tex file is a raw text file used by a system called LaTeX. You do not format text by clicking buttons. Instead, you write short commands to tell the computer what to do.

Think of it like writing a recipe. You write the ingredients and steps in the .tex file. The computer reads it and "bakes" a perfect PDF.

No Visual Editing

If you use Word or Google Docs, you see exactly what you get while you type. This is easy, but it gets messy with big files.

In a .tex file, you only look at code. You let the computer handle the margins, fonts, and spacing. This makes your document look exactly the same every single time.

The 3-Step Process

1

Write Code

You write plain text and commands in your .tex file using any text editor.

\title{My Book}
2

Compile

A LaTeX program reads your .tex file and figures out where everything should go.

3

Get PDF

The program gives you a final, locked PDF file. It looks perfect and professional.

The Anatomy of a .tex File

\documentclass{article}

% This is a comment. It is ignored.
\usepackage{amsmath}

\begin{document}

\title{My First Paper}
\author{Jane Doe}
\maketitle

Hello world! This is my text.

\end{document}
The Setup (Preamble)

Everything before \begin{document} is the setup. You tell the computer what type of document it is (like an article or a book) and load extra tools.

Comments

Any line starting with a % sign is a note for yourself. The computer skips it.

The Body

Everything between \begin{document} and \end{document} is the actual text that will show up on your PDF pages.

Why use .tex files?

Learning to write code just to make a document sounds hard. But people do it because it fixes huge problems.

  • It never crashes with big files. A 500-page book will make normal apps freeze. A .tex file handles it easily.
  • Total consistency. If you say a heading should be big and bold, every single heading will be exactly the same. No manual fixing needed.
  • Free and forever. A .tex file is just text. You can open it 50 years from now on any computer. You don't have to pay for an app to read it.

The Math Superpower

The number one reason people use .tex files is for math. It makes hard equations look perfect without using a mouse.

You type this: E = mc^2 You get this:
E = mc²
You type this: \frac{1}{2} \times x You get this:
½ × x

Handling Book References (Citations)

If you write a paper, you have to list the books you read. Doing this by hand is a nightmare. .tex files use a helper file called a .bib file to do it for you.

1. The Data (.bib file)

You put all book details in one list.

@book{smith2020,
  title={Big Data},
  author={John Smith},
  year={2020}
}

2. The Command (.tex file)

You just call the name when writing.

As seen in \cite{smith2020}, 
data is growing.

The computer will automatically build a perfect "Works Cited" list at the end of your PDF and put the numbers in the right order. If you move a paragraph, it changes the numbers for you.

Building Big Documents

You do not have to write a 100-page report in one giant .tex file. You can break it into small pieces.

main.tex The boss file that connects everything.
\input{chapter1.tex}
\input{chapter2.tex}
\input{chapter3.tex}

Common Mistakes

Because you are writing code, one small typo can stop the PDF from building. Here are the most common traps to avoid.

Missing Braces

Every open brace { needs a close brace }. If you forget one, the computer gets stuck.

\textbf{Bold text <- ERROR!
Special Characters

Signs like $, %, and & are code commands. To type them as normal text, put a slash first.

It costs $5. <- ERROR! It costs \$5. <- GOOD!

How to open and edit .tex files

You can open a .tex file with Notepad, but you need special tools to turn it into a PDF.

Overleaf (Best for Beginners)

A website that runs entirely in your browser. No setup needed. You write code on the left, and the PDF shows up on the right.

TeXstudio (Offline)

A free program you download to your computer. It has lots of buttons to help you insert math and tables quickly without typing.

VS Code (For Pros)

If you are a programmer, you can use VS Code with an extension called LaTeX Workshop. It is very fast and powerful.

Basic Text Formatting

In a normal app, you highlight text and press a "B" button to make it bold. In a .tex file, you wrap the text in a short code.

Bold
\textbf{Warning}
Warning
Italic
\textit{Special}
Special
Underline
\underline{Look}
Look

Bullet Points

Use an itemize block to create standard bullet points. Every new item gets an \item tag.

\begin{itemize} \item Apples \item Bananas \item Oranges \end{itemize}

Numbered Lists

If you want 1, 2, 3 instead of bullets, just change the word to enumerate. The computer counts for you.

\begin{enumerate} \item Wake up \item Eat food \item Go to work \end{enumerate}

Adding Pictures

You cannot drag and drop images into a plain text file. Instead, you put the image file in the same folder as your code, and then type a command to pull it in.

// Step 1: Tell the file you want to use images (put at top)

\usepackage{graphicx}

// Step 2: Show the image and set its width

\includegraphics[width=5cm]{logo.png}

Building Data Grids (Tables)

Tables are the hardest part of learning .tex files, but they look incredibly clean once finished.

\begin{tabular}{ |c|c| } \hline \textbf{Name} & \textbf{Age} \\ \hline John & 25 \\ Sarah & 30 \\ \hline \end{tabular}

The Rules:

  • { |c|c| } means two columns, centered, with vertical lines.
  • & is used to jump to the next column.
  • \\ tells the computer to go to the next row.
  • \hline draws a horizontal line across the grid.

The 1-Second Table of Contents

In Word, making a Table of Contents requires updating it every time you move a page. In a .tex file, it is fully automatic.

\tableofcontents

Just type that one line. The program will scan your file for every \section{} and \subsection{}, figure out what page they are on, and build a perfect list for you.

Choosing a Document Type

The very first line of your file decides the layout rules for the whole document.

\documentclass{article}

Best for short reports, homework, or science papers. It does not have chapters, only sections.

\documentclass{report}

Best for longer school papers or company manuals. It supports chapters and title pages.

\documentclass{book}

Best for real books. It formats pages for double-sided printing (left and right margins are different).

1 in
1 in

Fixing Your Margins

By default, .tex files use massive margins designed for reading academic papers. To change them to normal sizes, you use the geometry package.

\usepackage[margin=1in]{geometry}

Put this at the very top of your file to get standard 1-inch margins on all sides.

Making a Cover Page

You do not have to press "Enter" twenty times to center your title. You just provide the data, and the program builds the cover.

\title{My Great Report} \author{John Doe} \date{October 2026} \maketitle
My Great Report
John Doe
October 2026

Magic Page Links (References)

If you type "See Table 4 on page 10", and then add a new table earlier, it becomes Table 5, but your text will still say "Table 4". This is bad. Instead, use magic links.

TAG IT
This is my table. \label{my_cool_table}
LINK IT
Please look at Table \ref{my_cool_table}.

The computer will automatically find the correct number and insert it for you, no matter where you move the table.

Working With a Team

Because a .tex file is just plain text, it is incredibly easy to work on it with other people at the same time.

Overleaf

Works exactly like Google Docs. You share a link, and multiple people can type code into the same file at the same time in the browser.

Git & GitHub

Because it is code, software engineers can use Git to track every single letter that changes, save versions, and merge work together safely.

Ready to try it yourself?

You now know the basics of .tex files. The best way to learn is to copy the code from the "Anatomy" section above, paste it into a blank project on Overleaf, and press "Compile".

Copy Template