Exercises: Writing Scientific Reports in LaTeX

These exercises are designed to help you practice the key LaTeX skills needed to write a scientific report. Work through them in Overleaf, starting with the simpler ones and progressing to more complex tasks.

You can access your account from this link: Overleaf - University of Bristol

Exercise 1: Starting from Scratch - Your First Scientific Report

Objective: Create a complete but minimal LaTeX document for a scientific report and compile it successfully in Overleaf.

Instructions:

Create a new blank Overleaf project. Your document should include the basic structure of a scientific report with all four main sections (Introduction, Methodology, Results, and Conclusions). For now, you can use placeholder text (Lorem ipsum or a few sentences of your own).

Start with the document class article, ensure you have a proper preamble with necessary packages like geometry for page margins, and set a title for your report. Use \maketitle to display the title, and organize your sections with \section{} commands. Each section should have at least one paragraph of content.

The goal is to understand the overall structure and ensure your document compiles without errors. Pay attention to the basic hierarchy: document class → preamble → \begin{document} → title and sections → \end{document}.

Exercise 2: Exploring the revtex4-2 Template

Objective: Familiarize yourself with the specific template provided for your Project 4 report (download) and understand how it differs from the standard article class.

Instructions:

The provided template uses revtex4-2 as its document class, which is specifically designed for scientific papers and reports. Upload the provided templat zip file into a new Overleaf project and compile it. This template includes several features that go beyond the standard article class.

Examine the document class line: \documentclass[aps,prb,reprint,twocolumn]{revtex4-2}. The options aps,prb,reprint,twocolumn customize the appearance. Research or experiment with what happens if you modify these options (for example, remove twocolumn to see single-column formatting, or replace reprint with draft).

Notice the template includes an abstract section between the title information and \maketitle. This is specific to revtex. Read the comments in the template carefully—they provide guidance on figure sizes (3.34 inches for a column width), file formats (PDF preferred), and citation practices.

Observe how the template structures the author affiliation using \affiliation{} instead of including it in \author{}. Try modifying the title, author, and affiliation to make it your own. Then, explore how revtex automatically formats the section numbering, bibliography style (apsrev4-2), and other elements.

Finally, compare your revtex document with the simpler article class document from Exercise 1. Note the differences in spacing, margins, typography, and how sections are numbered. This template is polished and publication-ready, reflecting the professional standards you should strive for in your final report.

The goal is to become comfortable with the revtex template before you start filling it with your own content and analysis.

Exercise 3: Creating a Professional Title Section with \maketitle

Objective: Set up a proper title page with author, date, and institutional affiliation.

Instructions:

Take the document from Exercise 1 (or 2 if you prefer) and enhance the title section. In your preamble, use \title{} to set a descriptive title for a computational project. Add yourself as the \author{} and include additional information such as department, university, or affiliation.

Set the \date{} command to a specific date, or leave it empty if you prefer. Consider using the \date{\today} command to automatically display the current date. Then use \maketitle in your document to generate the title page. Compile and observe how LaTeX formats this automatically.

Exercise 4: Inserting and Positioning a Figure

Objective: Add a figure to your report with a caption and label, and reference it in the text.

Instructions:

You will need the graphicx package for this exercise.

Create or download a simple image (a plot, diagram, or any figure you have) that you have produced in Python. Save it in a suitable format paying attention to the figure size and font size:

  • for a single-column figure, aim for a width of around 3.34 inches (or 8.5 cm).
  • for a double-column figure, aim for a width of around 7 inches (or 17.8 cm).

If the figgure is mostly lines, you may want to use a vector format like PDF or SVG. If it is a photo or has many color 9e.g. a colormap), a raster format like PNG is fine.

Upload your figure to your Overleaf project (e.g. via drag and drop).

In the Results section of your document, create a figure environment using figure with the [t] or [tb] placement specifier. Inside the environment, use \includegraphics{} to insert your image, specifying a width (such as width=0.8\textwidth). Play with other placement options like [h] (here) or [b] (bottom) to see how LaTeX handles figure placement.

Add a caption beneath the figure using \caption{} that describes what the figure shows in a clear and informative way. Use \label{fig:something} to give your figure a meaningful label. Then, in the text above or below the figure, reference it using \ref{fig:something} or \autoref{fig:something} (if using the hyperref package).

Compile and verify that the figure appears in the correct position, the caption is formatted properly, and the reference number updates automatically.

Exercise 5: Constructing a Data Table

