forked from bjornoka/latex-course
4.1 KiB
4.1 KiB
Introductory Course to \LaTeX
What even is \LaTeX?
- 1978: Donald Knuth gets fed up by typographical errors in his documents and creates TeX
- 1984: Leslie Lamport gets fed up with having to write bonkers TeX-commands and piles on a bunch of macros
- 2025: We're here, still stuck with this ancient crap
But actually, it is a pretty good document preparation system.
(a modern alternative is Typst)
What even is a document preparation system?
It is a system that prepares your documents!
Crucial elements:
- What are the contents of the document?
- Where should all the words and sentences go?
- What do we do about equations, figures and tables?
- We need references and appendices and other things, right?!?
First Principle of \LaTeX
Separate content and presentation.
- General classes/types of content
- Styling applies to the entire document
- Just write, and deal with making it pretty later
- The publisher will mangle your document anyways
Second Principle of \LaTeX
Let the system handle book keeping.
- Don't manually update captions and figure numbers
- Don't manually update captions and table numbers
- Don't manually write/update/sort your list of references
Now, how do we use it?
Types of content
- Frontmatter
- Sections, subsections, paragraphs
- Math: both inline and standalone
- Figures and tables
- References (bibiolgraphy)
- Appendices
Document structure
- Preamble
- Frontmatter - title, table of content, list of figures/tables
- (The acutal) Document
- Sections/Chapters
- Text
- Math
- Figures
- Tables
- Sections/Chapters
- Bibliography
- Appendices
Document setup
- Type of document:
\documentclass - Preamble with
\input - Document body with
\begin{document}- This is an environment
- Frontmatter with
\maketitle - Sections with
\input - Bibliography with
\bibliography - Appendices with
\appendix
Part 0: Preamble
Here you might stick:
\usepackage-directives- Custom commands
- For instance those defined with
\newcommand
- For instance those defined with
- Setup for packages used in the document
- Directives for the presentation of the types of content in the document
Tip: Make you preamble self-contained and portable
Part 1: Content
Since content and presentation is mostly separate:
- Content type must be specified in the "raw content"
- Presentation will be defined "elsewhere"
Environments and displays define what you write means
Types of environments:
- Document, math, figure, table, list, quote, bold, italics
Usually specified in the text with:
\begin{content-type}
... what you write goes here
\end{content-type}
Normal text: headings, paragraphs, lists
- Headings
\section,\subsection,\subsubsection
- Paragraphs
- Just add some linebreaks!
- An empty line signifies the boundary between paragraphs
- Lists
itemize: bullet pointsenumerate: numbered list- Can be nested
Tip: For better version control, stick to one sentence, one line
MATH
equation: a single line of mathgather: multiple lines of mathalign: multiple lines that can be lined up\(...\): inline math\[...\]: basically likeequation
We're talking inline (F = ma) versus full display:
[E = mc^2].
Figures and tables
\begin{figure}: figure environment\includegraphics: the graphics to be shown\caption: text under/over the figure, with number\label: name to remember the figure by in the raw latex
\begin{table}: table environment\begin{tabular}: environment for tabulated data\caption: text over/under table, with number\label: allows you to refer to the table in the document
Referencing
\usepackage{biblatex}- Reference list styling
- Many other options
- Needs a file containing available sources
- Put
\addbibresourcein the preamble
- Put
\printbibliography- Options are available for this one as well
Appendices
\usepackage{appendix}\appendix: changes context of the document to "appendices"- Each
\sectionnow defines an appendix, not a "chapter" - Should probably have been an environment, but alas
- Each