Introduction
The curriculum of PHY146 : Principles of Physics I requires performing experiments studying various laws of physics followed by writing a lab report. For the last lab of the semester, I decided to challenge myself and write the report using \( \LaTeX{} \).
I decided to use the "head on" approach i.e. to learn as I go and document the process.
Preamble
Here is what the preamble of my report looked like:
The first line defines the type of document or template used.
The "\usepackage" are all the additional packages that I used.
\documentclass [12pt, titlepage]{article}
\usepackage[margin=0.8in]{geometry}
\usepackage{tabularx}
\usepackage{float}
\usepackage{graphicx}
\graphicspath{ {./figures/} }
\usepackage{siunitx}
\usepackage{gensymb}
\usepackage{booktabs}
\begin{document}
Adding Comments
% can be used to comment out an entire line or trailing part of a line.
This is a fraction: $ {a \over b} %this is a trailing comment $
$ % Use it at the start of the line to comment out the entire line. $
This is a fraction within a fraction ${a \over {b \over c}}$
This is a fraction: \( {a \over b} %this is a trailing comment \)
\( % Use it at the start of the line to comment out the entire line. \)
This is a fraction within a fraction \({a \over {b \over c}}\)
Comments are a useful tool in any language (markup or otherwise). The motive of adding comments is to make the code readable.
Relevant stackexchange Relevant xkcd
This is a fraction within a fraction \({a \over {b \over c}}\)
SI Units
Every physical measurement is composed of two components i.e. a numerical value and a unit.
SIUnitx package provides a seamless way of including units in \( \LaTeX{} \).
A detailed guide the package can be found here.
The basic structure of writing a measurement is to start with the tag "\qty" followed by the numerical value in curly brackets, followed by the units in curly brackets.
Unline writing the units is MS Word or similar document editors, SIUnitx require to write the name of the unit preceeded by backslash rather than the sybmol.
For instance to write the mass of a body, you will write: "\qty{1.00}{\kilogram}". Composite units can be chained in the similar fashion. Some examples follows:
$g = \qty{9.81}{\metre\per\second\squared}$
$\rho_{ball} = \qty{1.25}{\kilogram\per\metre\cubed}$
\( g = 9.81 \) m s\(^{-2} \)
\( \rho = 1.25 \) kg m\(^{-3}\)
One important thing to remember is to only use singular names. So metre instead of metres, Joule instead of joules, etc.
\( \rho = 1.25 \) kg m\(^{-3}\)
Lists
List enumeration can be done using the enumerate tag and beginning each item of the list with the "\\item" tag
A comprehenisve guide can be found here
\begin {enumerate}
\\item point1
\\item point2
\end {enumerate}

Tables
tabularx is the package that I used to make tables.
There are tools such as this one that can be used to create tables using a UI.
Although it is important to know how the syntax works to tailor the table to your needs, I found this tool really useful to create the layout and data enter.
A simple table is shown below:
A lot is going on here so let's break it down.
1. We start with the familiar begin tag that is followed by "[H]". This forces the table to to be placed at the same relative position in pdf as it is in the markup file. This functionality comes from the float package.
2. The centering tag and as the name suggests, it center aligns the table.
3. Next we have the table caption. This is the same caption that will appear in the table of contents.
4. The label tag creates a name for the table that can be used for referencing the table.
5. The begin tag for tabular followed by "{ c | c }" that defines that the table has two columns (Two Cs), the contents of the columns are centred (c for centre) in the column and the columns are separated by a vertical line (|)
6. The hline tage is for a horizontal line. There are two more hlines that corresponds to start of the table, end of header row, and end of table.
7. Each row is a single line of text with "&" as the column separator and "\\\\" as the end of line\row charachter.
\begin{table}[H]
\centering
\caption{Mass of objects}
\label{tab:mass-table}
\begin{tabular}{c|c}
\hline
Object & Mass (g) \\
\hline
Toy Car & 274.50 $\pm$ 0.05 \\
AAA Battery & 10.00 $\pm$ 0.05
\hline
\end{tabular}
\end{table}

1. We start with the familiar begin tag that is followed by "[H]". This forces the table to to be placed at the same relative position in pdf as it is in the markup file. This functionality comes from the float package.
2. The centering tag and as the name suggests, it center aligns the table.
3. Next we have the table caption. This is the same caption that will appear in the table of contents.
4. The label tag creates a name for the table that can be used for referencing the table.
5. The begin tag for tabular followed by "{ c | c }" that defines that the table has two columns (Two Cs), the contents of the columns are centred (c for centre) in the column and the columns are separated by a vertical line (|)
6. The hline tage is for a horizontal line. There are two more hlines that corresponds to start of the table, end of header row, and end of table.
7. Each row is a single line of text with "&" as the column separator and "\\\\" as the end of line\row charachter.
Figures
A packaged called graphicx can be used to handle adding graphicsc to the document.
In the preamble of this report, the graphicx package was included along with the definition of location of the graphics using the graohicspath tag.
The syntax is a simpler version of the table.
The includegraphics tag is where we define the the dimesnsions of the image in square brackets and name of the image file in curly brackets.
The convention for captioning is that the caption for table goes on top of the table and the caption for a figure goes on the bottom of the figure.
So, in table the caption tag was before the content of the table and for the figure, the caption tag is after the content.
\begin{figure}[H]
\centering
\includegraphics[width=10cm,height=7.2cm]{my_image.png}
\caption{A picture}
\end{figure}
Concluding
Units, lists, tables and figures provided me enough tools to write a complete report. For the raw data and calculations, I mainly used excel. In the future I will try to use python to add data and calculations to the markdown document that will likely make the entire process efficient and reduce the chances of typos.