Learning Latex
Lecture: Introduction to LaTeX for BS Students
1. What is LaTeX?
LaTeX is a typesetting system commonly used for creating documents that involve complex
formatting, such as scientific papers, theses, and reports. It is especially powerful for:
Mathematics and formulas (e.g., equations and symbols).
Technical documents with consistent styling.
Tables and graphs that require precise alignment.
Unlike word processors (e.g., MS Word), LaTeX uses a markup language where you write
commands in plain text to format your document.
2. Why Learn LaTeX?
1. Professional Appearance: LaTeX produces clean, consistent, and well-formatted
documents.
2. Efficiency in Formatting: Automates numbering (e.g., equations, sections, references).
3. Ideal for Research: Standard in academia for journals and conference papers.
4. Customizability: Easily control document layout and style.
5. Cross-Platform: Works on Windows, macOS, and Linux.
3. Basics of LaTeX
a. Document Structure
Every LaTeX document has three main parts:
\documentclass{article} % Specifies the document type
\usepackage{amsmath} % Adds math capabilities
\begin{document} % Document content starts here
Hello, World!
\end{document} % Document content ends here
b. Commands
Begin with a backslash \.
Followed by the command name.
Example: \section{Introduction} creates a section.
c. Comments
Use % to add comments (ignored by LaTeX).
% This is a comment
4. Writing Your First Document
a. Basic Example
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\title{My First LaTeX Document}
\author{John Doe}
\date{\today}
\maketitle
\section{Introduction}
This is my first LaTeX document. Let's write some math:
\[
E = mc^2
\]
\end{document}
5. Key Features
a. Mathematical Expressions
Inline math: $E = mc^2$
Display math:
\[
\int_{a}^{b} x^2 \, dx
\]
b. Sections and Subsections
\section{Main Section}
\subsection{Subsection}
\subsubsection{Subsubsection}
c. Lists
Itemized List:
\begin{itemize}
\item First item
\item Second item
\end{itemize}
Numbered List:
\begin{enumerate}
\item First item
\item Second item
\end{enumerate}
d. Tables
\begin{table}[h]
\centering
\begin{tabular}{|c|c|c|}
\hline
Header 1 & Header 2 & Header 3 \\
\hline
1 & 2 & 3 \\
\hline
\end{tabular}
\caption{Example Table}
\end{table}
e. Figures
\usepackage{graphicx}
...
\begin{figure}[h]
\centering
\includegraphics[width=0.5\textwidth]{example.jpg}
\caption{Example Image}
\end{figure}
6. LaTeX Tools
a. Editors
1. Overleaf: Online LaTeX editor with collaboration features.
2. Texmaker: Free desktop editor.
3. TeXstudio: Another popular LaTeX editor.
b. Compiling LaTeX
To generate a PDF from your LaTeX file:
1. Write the .tex file.
2. Compile using an editor (e.g., Overleaf) or tools like pdflatex.
7. Common Pitfalls
Unmatched Braces: Always ensure braces {} and brackets [] are closed.
File Names: Avoid spaces in file or image names.
Errors in Commands: Read error logs carefully.
8. Learning Resources
1. Overleaf Documentation: Comprehensive and beginner-friendly.
2. LaTeX Wikibook: Detailed explanations and examples.
3. YouTube Tutorials: Visual guides to learning LaTeX.
9. Practical Activity
1. Install an editor or create an Overleaf account.
2. Write a LaTeX document with:
o A title, author, and date.
o A section with text and a math equation.
o A table and a figure.
3. Compile and generate the PDF.
10. Conclusion
LaTeX is a valuable skill for academic and technical writing. While it has a learning curve,
mastering it will save you time and effort in producing high-quality documents.
Next Steps: Practice with your course assignments or create a LaTeX template for your reports!
Any questions? 😊