Re-order project structure chapter

This commit is contained in:
Florian 2025-11-17 16:07:37 +01:00
parent 774d9cdccd
commit 39ce749036
4 changed files with 148 additions and 142 deletions

View File

@ -326,17 +326,20 @@ Inhaltsverzeichnis
Dokument und Text gliedern
@content
* Öffnet die Datei `document-structure.tex`, die im Ordner `exercises/basic-document-structure` liegt.
* Packt den gesamten Text in der Datei in eine **Document**-Umgebung und schreibt darüber folgende **Präambel**.
::: {.box .warning}
**Schließt alle offenen Tabs** aus vorherigen Aufgaben.
:::
``` {.lang-tex .hljs .fragment}
* Öffnet die Datei `document-structure.tex`, die im Ordner `exercises/basic-document-structure` liegt.
* Packt den gesamten Text in der Datei in eine **document**-Umgebung und schreibt darüber folgende **Präambel**.
``` {.lang-tex .hljs}
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
```
* Öffnet mittels Rechtsklick auf die Datei das Kontextmenü und setzt die Datei als explizites Root-Dokument. Kompiliert sie anschließend.
* Wie ihr sehen könnt, sind in der Datei die Absätze im Dokument mit `\\` erstellt worden. Ersetzt diese durch richtige Absätze.
* Zeit für etwas Struktur! Verwendet für die **Überschriften** die passenden LaTeX-Befehle (`\section` u. ä.).
* Fügt anschließend ein **Inhaltsverzeichnis** in euer Dokument ein.

View File

@ -323,17 +323,20 @@ Table of contents
Structure your document and text
@content
::: {.box .warning}
**Close all open tabs** from previous tasks.
:::
* Open the file `document-structure.tex`. It is located in the directory `exercises/basic-document-structure`.
* Wrap the entire text in a **document** environment and insert the following **preamble**.
``` {.lang-tex .hljs .fragment}
``` {.lang-tex .hljs}
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
```
* In TeXstudio, right click on the file and select “Set as explicit root document.” Next, compile the file.
* As you may already have noticed, **paragraphs** are marked as `\\`. Use real paragraphs instead.
* Time to structure our document! Use LaTex commands to declare all **headings** (`\section`, `\subsubsection`, etc.).
* Add a **table of contents** to your document.

View File