Objective: Create a well-formatted table with data and a caption, and reference it in the text.

Instructions:

In your Results section, create a table environment using table with a placement specifier. Inside the table environment, use the tabular environment to structure your data. Define columns using a format string (for example, {|c|c|c|} for three centered columns with borders, or {lrr} for a left-aligned column followed by two right-aligned columns).

Use & to separate columns and \\ to move to the next row. Add a horizontal line with \hline to separate the header row from the data. Include a caption with \caption{} and a label with \label{tab:something}. Reference your table in the text using \ref{tab:something}.

For a more polished appearance, consider using the booktabs package and replacing lines with \toprule, \midrule, and \bottomrule instead of \hline.

Exercise 6: Debugging a LaTeX Error

Objective: Identify and fix common LaTeX compilation errors.

Instructions:

In a new Overleaf project, intentionally introduce errors to practice debugging. Start with a working document from one of the previous exercises. Then introduce one or more of these common mistakes: missing a closing brace }, forgetting to end a section, misspelling a command, or using a character that needs escaping (like an unescaped & or % outside of a table).

Try to compile the document and read the error message carefully. The error output will tell you the line number and the nature of the problem. Use this information to locate and fix the error. Repeat with different types of errors to become familiar with how LaTeX reports problems.

This exercise teaches you to read and interpret compilation errors, which is essential for efficient debugging.

Exercise 7: Working with Mathematical Equations

Objective: Include both inline and display equations in your report, with proper numbering and referencing.

Instructions:

In your Methodology section, introduce mathematical notation. Use inline math mode with $...$ when writing formulas within a sentence (for example, “We compute the mean \(\bar{x} = \frac{1}{n}\sum_{i=1}^{n} x_i\)”).

For more prominent equations that deserve their own line, use the equation environment or align environment (for multiple equations). Inside these environments, add a \label{} to make the equation referenceable. For example, define a key metric or model equation and label it. Then, in your text, reference it using \eqref{} (note: use \eqref{} rather than \ref{} for equations, as it automatically adds parentheses).

An example of an equation environment is the following:

\begin{equation}
E = mc^2
\label{eq:einstein}
\end{equation}

You can then reference this equation in your text with \eqref{eq:einstein}.

Ensure the amsmath package is included in your preamble. Comment and uncomment its inclusion line and observe the resulting errors (if any). Compile and verify that equations are numbered correctly and references update automatically.

Exercise 8: Incorporating a Bibliography

Objective: Set up a bibliography and cite sources within your report.

Instructions:

Create a simple .bib file in your Overleaf project (you can do this by creating a new file). Add several BibTeX entries for different types of sources: a book, a journal article, a website, and a dataset. Use realistic entries based on the examples from the lecture.

In your LaTeX document, include \usepackage{natbib} or rely on the default bibliography handling. Near the end of your document (after your Conclusions section), add **\bibliographystyle{} with a suitable style (see the correspoding section in the lecture).

In your Introduction or Methodology section, cite one or more of your sources using \cite{} with the key from your BibTeX entry. Compile the document, and LaTeX will automatically generate the bibliography and number your citations.

Exercise 9: Creating a Report with Multiple Sections

Objective: Build a structured multi-section report and add an automatic table of contents.

Instructions:

Expand your report to include five sections: Introduction, Methodology, Results, Conclusions, References. Use \section{} for main sections and \subsection{} where appropriate.

Exercise 10: Formatting Text with Emphasis and Special Styles

Objective: Apply various text formatting and styles to enhance readability and emphasize key points.

Instructions:

In different sections of your report, practice text formatting. Use \textbf{} for bold text when emphasizing key terms or results. Use \textit{} for italic text when introducing new concepts or for variable names. Use \underline{} sparingly for highlighting.

Experiment with font sizes using commands like \large, \Large, \small, or \tiny within appropriate contexts (avoid making normal body text too large or small, but these can be useful for headers or footnotes).

Practice creating lists: use the itemize environment for bullet points and the enumerate environment for numbered lists. Nest lists within lists if needed. This formatting helps break up text and make your report more scannable.

The syntax for these environments is straightforward:

% For bullet points:
\begin{itemize}
    \item First bullet point
    \item Second bullet point
\end{itemize}   
% for numbered lists:
\begin{enumerate}
    \item First numbered item
    \item Second numbered item
\end{enumerate}

Compile and review how different formatting affects readability. Remember the principle of clarity: formatting should guide the reader to important information, not overwhelm the page.