Home
2Technical Report Writing with LaTeX
2

Topic 2 of 9 · Labs II–III

Technical Report Writing with LaTeX

Typesetting reports in LaTeX with Overleaf: text and special characters, errors, mathematics, lists, packages, sections, cross-references, figures, tables, algorithms and BibTeX citations.

← → move between slides · F full screen · M slide list

Before we start

Why this matters

Your final report will have 30 figures, 15 tables and 40 references. In a word processor, adding one figure in chapter 2 means renumbering everything after it by hand.

LaTeX numbers figures, tables, sections, equations and citations for you and keeps every cross-reference correct. It is also what IEEE, ACM and most universities expect for technical writing.

This topic covers Lab II (text, errors, maths, packages) and Lab III (structure, references, figures, tables, citations). The playground on the slides compiles as you type.

Outline · Labs II–III

Topics in this chapter

Select a topic to jump to the slide that explains it.

  1. Getting started
  2. Errors
  3. Mathematics
  4. Packages
  5. Structured documents
  6. Figures, tables and code
  7. Citations
  8. The technical report

Concept 1 of 23

What LaTeX is

LaTeX (pronounced “lay-tek” or “lah-tek”) is a document preparation system used worldwide for scientific papers, theses, books and slides. You write plain text with commands; a compiler turns it into a beautifully typeset PDF.

  • It separates content from style: change the document class or a package and the whole layout changes.
  • It numbers sections, figures, tables and equations automatically and keeps every cross-reference right.
  • It builds the table of contents and bibliography for you.
  • Journals and conferences (IEEE, ACM, Springer) publish LaTeX templates: you add only the content.

Concept 1 of 23

What LaTeX is (cont.)

You edit .tex (and .bib) files; the compiler produces the PDF plus helper files.
Overleaf is a free website that compiles LaTeX in the browser — nothing to install, and your whole team can edit the same report at once.

Getting started

Your first document

LaTeX source
\documentclass{article}
\begin{document}
Hello World! % your content goes here...
\end{document}
Output · what the PDF shows

The comment after % is not printed.

  • Commands start with a backslash \.
  • Every document starts with \documentclass; the argument in { } says what kind: article, report, book, beamer (slides).
  • Optional arguments go in [ ]: \documentclass[12pt,twocolumn]{article}.
  • A % starts a comment: LaTeX ignores the rest of the line.

Everything before \begin{document} is the preamble (settings and packages). Everything between \begin{document} and \end{document} is the body that gets printed.

ClassUse it for
articlelab reports, papers, short reports
reportlong reports and theses with chapters
bookbooks
beamerpresentation slides

Interactive

Try it: typesetting text

Interactive

Try it: typesetting text (cont.)

Words are separated by one or more spaces; paragraphs by one or more blank lines. Extra spaces in the source are collapsed in the output.

Typesetting text

Special characters

Ten characters have special meanings. Typing them directly causes an error or a surprise.

CharacterMeaning in LaTeXTo print it
%comment\%
$start/end maths\$
&table column separator\&
#macro parameter\#
_ ^subscript / superscript (maths)\_ \^{}
{ }grouping\{ \}
~non-breaking space\textasciitilde
\starts a command\textbackslash

