Master the basics of LaTeX with this comprehensive beginner guide. Learn essential commands, document structure, mathematical expressions, citations, and best practices for academic writing.
LaTeX (pronounced “Lay-tech” or “Lah-tech”) is a powerful document preparation system that has become the gold standard for academic and scientific writing. While it may seem intimidating at first, LaTeX offers unparalleled control over document formatting and is essential for anyone writing research papers, theses, or technical documents.
LaTeX is a markup language that separates content from formatting, allowing you to focus on writing while the system handles the layout. Unlike word processors like Microsoft Word, LaTeX produces professional-quality documents with consistent formatting.
For Windows:
For macOS:
For Linux:
sudo apt install texlive-full
sudo apt install texstudio
Create a file named first-document.tex
with this content:
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{geometry}
% Page setup
\geometry{
left=2.5cm,
right=2.5cm,
top=2.5cm,
bottom=2.5cm
}
\begin{document}
\title{My First LaTeX Document}
\author{Your Name}
\date{\today}
\maketitle
\section{Introduction}
This is my first LaTeX document. I'm learning how to create professional documents!
\section{What I've Learned}
LaTeX is a powerful tool for creating:
\begin{itemize}
\item Research papers
\item Theses and dissertations
\item Technical reports
\item Mathematical documents
\end{itemize}
\section{Conclusion}
I'm excited to learn more about LaTeX and create better documents.
\end{document}
.tex
extensionpdflatex first-document.tex
Every LaTeX document has three main parts:
\documentclass{article} % Document class declaration
\usepackage{package} % Package imports
\begin{document} % Document content begins
% Your content here
\end{document} % Document ends
article
: For research papers and short documentsreport
: For longer documents with chaptersbook
: For books and thesesbeamer
: For presentations% Text formatting
\textbf{bold text} % Bold
\textit{italic text} % Italic
\underline{underlined text} % Underlined
\texttt{monospace text} % Monospace font
% Section commands
\section{Section Title} % Numbered section
\subsection{Subsection} % Numbered subsection
\subsubsection{Subsubsection} % Numbered subsubsection
% Lists
\begin{itemize} % Bullet list
\item First item
\item Second item
\end{itemize}
\begin{enumerate} % Numbered list
\item First item
\item Second item
\end{enumerate}
% Paragraphs and spacing
\newpage % Start new page
\newline % Start new line
\\ % Line break
\vspace{1cm} % Vertical space
\hspace{1cm} % Horizontal space
LaTeX’s mathematical capabilities are one of its greatest strengths. For comprehensive mathematical typesetting, refer to our detailed guide on LaTeX Math Mode Mastery.
Use single dollar signs for inline math:
The quadratic formula is $x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$.
Use double dollar signs for displayed equations:
The quadratic formula is:
$$x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$$
For numbered equations:
\begin{equation}
E = mc^2
\end{equation}
% Greek letters
\alpha, \beta, \gamma, \delta, \epsilon
\Alpha, \Beta, \Gamma, \Delta, \Epsilon
% Mathematical operators
\pm, \mp, \times, \div, \cdot
\leq, \geq, \neq, \approx, \equiv
% Subscripts and superscripts
x^2, x_1, x_{i,j}, x^{n+1}
% Fractions and roots
\frac{a}{b}, \sqrt{x}, \sqrt[n]{x}
% Sums and integrals
\sum_{i=1}^{n} x_i
\int_{a}^{b} f(x) dx
% Matrix
\begin{bmatrix}
a & b & c \\
d & e & f \\
g & h & i
\end{bmatrix}
% Multiple equations
\begin{align}
y &= mx + b \\
&= 2x + 3
\end{align}
% Cases
f(x) = \begin{cases}
x^2 & \text{if } x > 0 \\
0 & \text{if } x = 0 \\
-x^2 & \text{if } x < 0
\end{cases}
LaTeX makes managing citations effortless. For a comprehensive guide to bibliography management, see our article on LaTeX Bibliography Management.
% In your document
According to Einstein \cite{einstein1905}, energy equals mass times the speed of light squared.
% Bibliography
\bibliographystyle{plain}
\bibliography{references}
@article{einstein1905,
title={On the electrodynamics of moving bodies},
author={Einstein, Albert},
journal={Annalen der Physik},
volume={322},
number={10},
pages={891--921},
year={1905},
publisher={Wiley Online Library}
}
@book{lamport1994,
title={LaTeX: A document preparation system},
author={Lamport, Leslie},
year={1994},
publisher={Addison-Wesley}
}
% Different bibliography styles
\bibliographystyle{plain} % Standard style
\bibliographystyle{ieeetran} % IEEE style
\bibliographystyle{apa} % APA style
\usepackage{graphicx} % Add this to preamble
% In your document
\begin{figure}[h]
\centering
\includegraphics[width=0.8\textwidth]{image.png}
\caption{A sample image}
\label{fig:sample}
\end{figure}
% Reference the figure
Figure~\ref{fig:sample} shows a sample image.
\begin{table}[h]
\centering
\begin{tabular}{|l|c|r|}
\hline
\textbf{Left} & \textbf{Center} & \textbf{Right} \\
\hline
Data 1 & Data 2 & Data 3 \\
\hline
\end{tabular}
\caption{A sample table}
\label{tab:sample}
\end{table}
\begin{table}[h]
\centering
\begin{tabular}{lcc}
\toprule
\textbf{Variable} & \textbf{Mean} & \textbf{Std Dev} \\
\midrule
Age & 25.3 & 4.2 \\
Height & 170.5 & 8.1 \\
Weight & 65.2 & 12.3 \\
\bottomrule
\end{tabular}
\caption{Descriptive statistics}
\label{tab:stats}
\end{table}
LaTeX automatically handles cross-references:
% Define a section
\section{Methodology}\label{sec:methodology}
% Reference it elsewhere
As discussed in Section~\ref{sec:methodology}, our approach...
% Define a figure
\begin{figure}[h]
\centering
\includegraphics[width=0.6\textwidth]{results.png}
\caption{Experimental Results}\label{fig:results}
\end{figure}
% Reference the figure
Figure~\ref{fig:results} shows our experimental results.
Packages extend LaTeX’s functionality. For a comprehensive list of essential packages, see our guide on Essential LaTeX Packages.
% Essential packages for most documents
\usepackage[utf8]{inputenc} % Character encoding
\usepackage{geometry} % Page layout
\usepackage{graphicx} % Images
\usepackage{amsmath} % Advanced math
\usepackage{amsfonts} % Mathematical fonts
\usepackage{amssymb} % Mathematical symbols
\usepackage{natbib} % Bibliography
\usepackage{hyperref} % Hyperlinks
\usepackage{fancyhdr} % Headers and footers
\usepackage{titlesec} % Title formatting
\usepackage{enumitem} % List customization
\usepackage{xcolor} % Colors
\usepackage{listings} % Code listings
Geometry Package:
\usepackage[margin=1in]{geometry}
Hyperref Package:
\usepackage[colorlinks=true,linkcolor=blue,citecolor=green]{hyperref}
Fancyhdr Package:
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[L]{\leftmark}
\fancyhead[R]{\thepage}
% Define custom commands
\newcommand{\todo}[1]{\textcolor{red}{[TODO: #1]}}
\newcommand{\note}[1]{\textcolor{blue}{[NOTE: #1]}}
\newcommand{\keywords}[1]{\textbf{Keywords:} #1}
% Use them in your document
This needs work \todo{Add more detail}.
This is important \note{Key finding}.
\keywords{LaTeX, document preparation, academic writing}
% Define custom environment
\newenvironment{methodology}
{\begin{description}}
{\end{description}}
% Use the environment
\begin{methodology}
\item[Data Collection] We collected data from...
\item[Analysis] We analyzed the data using...
\end{methodology}
Missing Package:
! LaTeX Error: File `package.sty' not found.
Solution: Install the missing package or use an alternative.
Undefined Control Sequence:
! Undefined control sequence.
Solution: Check spelling and ensure the command exists.
Missing Dollar Signs:
! Missing $ inserted.
Solution: Ensure math expressions are properly enclosed in dollar signs.
% Fix for missing packages
\usepackage{amsmath} % Add to preamble
% Fix for undefined commands
\newcommand{\mycommand}{definition} % Define custom commands
% Fix for math mode issues
$E = mc^2$ % Proper math mode
\usepackage{multicol}
\begin{multicols}{2}
Your text here will be formatted in two columns.
\end{multicols}
\usepackage{listings}
\begin{lstlisting}[language=Python]
def hello_world():
print("Hello, LaTeX!")
\end{lstlisting}
\usepackage{xcolor}
\textcolor{red}{Red text}
\textcolor{blue}{Blue text}
\colorbox{yellow}{Highlighted text}
Once you’re comfortable with the basics, explore:
LaTeX may seem complex at first, but with practice and the right tools, it becomes an incredibly powerful ally in academic and technical writing. The key is to:
Remember, every expert was once a beginner. With dedication and the right approach, you’ll soon be creating professional-quality documents that stand out in the academic world.
Ready to start your LaTeX journey? Try inscrive.io’s collaborative LaTeX editor and experience the power of modern document preparation with real-time collaboration features.
Master the basics of LaTeX with this comprehensive beginner guide. Learn essential commands, document structure, mathematical expressions, citations, and best practices for academic writing.
Read in 20 minutesLearn how to manage citations and bibliographies professionally with BibLaTeX. From basic citations to advanced customization, discover why BibLaTeX is the modern choice for academic writing.
Read in 22 minutesCompare LaTeX and Microsoft Word for academic writing, exploring their strengths, weaknesses, mathematical capabilities, citation management, and when to use each tool for maximum productivity.
Read in 15 minutesComprehensive comparison of online LaTeX editors including inscrive.io, Overleaf, and alternatives. Discover features, pricing, collaboration tools, and GDPR compliance for academic writing.
Read in 23 minutesStay up to date with the roadmap progress, announcements and exclusive discounts feel free to sign up with your email.
We care about the protection of your data. Read our Privacy Policy.