@ -79,6 +79,74 @@ Inhalt von Abschnitt 2.
![](svg/project-structure/hauptdatei-teile-crop.svg){.thin-padding}
@slide(layout=content-only)
@title
Kompilieren des Projekts
@content
* **Nur die Hauptdatei** wird kompiliert, um das fertige PDF-Dokument zu erhalten.
* ++ Fehlermeldungen enthalten dann Verweis, in welcher Unterdatei sie aufgetreten sind.
* ++ Die Unterdateien können wegen ihrer fehlenden Präambel nicht selbstständig kompiliert werden.
@slide(layout=task)
@task-number
3
@title
Ein strukturiertes Projekt
@content
::: {.box .warning}
**Schließt alle offenen Tabs** aus vorherigen Aufgaben.
:::
Im Ordner `exercises/project-structure` findet ihr eine Datei namens `main.tex`.
* Erstellt neue Dateien (z. B. `section1.tex` und `section2.tex` und verschiebt die Abschnitte in diese.
* Importiert die Fragmente anschließend mit Hilfe des `\input`-Befehls.
* Lagert die Präambel auf demselben Weg in eine eigene Datei aus.
* Schaut euch abschließend die Gesamtstruktur unseres Projektarchivs an, beginnend mit `main-exercises.tex` im Wurzelverzeichnis. Wie binden wir hier die einzelnen Abschnitte ein?
@slide(layout=extra-content-only)
@title
PDF-Dokumente einbetten
@content
Das Paket `pdfpages` erlaubt das Einbetten ganzer PDF-Dokumente.
``` {.lang-tex .hljs}
\includepdf[pages={<from>-<to>}]{<file>}
```
Weitere Parameter lassen mehrere Seiten in Kacheln nebeneinander erscheinen oder ändern die Ausrichtung zu Querformat. Die [Paket-Dokumentation](https://www.ctan.org/pkg/pdfpages) enthält eine abschließende Liste aller Möglichkeiten.
@slide(layout=extra-wide-content)
@title
Makros
@content
Manchmal ist es nützlich, oft genutzten Codes durch Makros zu vereinfachen.
``` {.lang-tex .hljs}
\newcommand{\<name>}[<parameter_count>][<default>]{<content>}
```
Im Skript haben wir solche Makros unter anderem verwendet, um Abstände und Akronyme zu definieren (siehe `commands.tex` für weitere Beispiele):
``` {.lang-tex .hljs}
\newcommand{\widefiguremargin}{-.22\textwidth}
\newcommand{\acro}[1]{\textsc{\lowercase{#1}}}
```
Es ist auch möglich, bestehende Befehle anzupassen. $\LaTeX$ erlaubt es sogar, Programmierkonstrukte wie Variablen, Verzweigungen und Schleifen zu nutzen. Für weitere Einblicke dient [dieses Kapitel des WikiBooks](https://en.wikibooks.org/wiki/LaTeX/Macros).
@slide(layout=content-and-preview-with-category)
@category
@ -163,73 +231,6 @@ Dateipfade angeben <span class="emoji">👣</span>
@slide(layout=content-only-with-category)
@category
Demo
@title
Kompilieren des Projekts
@content
* **Nur die Hauptdatei** wird kompiliert, um das fertige PDF-Dokument zu erhalten.
* ++ Fehlermeldungen enthalten dann Verweis, in welcher Unterdatei sie aufgetreten sind.
* ++ Die Unterdateien können wegen ihrer fehlenden Präambel nicht selbstständig kompiliert werden.
@slide(layout=task)
@task-number
3
@title
Ein strukturiertes Projekt
@content
Im Ordner `exercises/project-structure` findet ihr eine Datei namens `main.tex`.
* Erstellt neue Dateien (z.&thinsp;B. `section1.tex` und `section2.tex` und verschiebt die Abschnitte in diese.
* Importiert die Fragmente anschließend mit Hilfe des `\input`-Befehls.
* Lagert die Präambel auf demselben Weg in eine eigene Datei aus.
* Schaut euch abschließend die Gesamtstruktur unseres Projektarchivs an, beginnend mit `main-exercises.tex` im Wurzelverzeichnis. Wie binden wir hier die einzelnen Abschnitte ein?
@slide(layout=extra-content-only)
@title
PDF-Dokumente einbetten
@content
Das Paket `pdfpages` erlaubt das Einbetten ganzer PDF-Dokumente.
``` {.lang-tex .hljs}
\includepdf[pages={<from>-<to>}]{<file>}
```
Weitere Parameter lassen mehrere Seiten in Kacheln nebeneinander erscheinen oder ändern die Ausrichtung zu Querformat. Die [Paket-Dokumentation](https://www.ctan.org/pkg/pdfpages) enthält eine abschließende Liste aller Möglichkeiten.
@slide(layout=extra-wide-content)
@title
Makros
@content
Manchmal ist es nützlich, oft genutzten Codes durch Makros zu vereinfachen.
``` {.lang-tex .hljs}
\newcommand{\<name>}[<parameter_count>][<default>]{<content>}
```
Im Skript haben wir solche Makros unter anderem verwendet, um Abstände und Akronyme zu definieren (siehe `commands.tex` für weitere Beispiele):
``` {.lang-tex .hljs}
\newcommand{\widefiguremargin}{-.22\textwidth}
\newcommand{\acro}[1]{\textsc{\lowercase{#1}}}
```
Es ist auch möglich, bestehende Befehle anzupassen. $\LaTeX$ erlaubt es sogar, Programmierkonstrukte wie Variablen, Verzweigungen und Schleifen zu nutzen. Für weitere Einblicke dient [dieses Kapitel des WikiBooks](https://en.wikibooks.org/wiki/LaTeX/Macros).
@slide(layout=content-only)
@title

View File

@ -78,6 +78,74 @@ of section 2.
![](svg/project-structure/main-parts-crop.svg){.thin-padding}
@slide(layout=content-only)
@title
Compiling the project
@content
* **Only the main file** has to be compiled to get the complete PDF document.
* ++ Error messages include a reference to the corresponding subfile.
* ++ Subfiles cannot be compiled on their own as they dont have a preamble.
@slide(layout=task)
@task-number
3
@title
A structured project
@content
::: {.box .warning}
**Close all open tabs** from previous tasks.
:::
You will find a file named `main.tex` in the folder `exercises/project-structure`.
* Put the sections of the file into separate files, named `section1.tex` and `section2.tex`.
* Include them using the `\input` command.
* Move the preamble to its own file in a similar fashion.
* Finally, have a look at the general project archive, starting from `main-exercises.tex` (in the root folder of the project archive). How do we include the different sections here?
@slide(layout=extra-content-only)
@title
Embedding PDF documents
@content
The `pdfpages` package allows for embedding entire PDF documents.
``` {.lang-tex .hljs}
\includepdf[pages={<from>-<to>}]{<file>}
```
Further options make multiple pages appear in tiles and change the orientation to landscape, among other things. See the [package documentation](https://www.ctan.org/pkg/pdfpages) for a complete list.
@slide(layout=extra-wide-content)
@title
Macros
@content
It may be helpful to specify custom macros for often-used code.
``` {.lang-tex .hljs}
\newcommand{\<name>}[<parameter_count>][<default>]{<content>}
```
In the script, we used these macros for margins and acronyms (see `commands.tex` for more examples):
``` {.lang-tex .hljs}
\newcommand{\widefiguremargin}{-.22\textwidth}
\newcommand{\acro}[1]{\textsc{\lowercase{#1}}}
```
It is also possible to customize existing commands. $\LaTeX$ even allows you to use programming patterns like variables, conditionals, and loops. To learn more, have a look at [this WikiBook chapter](https://en.wikibooks.org/wiki/LaTeX/Macros).
@slide(layout=content-and-preview-with-category)
@category
@ -159,75 +227,6 @@ Specifying file paths <span class="emoji">👣</span>
![](svg/project-structure/relative-path-transitive-english-crop.svg)
@slide(layout=content-only-with-category)
@category
Demo
@title
Compiling the project
@content
* **Only the main file** has to be compiled to get the complete PDF document.
* ++ Error messages include a reference to the corresponding subfile.
* ++ Subfiles cannot be compiled on their own as they dont have a preamble.
@slide(layout=task)
@task-number
3
@title
A structured project
@content
You will find a file named `main.tex` in the folder `exercises/project-structure`.
* Put the sections of the file into separate files, named `section1.tex` and `section2.tex`.
* Include them using the `\input` command.
* Move the preamble to its own file in a similar fashion.
* Finally, have a look at the general project archive, starting from `main-exercises.tex` (in the root folder of the project archive). How do we include the different sections here?
@slide(layout=extra-content-only)
@title
Embedding PDF documents
@content
The `pdfpages` package allows for embedding entire PDF documents.
``` {.lang-tex .hljs}
\includepdf[pages={<from>-<to>}]{<file>}
```
Further options make multiple pages appear in tiles and change the orientation to landscape, among other things. See the [package documentation](https://www.ctan.org/pkg/pdfpages) for a complete list.
@slide(layout=extra-wide-content)
@title
Macros
@content
It may be helpful to specify custom macros for often-used code.
``` {.lang-tex .hljs}
\newcommand{\<name>}[<parameter_count>][<default>]{<content>}
```
In the script, we used these macros for margins and acronyms (see `commands.tex` for more examples):
``` {.lang-tex .hljs}
\newcommand{\widefiguremargin}{-.22\textwidth}
\newcommand{\acro}[1]{\textsc{\lowercase{#1}}}
```
It is also possible to customize existing commands. $\LaTeX$ even allows you to use programming patterns like variables, conditionals, and loops. To learn more, have a look at [this WikiBook chapter](https://en.wikibooks.org/wiki/LaTeX/Macros).
@slide(layout=content-only)
@title