Quotes: use `` and '' for “double” and ` ' for ‘single’ quotes.

Typesetting text

Special characters (cont.)

Typesetting text

Handling errors

When LaTeX cannot understand the source it stops with an error and a line number. For example, misspelling \emph as \meph gives Undefined control sequence.

Advice on errors

  1. Don’t panic — errors happen to everyone.
  2. Fix them as soon as they appear: if what you just typed caused an error, start there.
  3. If there are several errors, fix the first one; the cause may even be on a line above it.
MessageUsual cause
Undefined control sequencemisspelt command, or a package not loaded
Missing $ inserted_, ^ or a maths command used outside $…$; or a blank line inside maths
Misplaced alignment tab character &an & in normal text: write \&
\begin{x} ended by \end{y}environments closed in the wrong order
Environment align undefined\usepackage{amsmath} missing
Reference … undefineda \label is missing or misspelt; or compile again

Exercise

Exercise 1: find and fix the errors

Exercise

Exercise 1: find and fix the errors (cont.)

Show the fixed text

The whole corrected source: select all of it and paste it over the text in the box above.

LaTeX source
\documentclass{article}
\begin{document}
In March 2006, Congress raised that ceiling an additional \$0.79
trillion to \$8.97 trillion, which is approximately 68\% of GDP. As of
October 4, 2008, the ``Emergency Economic Stabilization Act of
2008'' raised the current debt ceiling to \$11.3 trillion.
\end{document}
Output · what the PDF shows

\$ and \% print the characters; ``…'' gives curly quotes instead of straight ".

Concept 7 of 23

Mathematics: inline and displayed

  • Dollar signs mark maths in the text: $c = a - b + 1$. Always use them in pairs.
  • LaTeX handles spacing in maths itself — it ignores your spaces.
  • Big formulas go on their own line in an equation environment, which is numbered; equation* (from amsmath) is unnumbered.
  • Do not leave blank lines inside maths.
You typeYou get
x^2, x_isuperscript, subscript
\frac{a}{b}a fraction
\sqrt{b^2-4ac}a square root
\sum_{k=1}^{n}a sum with limits
\alpha, \pi, \inftyGreek letters, ∞
\leq, \geq, \neq, \pm≤ ≥ ≠ ±

Concept 7 of 23

Mathematics: inline and displayed (cont.)

LaTeX source
The roots of a quadratic equation are given by
\begin{equation}
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
\end{equation}
where $a$, $b$ and $c$ are \ldots
Output · what the PDF shows
Environments change how commands behave: \sum is small with side limits in text, and large with limits above and below in a displayed equation.

Mathematics

amsmath: operators and aligned equations

LaTeX source
\usepackage{amsmath}   % in the preamble

\begin{equation*}
\min_{x,y} (1-x)^2 + 100(y-x^2)^2
\end{equation*}

\begin{equation*}
\beta_i = \frac{\operatorname{Cov}(R_i, R_m)}{\operatorname{Var}(R_m)}
\end{equation*}

\begin{align*}
(x+1)^3 &= (x+1)(x+1)(x+1) \\
        &= (x+1)(x^2 + 2x + 1) \\
        &= x^3 + 3x^2 + 3x + 1
\end{align*}
Output · what the PDF shows

The three lines line up at the = signs, where the & is.

Mathematics

amsmath: operators and aligned equations (cont.)

  • LaTeX reads adjacent letters as variables multiplied together, so min would print in italics. amsmath defines upright operators such as \min, \max, \log.
  • \operatorname{Cov} makes your own operator.
  • In align*, & marks the alignment point (before the =) and \\ starts a new line.
  • align without the star numbers every line; add \nonumber to skip one.

Interactive

Try it: maths

Interactive

Try it: maths (cont.)

Change a formula and watch the page. Try deleting a $ or the \usepackage{amsmath} line to see the errors LaTeX gives.

Exercise

Exercise 2: typeset the central limit theorem

Exercise

Exercise 2: typeset the central limit theorem (cont.)

Show the answer

The whole corrected source: select all of it and paste it over the text in the box above.

LaTeX source
\documentclass{article}
\usepackage{amsmath}
\begin{document}
Let $X_1, X_2, \ldots, X_n$ be a sequence of independent and identically
distributed random variables with $\operatorname{E}[X_i] = \mu$ and
$\operatorname{Var}[X_i] = \sigma^2 < \infty$, and let
\begin{equation*}
S_n = \frac{1}{n}\sum_{i=1}^{n} X_i
\end{equation*}
denote their mean. Then as $n$ approaches infinity, the random variables
$\sqrt{n}(S_n - \mu)$ converge in distribution to a normal $N(0, \sigma^2)$.
\end{document}
Output · what the PDF shows

Structure

Environments and lists

LaTeX source
\begin{itemize}   % bullet points
  \item Biscuits
  \item Tea
\end{itemize}

\begin{enumerate}  % numbers
  \item Biscuits
  \item Tea
    \begin{itemize}
      \item green      % lists can nest
    \end{itemize}
\end{enumerate}

\begin{description}
  \item[SRS] Software Requirements Specification
\end{description}
Output · what the PDF shows

Three lists: bullets, numbers with a nested bullet list inside item 2, and a description list with a bold label.

Structure

Environments and lists (cont.)

  • \begin{name} … \end{name} creates an environment: a context that changes how its content is typeset.
  • itemize gives bullets, enumerate numbers, description bold labels.
  • Every \begin needs a matching \end, closed in reverse order.
  • You could even write $…$ as \begin{math}…\end{math}.

Concept 12 of 23

Packages

All the commands so far are built into LaTeX. Packages are libraries of extra commands; load each one with \usepackage in the preamble.

PackageGives youPackageGives you
amsmathequation*, align, \eqref, operatorsgraphicx\includegraphics for images
hyperrefclickable links and referencesbiblatexcitations and bibliography
booktabsprofessional table rulescaption, subcaptioncaption styling, subfigures
algorithm, algpseudocodenumbered pseudocodelistingssource code with highlighting
geometrypage marginsxcolorcoloured text
float[H] “put the figure exactly here”tabularxtables that fill the line width

Concept 12 of 23

Packages (cont.)

LaTeX source
\documentclass{article}
\usepackage{amsmath}   % preamble
\begin{document}
% now we can use commands from amsmath here...
\begin{align*}
a^2 + b^2 &= c^2 \\
\max(a, b) &\leq c
\end{align*}
\end{document}
Output · what the PDF shows

Delete line 2 and the previewer reports Environment align* undefined: align* comes from amsmath.

Concept 13 of 23

Title, abstract and sections

LaTeX source
\documentclass{article}
\title{The Title}
\author{A. Author}
\date{\today}
\begin{document}
\maketitle
\begin{abstract}
Abstract goes here...
\end{abstract}
\tableofcontents

Concept 13 of 23

Title, abstract and sections (cont.)

\section{Introduction}
The problem of \ldots
\section{Method}
We investigate \ldots
\subsection{Sample Preparation}
\subsection{Data Collection}
\section{Results}
\section{Conclusion}
\end{document}
Output · what the PDF shows

Concept 13 of 23

Title, abstract and sections (cont.)

Concept 13 of 23

Title, abstract and sections (cont.)

Every heading is numbered for you, and the contents list is built from them (after the second compile).

  • Tell LaTeX the \title, \author and \date in the preamble; \maketitle prints them.
  • The abstract environment makes an abstract.
  • \section, \subsection, \subsubsection are numbered automatically (1, 1.1, 1.1.1).
  • \section* gives an unnumbered heading that is left out of the table of contents.
  • In the report class, \chapter sits above \section.
  • \tableofcontents needs two compiles to fill in.

Structured documents

Labels and cross-references

LaTeX source
\usepackage{amsmath}   % for \eqref
...
\section{Introduction}
\label{sec:intro}
In Section~\ref{sec:method}, we \ldots

\section{Method}
\label{sec:method}
\begin{equation}
\label{eq:euler}
e^{i\pi} + 1 = 0
\end{equation}
By \eqref{eq:euler}, we have \ldots
Output · what the PDF shows

\ref{sec:method} became 2 and \eqref{eq:euler} became (1); the ~ keeps “Section” and “2” on one line.

Structured documents

Labels and cross-references (cont.)

  • Put \label{key} right after the thing you number (section, equation, caption).
  • Refer to it with \ref{key}; \eqref{key} adds brackets for equations.
  • Never type numbers yourself: if you add a section, every reference updates.
  • Use prefixes so keys are readable: sec:, fig:, tab:, eq:.
  • Write Section~\ref{…}: the ~ stops the line breaking between the word and the number.
  • LaTeX needs two runs: the first records labels, the second prints them. Until then you see ??.

Interactive

Try it: a small report

Interactive

Try it: a small report (cont.)

Change the order of the sections and watch the numbers and the reference update. Delete a \label to see “??” and the warning.

Concept 16 of 23

Figures and floats

LaTeX source
\usepackage{graphicx}   % preamble
...
Figure~\ref{fig:model} shows \ldots

\begin{figure}[htbp]
  \centering
  \includegraphics[width=0.5\textwidth]{model}
  \caption{The iterative model.}
  \label{fig:model}
\end{figure}
Output · what the PDF shows

The striped box stands for your image file model.png. The caption is numbered and the reference says Figure 1.

Concept 16 of 23

Figures and floats (cont.)

  • \includegraphics (from graphicx) inserts JPEG, PNG or PDF images. Options: width=0.5\textwidth (half the text width), angle=270, scale=0.8.
  • Wrapping it in figure makes a float: LaTeX decides where it fits best.
  • Placement hints: h here, t top, b bottom, p own page; [H] (package float) forces “exactly here”.
  • \label must come after \caption, or the reference points to the section instead.
  • Tables go in a table float, usually with the caption above.

Figures, tables and code

Subfigures

Load caption and subcaption, then place several subfigure environments inside one figure. \hfill spreads them across the line.

LaTeX source
\begin{figure}
  \centering
  \begin{subfigure}[b]{0.3\textwidth}
    \centering
    \includegraphics[width=\textwidth]{graph1}
    \caption{$y=x$}
    \label{fig:y equals x}
  \end{subfigure}
  \hfill
  \begin{subfigure}[b]{0.3\textwidth}
    \centering
    \includegraphics[width=\textwidth]{graph2}
    \caption{$y=3\sin x$}

Figures, tables and code

Subfigures (cont.)

    \label{fig:three sin x}
  \end{subfigure}
  \caption{Three simple graphs}
  \label{fig:three graphs}
\end{figure}
Output · what the PDF shows

Each subfigure gets its own letter, (a) and (b), under one shared figure number.

Figures, tables and code

Tables

LaTeX source
\begin{tabular}{|l|r|r|} \hline
Item   & Qty & Unit \$ \\ \hline
Widget & 1   & 199.99  \\
Gadget & 2   & 399.99  \\
Cable  & 3   & 19.99   \\ \hline
\end{tabular}
Output · what the PDF shows
  • The argument gives the column alignment: left, centre, right; p{3cm} wraps text.
  • | draws vertical lines; \hline draws a horizontal line.
  • & separates columns and \\ ends a row — like align*.
  • For reports, the booktabs style (\toprule, \midrule, \bottomrule, no vertical lines) looks more professional.

Figures, tables and code

Tables (cont.)

Figures, tables and code

Algorithms and code listings

LaTeX source
\usepackage{algorithm}
\usepackage{algpseudocode}
...
\begin{algorithm}
\caption{Withdraw cash}
\begin{algorithmic}[1]   % [1] = number every line
\State $i \gets 10$
\If{$i \geq 5$}
    \State $i \gets i - 1$
\Else
    \If{$i \leq 3$}
        \State $i \gets i + 2$
    \EndIf

Figures, tables and code

Algorithms and code listings (cont.)

\EndIf
\end{algorithmic}
\end{algorithm}
Output · what the PDF shows

Figures, tables and code

Algorithms and code listings (cont.)

\If, \Else and \EndIf print the bold keywords and indent the lines for you.

Command names are title-cased: \State, \While, \EndWhile, \For, \Return. The algorithm float adds a caption and number. For real source code, use the listings package instead:

LaTeX source
\usepackage{listings}
\begin{lstlisting}[language=Python]
def incmatrix(genl1, genl2):
    m = len(genl1)
    ...
\end{lstlisting}
Output · what the PDF shows

The code is printed exactly as typed, in a typewriter font (Overleaf also colours the Python keywords).

Interactive

Try it: figures, tables and algorithms

Interactive

Try it: figures, tables and algorithms (cont.)

Swap the two subfigures, add a row to the table or a \State to the algorithm, and watch the numbers and layout follow.

Concept 21 of 23

Citations with BibTeX and biblatex

  1. Create a reference file with the .bib extension (Overleaf: New file → citation.bib).
  2. Find the paper, journal or book in Google Scholar.
  3. Click Cite → BibTeX to get the entry.
  4. Paste the entry into the .bib file.
  5. In the preamble: \usepackage{biblatex} and \addbibresource{citation.bib}.
  6. In the text: \cite{key}; where the list should go: \printbibliography.
  7. Compile (Overleaf runs biber and LaTeX again for you).

Concept 21 of 23

Citations with BibTeX and biblatex (cont.)

citation.bib
@article{guyot2002high,
  title={High solid content latexes},
  author={Guyot, A and Chu, F and Schneider, M and Graillat, C and McKenna, TF},
  journal={Progress in Polymer Science},
  volume={27}, number={8}, pages={1573--1615},
  year={2002}, publisher={Elsevier}
}
Output · in the reference list

The entry appears like this in the list once it is cited with \cite{guyot2002high}.

Concept 21 of 23

Citations with BibTeX and biblatex (cont.)

Concept 21 of 23

Citations with BibTeX and biblatex (cont.)

Only the entries you actually \cite appear in the list. Use one style consistently (IEEE is common in computing: \usepackage[style=ieee]{biblatex}).

Interactive

Build a BibTeX entry

Concept 23 of 23

Writing the technical report

SectionContents
Title pagecourse, project title, team members and IDs, date
Abstract150–250 words: problem, approach, result
Introductionproblem, motivation, objectives
Background / related workexisting systems with citations
Methodology & designSRS, SDLC choice, DFD, UML, UI
Implementation / outputscreens, results, figures with captions
Discussion & conclusionwhat worked, limits, future work
Referencesgenerated from the .bib file
  • Every figure and table has a numbered caption and is referred to in the text before it appears.
  • Write in plain, precise sentences; prefer active voice (“The system stores…”).
  • Keep one file per chapter and join them with \input{intro} — easier for a team.
  • Keep images in a figures/ folder; export diagrams as PDF or PNG at good resolution.
  • Academic integrity: cite every source; copied text or diagrams can cost full marks.

Worked example 1 of 3

Worked example 1

Write the LaTeX for: “The profit was 25% higher & the cost fell by $2,000 (see Table 3).” where Table 3 has the label tab:cost.
Show the solution
LaTeX source
The profit was 25\% higher \& the cost fell by \$2,000
(see Table~\ref{tab:cost}).
Output · what the PDF shows

Assuming the table labelled tab:cost is the third table in the report.

Escape %, & and $; never type the table number yourself.

Worked example 2 of 3

Worked example 2

Typeset the quadratic formula as a numbered equation and refer to it in the next sentence.
Show the solution
LaTeX source
\begin{equation}
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
\label{eq:quadratic}
\end{equation}
Equation~\eqref{eq:quadratic} gives both roots.
Output · what the PDF shows
\eqref needs \usepackage{amsmath}.

Worked example 3 of 3

Worked example 3

A figure appears as “Figure 1.1” in a reference but it is the only figure in the report. What went wrong?
Show the solution
The \label was placed before \caption (or outside the figure), so it captured the current section number (1.1). Move \label{fig:…} directly after \caption{…}.

Practice

Practice (1 of 2)

Try each one on paper first, then check your answer.

1. What is the difference between \section{Results} and \section*{Results}?
Show the answer
The starred version is not numbered and does not appear in the table of contents.
2. Which package is missing if LaTeX reports “Undefined control sequence \includegraphics”?
Show the answer
graphicx: add \usepackage{graphicx} to the preamble.
3. Write a 3-column table (left, centre, right) with a line above and below the header row.
Show the answer
LaTeX source
\begin{tabular}{lcr}
\hline
Name & Qty & Price \\
\hline
Pen & 2 & 20 \\
\end{tabular}
Output · what the PDF shows

Practice

Practice (2 of 2)

Try each one on paper first, then check your answer.

4. Why do you sometimes see “??” in the PDF instead of a number?
Show the answer
A \ref points to a label LaTeX does not know yet. Either the label is missing or misspelt, or the document needs to be compiled a second time.
5. Write the BibTeX key and \cite command for an entry that starts with @inproceedings{rahman2023atm,.
Show the answer
\cite{rahman2023atm} — the key is the text between { and the first comma.
6. Typeset $S_n = \frac{1}{n}\sum_{i=1}^{n} X_i$ as an unnumbered displayed equation.
Show the answer
LaTeX source
\begin{equation*}
S_n = \frac{1}{n}\sum_{i=1}^{n} X_i
\end{equation*}
Output · what the PDF shows
Requires amsmath; or use \[ … \] without any package.

Check yourself

Quiz

Summary

Summary

  • LaTeX separates content from style and numbers everything automatically; Overleaf compiles it online.
  • Escape the special characters # $ % & _ { } ~ ^ \; fix the first error first.
  • Maths goes in $…$ inline or equation/equation*/align* on its own line (amsmath).
  • Load extra features with \usepackage in the preamble.
  • Structure with \section; refer with \label + \ref/\eqref — never type numbers.
  • Figures and tables are floats with \caption then \label; tables use & and \\.
  • Cite with BibTeX: .bib file, \addbibresource, \cite, \printbibliography.