bergziege/src/bachelorarbeit.typ
2025-12-05 14:33:00 +01:00

408 lines
12 KiB
Typst

#import "@preview/cetz:0.4.1"
#import "@preview/cetz-venn:0.1.4"
== Einführung
Für das Schreiben einer grösseren Arbeit sind Programme wie Microsoft Word oder Google docs gänzlich ungeeignet. Wesentlich besser geeignet sind Code basierte Tool's wie LaTeX oder Typst.
Vergleich von Word, Latex und Typst:
#table(columns: 4,
[Merkmal], [Microsoft Word], [LaTeX], [Typst],
[Typ], [WYSIWYG (What You See Is What You Get) Textverarbeitung], [Markup-Sprache / Textsatzsystem], [Markup-basierte Textverarbeitung (Syntax-orientiert, kompiliert)],
[Bedienung], [Grafische Benutzeroberfläche (GUI), intuitiv], [Code-basiert, steile Lernkurve], [Code-basiert, flachere Lernkurve als LaTeX, moderner],
[Fokus], [Allgemeine Dokumente, schnelle Erstellung], [Wissenschaftliche Arbeiten, technische Dokumente, Bücher, Formeln], [Wissenschaftliche Arbeiten, Berichte, Präsentationen, schneller],
[Komplexität], [Einfach für Grundfunktionen, komplex für Fortgeschrittenes], [Hoch (Code, Pakete, Makros)], [Mittel (einfacher als LaTeX, aber immer noch Code-basiert)],
[Ausgabe], [.docx (nativ), PDF, HTML etc.], [PDF (nativ), DVI, PostScript etc.], [PDF (nativ)],
[Formatierung], [Manuell/visuell, Formatvorlagen], [Makros, Pakete, präzise typografische Kontrolle], [Funktionen, Makros, präzise Kontrolle, oft vordefinierte Stile],
[Formeln], [Eingebauter Formeleditor (oft umständlich)], [Exzellent (TeX-Syntax), professionelle Darstellung], [Gut (ähnliche Syntax wie LaTeX, intuitive Ergänzungen)],
[Zitationen], [Eingebaut (oft rudimentär), Plugins (z.B. Citavi, EndNote)], [BibTeX/BibLaTeX (sehr mächtig und flexibel)], [Eingebaut, flexibel (z.B. mit BibTeX-Dateien)],
[Bilder/Tabellen], [Einfaches Einfügen, Drag & Drop], [Code-basiert, präzise Platzierung, Beschriftungen], [Code-basiert, einfacher als LaTeX, flexiblere Anordnung],
[Anpassbarkeit], [Begrenzt (Themes, Vorlagen)], [Extrem hoch (Pakete, eigene Makros, Klassen)], [Hoch (eigene Funktionen, Stile definierbar)],
)
#pagebreak()
== LaTex, Typst
Dokument aufsetzen und Grundbefehle
#set par(justify: false) // Blocksatz
#table(columns: 3,
[], [Latex], [Typst],
[Seitenformat],
[```tex \documentclass[12pt, a4paper]{article} ``` ],
[Typst hat Standartmässig ein A4 Vormat. \ ```typ #set text(paper: "a3") // (optional) ``` ],
[Blocksatz],
[ ```tex Standartmässig aktiv ``` ],
[ ```typ #set par(justify: true) ``` ],
[Zeilenabstand],
[```tex \linespread{1.25} ```],
[```typ #set par(leading: 0.65em) ```],
[Sprache],
[```tex \usepackage[ngerman]{babel} ```],
[```typ #set text(lang: "de") ```],
[Sielbentrennung],
[```tex Standartmässig aktiv ```],
[```typ #set text(hyphenate: true) ```],
[Font],
[```tex \fontfamily{Helvetica} ```],
[```typ #set text(font: "New Computer Modern") ```],
[Schriftgrösse],
[ Die grundgrösse wird in `\documentclass` festgelegt.
danach kann mit:
#table(columns: 4,
[Befehl], [10pt], [11pt], [12pt],
[```tex \tiny```], [5pt], [6pt], [6pt],
[```tex \scriptsize```], [7pt], [8pt], [8pt],
[```tex \footnotesize```], [8pt], [9pt], [10pt],
[```tex \small```], [9pt], [10pt], [11pt],
[```tex \normalsize```], [10pt], [11pt], [12pt],
[```tex \large```], [12pt], [12pt], [14pt],
[```tex \Large```], [14pt], [14pt], [17pt],
[```tex \LARGE```], [17pt], [17pt], [20pt],
[```tex \huge```], [20pt], [20pt], [25pt],
[```tex \Huge```], [25pt], [25pt], [25pt],
)
die Grösse verändert werden.
],
[```typ #set text(size: 10pt) ```],
[Fett],
[```tex \textbf{bal bla bla} ```],
[```typ *bla bla bla* ```],
[Kusiev],
[```tex \emph{bal bla bla} ```],
[```typ _bla bla bla_ ```],
[Monospace],
[```tex \texttt{bal bla bla} ```],
[```typ `bla bla bla` ```],
[Link],
[```tex \url{https://typst.app} ```],
[```typ https://typst.app ```],
[Label],
[```tex \label{intro} ```],
[```typ <bla bla bla> ```],
[Reference],
[```tex \ref{bla bal bla} ```],
[```typ @NurEinWortSo @[bla bla bla] ```],
[Liste],
[```tex
\begin{itemize}
\item bla
\item bla bla
\item la la la
\end{itemize}
```],
[```typ
- bla
- bla bla bla
- la la la
``` ],
[Nummerierte Liste],
[```tex
\begin{enumerate}
\item erstes
\item zweites
\end{enumerate}
```],
[```typ
+ bla
+ bla bla bla
```],
[Kapietel],
[```tex
\section{Superlicht}
\subsection{unterlicht}
\subsubsection{unter dem unterlicht}
```],
[```typ
= Superlicht
== unterlicht
=== unter dem unterlicht
```],
)
\* optional (muss meistens nicht abgegeben werden)
Bei Typst können auch mehere Parameter auf einmal gesetzt werden:
```typ
#set text(
font: "New Computer Modern",
size: 10pt
)
```
#text(fill: blue)[`#set ...`] wirkt sich auf den folgenden test aus. Soll nur etwas gemcht werden dann kann auch z.B. `#text(size: 16pt)[text]` mit klammern verwendet werden.
#text(size: 16pt)[Das könnte mal noch nützlich sein.]
=== Inhaltsverzeichnis
*Typst*
```typ
#set heading(numbering: "1.")
// 1
// 1.1
#set heading(numbering: "1.a")
// 1
// 1.a
// eigentliches Inhaltsverzeichnis
#outline()
```
*LaTeX*
```tex
\tableofcontents
```
=== Referenz beispiel
```typ
Glaciers as the one shown in
@glaciers will cease to exist if
we don't take action soon!
#figure(
image("glacier.jpg", width: 70%),
caption: [
_Glaciers_ form an important part
of the earth's climate system.
],
) <glaciers>
```
== PDF Generieren
Falls in einer gui umgebung gearbeitet wird gibt es dafür schaltflächen, aber weil wir alle mit vim resp. nvim im Terminal unterwegs sind hier die befehle:
#table(columns: 2,
[Latex],
[ Da es verschieden Compiler gibt:
#table(columns: 2,
[Latex], [```sh pdflatex mydocument.tex```],
[XeTeX], [```sh xelatex mydocument.tex```],
[LuaTeX], [```sh luatex mydocument.tex```]
)],
[Typst], [```sh typst compile mydocument.typ```]
)
#set par(justify: true) // Blocksatz
#pagebreak()
== Symbole
#grid(columns: (1fr, 1fr), gutter: 10pt, [
#table(columns: (1fr, 1fr),
[$plus.minus$], [```typ $plus.minus$ ```],
[$eq$], [```typ $eq$ ```],
[$eq.triple$], [```typ $eq.triple$ ```],
[$approx$], [```typ $approx$ ```],
[$in$], [```typ $in$ ```],
[$in.not$], [```typ $in.not$ ```],
[$emptyset$], [```typ $emptyset$ ```],
[$diameter$], [```typ $diameter$ ```],
[$subset$], [```typ $subset$ ```],
[$subset.eq$], [```typ $subset.eq$ ```],
[$subset.not$], [```typ $subset.not$ ```],
[$subset.not.eq$], [```typ $subset.not.eq$ ```],
[$union$], [```typ $union$ ```],
[$inter$], [```typ $inter$ ```],
[$Delta$], [```typ $Delta$ ```],
[$mu$], [```typ $mu$ ```],
[$Sigma$], [```typ $Sigma$ ```],
[$accent(x, macron)$], [```typ $accent(x, macron)$ ```],
[$accent(x, hat)$], [```typ $accent(x, hat)$ ```],
[$accent(x, tilde)$], [```typ $accent(x, tilde)$ ```],
[$accent(x, arrow)$], [```typ $accent(x, arrow)$ ```],
[$accent(x, harpoon)$], [```typ $accent(x, harpoon)$ ```],
[$root(, 4)$], [```typ $root(, 4)$ ```],
[$root(3, 4)$], [```typ $root(3, 4)$ ```],
[$frac(1, 2)$], [```typ $frac(1, 2)$ ```],
[$sum_i^N$], [```typ $sum_i^N$ ```],
[$abs(5)$], [```typ $abs(6)$ ```],
[$ln(x)$], [```typ $ln(x)$ ```],
[$integral$], [```typ $integral$ ```],
)
], [
#table(columns: (1fr, 1fr),
[$alpha$], [```typ $alpha$ ```],
[$beta$], [```typ $beta$ ```],
[$gamma$], [```typ $gamma$ ```],
[$delta$], [```typ $delta$ ```],
[$epsilon$], [```typ $epsilon$ ```],
[$zeta$], [```typ $zeta$ ```],
[$eta$], [```typ $eta$ ```],
[$theta$], [```typ $theta$ ```],
[$kappa$], [```typ $kappa$ ```],
[$lambda$], [```typ $lambda$ ```],
[$mu$], [```typ $mu$ ```],
[$nu$], [```typ $nu$ ```],
[$xi$], [```typ $xi$ ```],
[$omicron$], [```typ $omicron$ ```],
[$pi$], [```typ $pi$ ```],
[$rho$], [```typ $rho$ ```],
[$sigma$], [```typ $sigma$ ```],
[$tau$], [```typ $tau$ ```],
[$upsilon$], [```typ $upsilon$ ```],
[$phi$], [```typ $phi$ ```],
[$chi$], [```typ $chi$ ```],
[$psi$], [```typ $psi$ ```],
[$omega$], [```typ $omega$ ```],
)
])
== Farben
#table(columns: (1fr,) * 9, gutter: 6pt, align: (center + horizon), stroke: none,
table.cell(fill: black)[#text(fill: white)[black]],
table.cell(fill: gray)[gray],
table.cell(fill: silver)[silver],
table.cell(fill: white, stroke: black)[white],
table.cell(fill: navy)[#text(fill: white)[navy]],
table.cell(fill: blue)[blue],
table.cell(fill: aqua)[aqua],
table.cell(fill: teal)[teal],
table.cell(fill: eastern)[eastern],
table.cell(fill: purple)[#text(fill: white)[purple]],
table.cell(fill: fuchsia)[fuchsia],
table.cell(fill: maroon)[maroon],
table.cell(fill: red)[red],
table.cell(fill: orange)[orange],
table.cell(fill: yellow)[yellow],
table.cell(fill: olive)[olive],
table.cell(fill: green)[green],
table.cell(fill: lime)[lime],
)
Alternativ kann auch einfach `rgb("#001f3f")` verwendet werden.
== cetz
importieren:
```typ
#import "@preview/cetz:0.4.1"
#import "@preview/cetz-venn:0.1.4"
```
#table(columns: (1fr, 0.7fr),
[```typ
rect((0, 0), (1, 1))
rect((2, 0), (3, 1), fill: blue)
rect((4, 0), (6, 1), fill: rgb(0, 0, 255, 60))
```], [
#cetz.canvas({
import cetz.draw: *
rect((0, 0), (1, 1))
rect((2, 0), (3, 1), fill: blue)
rect((4, 0), (6, 1), fill: rgb(0, 0, 255, 60))
})], [```typ
grid((0, 0), (3, 1), step: 1)
grid((0, -1), (6, -5), step: 2)
```], [
#cetz.canvas({
import cetz.draw: *
grid((0, 0), (3, 1), step: 1)
grid((0, -1), (6, -5), step: 2)
})], [```typ
circle((0, 0))
circle((2, 0), radius: 0.5)
circle((4, 0), radius: (1, 0.5))
```], [
#cetz.canvas({
import cetz.draw: *
circle((0, 0))
circle((2, 0), radius: 0.5)
circle((4, 0), radius: (1, 0.5))
})], [```typ
line((0, 0), (6, 0))
line((0, -1), (6, -1), stroke: (dash: "dashed"))
line((0, -2), (6, -2), mark: (symbol: ">"), fill: blue, stroke: blue)
line((0, -3), (6, -3), mark: (end: ">"), fill: blue, stroke: blue)
```], [
#cetz.canvas({
import cetz.draw: *
line((0, 0), (6, 0))
line((0, -1), (6, -1), stroke: (dash: "dashed"))
line((0, -2), (6, -2), mark: (symbol: ">"), fill: blue, stroke: blue)
line((0, -3), (6, -3), mark: (end: ">"), fill: blue, stroke: blue)
})], [```typ
content((0, 0), [1])
content((0, -1), [Median = 4])
```], [
#cetz.canvas({
import cetz.draw: *
content((0, 0), [1])
content((0, -1), [Median = 4])
})], [```typ
```],[]
)
beispiel code
```typ
#cetz.canvas({
import cetz.draw: *
scale(0.5)
rect((0, 0), (5, 1), fill: blue)
rect((0, 0), (5, 1), fill: rgb(0, 0, 255, 60))
grid((0, 0), (5, 1), step: 1)
circle((3, 5))
circle((3, 5), radius: (1, 0.5))
line((0, 0), (3, 2))
line((6, 0), (6, 2), stroke: (dash: "dashed"))
line((3, 0), (6, 0), mark: (symbol: ">"), fill: blue, stroke: blue)
line((2.5, 0), (2.5, -0.8), mark: (end: ">"), fill: blue, stroke: blue)
content((0.5, 0.5), [1])
content((2.5, -1), [Median = 4])
})
```
#pagebreak()
== Arbeiten mit meheren Verzeichnissen
#grid(columns: (1fr, 0.5fr), gutter: 10pt, [
Wenn mit mehreren Files und Previewern gearbeitet wird, werden Bilder oder andere externe Inhalte nicht korrekt geladen, wenn in einem Unterfile z. B. mit file_1.typ gearbeitet wird, da kein Root-Verzeichnis für Typst definiert ist. Dies kann wie folgt behoben werden: \
```sh export TYPST_ROOT=~/FHGR/photonics ``` \
Respektive bei dir der Pfad, wo das Main.typ liegt. Nun sollte das Vorschau- und auch das Kompilieren eines einzelnen Files funktionieren.
], [```md
main.typ
├── src
│ ├── file_1.typ
│ ├── file_1.typ
│ └── file_1.typ
└── img
├── img_1.png
├── img_2.png
└── img_3.png
```]
)
#pagebreak()
== randome typst stuff
// #show table.cell.where(y: 0): set text(weight: "bold")
#figure(
table(
columns: 4,
stroke: none,
table.header[Test Item][Specification][Test Result][Compliance],
[Voltage], [220V ± 5%], [218V], [Pass],
[Current], [5A ± 0.5A], [4.2A], [Fail],
),
caption: [Probe results for design A],
) <probe-a>
The results from @probe-a show that the design is not yet optimal.
We will show how its performance can be improved in this section.
#line()
#table(
columns: 2,
stroke: (x: none),
align: horizon,
[☒], [Close cabin door],
[☐], [Start engines],
[☐], [Radio tower],
[☐], [Push back],
)
// fill: (x, y) => if y == 0 {gray.lighten(40%)},
// https://typst.app/docs/guides/table-guide/#table-across-pages
// #set block(breakable: true)
// #show figure: set block(breakable: true)