Initial push of previous course

This commit is contained in:
Bjornar Orjansen Kaarevik 2025-02-12 23:34:31 +01:00
parent 305d17e370
commit 11675375cb
11 changed files with 409 additions and 0 deletions

View File

@ -0,0 +1,3 @@
\section{The Appendix}
\lipsum[1]

View File

@ -0,0 +1,71 @@
\section{Figures and tables}
\subsection{Figures}
\begin{figure}[!h]
\centering
\includegraphics[width=\linewidth]{figures/abc.png}
% \linewidth refers to the "current line" which may be different from \textwidth which is the text area in general
% \includegraphics{figures/abc.png}
\caption{The caption of the figure}
\label{fig:abc_figure} % Tells the compiler that this environment can be referenced and pointed to
\end{figure}
% The \ref{} command fetches the relevant number and makes it show up in the outputted pdf.
A reference to figure \ref{fig:abc_figure}.
\begin{figure}[!htbp]
\centering % Centering is done within the text area
% pdf's may be shown as graphics, especially nice if the pdf is vector based and therefore scalable
\includegraphics[width=1.05\textwidth]{figures/p2b-real-zt.pdf} % It is too wide to be contained in the text area
\caption{The caption of the other figure, we can show pdf's which may or may not be vector graphics.}
\label{fig:other_figure}
\end{figure}
% \begin{env_name}{first_arg}{second_arg}
% First argument for wrapfigure is figure justification
% l: left, r: right, c: center, o: outer, i: inner
% outer and inner are applicable for books
% Second argument for wrapfigure is figure width
% redefines linewidth within the environment
\begin{wrapfigure}{l}{0.33\textwidth} % .33\textwidth defines a new linewidth for this env
% \centering % Centering is done within the environment and overrides the l justification
\includegraphics[width=0.5\linewidth]{figures/abc.png}
% .5\linewidth uses only half of the space available
\caption{A third figure, but still the same picture. I }
\label{fig:third_figure}
\end{wrapfigure}
\newpage
\subsection{Tables}
\begin{table}[!htbp]
\setstretch{0.5} % Huddles lines closer together; it's cold outside
\centering % Centers on the page
\caption{Linking equations with desired functionality and proper function name in python.} % The caption may be put above instead of below
\vspace{2mm}
\begin{tabular}{clr} % c: center; l: left; r: right; |: v-line
\hline % Inserts a horizontal line
Equation & Action & Function name \\
\hline
\ref{eq:forward_sweep} & Forward sweep & \verb|getZ| \\
\ref{eq:forward_sweep} & Approximate values from the ANN & \verb|getUpsilon| \\
&&\\
\ref{eq:first_back_prop} & Start back propagation & \verb|getPK| \\
\ref{eq:back_prop} & Rest of the back propagation & \verb|getP| \\
\\
\ref{eq:Yc} & $Y_c$ simplification & \verb|getYc| \\
\ref{eq:nu} & $\nu$ simplification & \verb|getNu| \\
\ref{eq:Hk} & $H^{(k)}$ simplification & \verb|getHk| \\
\\
\ref{eq:my_del_J} & Computation of $\nabla_\theta J$ & \verb|getdelJ| \\
\ref{eq:update_theta} & Updating \(\theta\) & \verb|updateTheta| \\
\hline
\end{tabular}
\label{tab:eq_fn_lookup_table}
\end{table}
% The {fig:...}, {tab:...} and {eq:...} aren't required, but will help differentiating what is being references. Maybe a figure and a table have very similar names, then the fig: and tab: prefixes allow you to separate them.
Referencing the table as table \ref{tab:eq_fn_lookup_table}.
\lipsum[1-2]

View File

@ -0,0 +1,132 @@
\section{Math}
\subsection{Equation}
This is an equation
\begin{equation}
% A lonesome ( will have a fixed size
% But a \left( will be scaled to contain whatever it has to
\langle f, g \rangle_{\left[a, b\right]}
=
\int_a^b f(x)\overline{g(x)} dx
% \\ % The equation env ignores \\
% a^2 + b^2 = c^2
\label{eq:inner_product} % You may label equations for referencing later
\end{equation}
\subsection{Gather}
This is the gather environment
\begin{gather*}
E = mc^2
\\
E^2 =
\frac{ % You
mc^2 % May
} % Use
{ % As
\sqrt{ % Many
1 % Lines
- % As
\frac{ % You
v^2 % Want
}
{ % Sometimes
c^2 % It makes
} % Things more
} % Structured
} % ...though not always...
\end{gather*}
\subsection{Align}
This is an \emph{anonymous} align environment
\begin{align*}
24 &= 8 \cdot 3 \\ % Allows aligning glyphs by using &
&= 4 \cdot 6 \\ % The glyph marked with & on each line
&= 2 \cdot 2 \cdot 2 \cdot 3 % Will be aligned
\end{align*}
\subsection{Inlined math}
% Math can be inlined with \( ..my math.. \) or $..also my math..$
% $_$ is the old TeX way and is not advisable to use
% \(_\) is the more modern LaTeX way and is more robust
A \(\sum_n^k\) sum! And a $\frac{1}{n}$.
% The \[\] is a \displaystyle math environment
% There is no real reason to use it over the \begin syntax, but it's there. This env is displayed on its own line and is not a part of the paragraph in the same way $_$ and \(\) are.
You can also: \[\alpha\] do this.
\subsection{Some symbols}
Greek
\begin{gather*}
\psi,\ \Psi % The "\ " thing forces the insert of a space, otherwise whitespace is ignored
\\
\alpha, \beta, \gamma, \delta % Lower case with _small_ letters
\\
\Gamma, \Delta % Upper case with _Capital_ letter
\\
\epsilon, \varepsilon % Variants with _var_
\end{gather*}
Other things
% If you want a glyph, but don't know what it's called
% Either try something (most glyphs have sensible names)
% Or just search it up online, after a while you'll remember
\begin{gather*}
\nabla, \partial
\\
\int, \iint, \oint
\\
\sum_{i = 1}^{n}, \prod_{1 \leq i \leq n}
\\
\frac{a + ib}{c + id}, i = 1, \dots, n
\\
\bar{x}, \vec{x}, x^\circ
\end{gather*}
Matrices (and vectors)
\begin{gather*}
\begin{pmatrix} % Parantheses
1 & 2 & 3 \\ % Columns separated with &
4 & 5 & 6 \\ % Rows separated with \\
7 & 8 & 9
\end{pmatrix}
,
\begin{bmatrix} % Brackets
1 & 2 & 3 \\
4 & 5 & 6 \\
7 & 8 & 9
\end{bmatrix}
,
\begin{Bmatrix} % _Curly_ brackets
1 & 2 & \\ % You can leave elements empty
4 & \displaystyle\int_0^1x^2 dx & 6 \\ % You can make the elements complicated (and force roomy display with \displaystyle
7 & 8 & 9
\end{Bmatrix}
,
\begin{pmatrix} % Essentially a vector
x_1 \\ x_2 \\ x_3 % Just because \\ causes linebreak, doesn't mean you need a new line in the source
\end{pmatrix}
\end{gather*}
% Defining a new command, don't do it here, do it in the preamble or something similar
% newcommand takes a command name, a number of arguments and the "function body" of the command. The arguments to the new command being defined can be accessed by #<number>
\newcommand{\myvec}[1]{
\begin{pmatrix}
#1
\end{pmatrix}
}
% Works like a charm
\begin{gather*}
\myvec{x_1\\x_2\\x_3} \leftarrow \text{My vector command}
\end{gather*}

View File

@ -0,0 +1,13 @@
\section{Referencing}
I hereby cite \cite{einstein}. % Tells the compiler to put a citation link here
I can also cite \cite{dirac}. % The only citation of dirac, if we remove it, dirac won't show in the References section
% If you're quoting larger passages from your sources, consider putting them in the
% "quote" environment
\begin{quote}
This is a quote which cites %\cite{einstein}
\end{quote}
% Small phrases may be quoted inline with "enquote"
I may also \enquote{quote} my sources \cite{einstein}.

View File

@ -0,0 +1,45 @@
\section{Normal Text} % Top-level heading
\subsection{Level 2} % For divisioning each part/section/chapter for structure
\subsubsection{Level 3} % Second order structure
% \subsubsubsection{Level 4} % This doesn't work, as it doesn't exist
% If you need a fourth level heading, consider just _not_ doing it
% There may exist packages for it, if you're adamant
This is a paragraph.
This is in the same paragraph.
This is still in the same paragraph. % An empty line breaks into a new paragraph
This is another paragraph, however. % \\ forces a linebreak which will come in addition to the "new paragraph" break
\vspace{1em}
\begin{itemize} % Says that what exists inside of here is a bulletpoint list
\item It is possible to \emph{italicize} text with \verb|\emph{}|.
\item It is possible to \textbf{boldface} text with \verb|\textbf{}|.
\item It is possible \textbf{to \emph{nest} these} effects.
\end{itemize}
If you wish to write an entire paragraph, you may write everything on one line. With line-wrapping, this becomes trivial, as it even looks like paragraph. However, for the love of God, do not do this, as it is impossible to debug, should some of your inline things be weird. In addition, version-control systems like git are much more powerful when you use more lines.
\subsection{Lists}
\begin{enumerate}
\item First
\item Second
\item Third
\begin{enumerate}
\setlength{\itemsep}{-0.5em} % Pulls the items closer
\item Nesting
\item Is
\item Nice
\end{enumerate}
\begin{itemize}
\item You can
\item[\LaTeX] Even
\item[*] Do
\item[$\rightarrow$] This
\end{itemize}
\end{enumerate}

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

50
example-document/main.tex Normal file
View File

@ -0,0 +1,50 @@
\documentclass{article} % Tells the compiler to treat the rest in the context of the predefined article type
% Other classes include report and book, among others
\input{preamble} % Input pastes the raw text from the given file
\title{\LaTeX Course}
\author{Some Name Here}
\date{\today}
\begin{document}
\maketitle % Makes the title defined by the commands above and shows it in the pdf
\setlength{\parskip}{0em} % Sets how much space is skipped when a new paragraph appears
\tableofcontents
\listoffigures
\listoftables
\setlength{\parskip}{0em} % 1em gives more air, but the TOC should be tightly packed
\newpage
\section{Introduction}
\lipsum[1-2]
\newpage
\input{doc/text}
\newpage
\input{doc/math}
\newpage
\input{doc/figs-and-tables}
\newpage
\input{doc/referencing}
\appendix % Changes the context of the document env to be appendix based, not "normal document"
\printbibliography % Prints the bilbiography based on the added resoruces and which citations have been done in the document
\newpage
\input{doc/appendix}
\end{document}

View File

@ -0,0 +1,50 @@
% Input encoding, ensures compatibility with UTF-8
\usepackage[utf8]{inputenc} % Only necessary if using pdfLaTeX
% XeLaTeX is a more modern compiler which supports utf8 by default
% Localization
\usepackage[english]{babel} % Babel renews "hardcoded" strings to reflect the given language
%% One example: "Content" -> "Innhold" when setting [norsk]
\usepackage{csquotes} % Recommended with babel or polyglossia
% Just for sample text
\usepackage{lipsum}
% Presentation - paper and margins
\usepackage{geometry} % Gives access to powerful commands for deciding document layout
\geometry{margin=25mm} % All margins around the border
\geometry{paper=a4paper} % Paper size can be set to a4, a5 or many others
% Math packages
\usepackage{amsmath} % Contains many math symbols and environments
\usepackage{amssymb} % Contains additional math symbols
% Figure packages
\usepackage{graphicx} % Allows us to \includegraphics{} for figures
\usepackage{wrapfig} % Allows us to wrap text around a figure
% Referencing
\usepackage{hyperref} % Enables hyper-referencing of all \ref{}'s
% Bibliography
\usepackage[style=ieee]{biblatex} % Most feature-updated bibliography package
% Different styles are set here, such as: apa, ieee, ...
\addbibresource{ref.bib} % Must be in preamble to be defined before it's used
% Appendices
\usepackage{appendix} % Gives access to the appendix-environment
% Formatting
% Either use baselinestretch OR linespread, both is unnecessary
% \renewcommand{\baselinestretch}{1.25} % The "stretch" between lines
% \linespread{1.6} % The "spread" between lines
% \setlength{\parskip}{0em} % Useless here as it is overrided further down (before and after the table of content)
\setlength{\parindent}{1em} % Sets indent for first line in a new paragraph
\usepackage{setspace}
%%% Custom Commands %%%
% Unit commands, ensures math to exponentiate and un-italicises text
\newcommand{\un}[1]{\ensuremath{\, \mathrm{#1}}}

View File

@ -0,0 +1,23 @@
# Installing LaTeX
You may use overleaf.com for your LaTeX projects and documents.
This allows for real-time collaboration and has version control to make sure nothing is lost.
It also keeps everything online in the cloud so you can access it from anywhere.
Overleaf also manages the LaTeX installation, compilation and available packages.
If you want to write documents offline and locally, you must install a LaTeX distribution.
## Distributions
Both MiKTeX and TeX Live are useful distributions, but TeX Live is the most complete and most used.
Both of these distributions should have guides online on how to install.
## The Power of Local Installation
If you've installed LaTeX locally, you can weave different programs together to make things even more flexible and powerful.
If you have `pandoc` you can write a markdown file (or many other document formats) and give this file to `pandoc` and tell it to give you a LaTeX compiled pdf.
You can even integrate python code which is to be run and its output used as information for the source which is to be compiled to a pdf.
Since everything is in plain text files, you may programatically alter any of these text files to do really complex things.
It is, however, way outside of the scope of this course.

22
example-document/ref.bib Normal file
View File

@ -0,0 +1,22 @@
@article{einstein,
author = "Albert Einstein",
title = "{Zur Elektrodynamik bewegter K{\"o}rper}. ({German})
[{On} the electrodynamics of moving bodies]",
journal = "Annalen der Physik",
volume = "322",
number = "10",
pages = "891--921",
year = "1905",
DOI = "http://dx.doi.org/10.1002/andp.19053221004",
keywords = "physics"
}
@book{dirac,
title = {The Principles of Quantum Mechanics},
author = {Paul Adrien Maurice Dirac},
isbn = {9780198520115},
series = {International series of monographs on physics},
year = {1981},
publisher = {Clarendon Press},
keywords = {physics}
}