255 lines
5.5 KiB
Markdown
255 lines
5.5 KiB
Markdown
@slide(layout=chapter-slide)
|
||
|
||
@title
|
||
Project structure
|
||
|
||
@slide(layout=content-and-preview)
|
||
|
||
@title
|
||
Goal
|
||
|
||
@content
|
||
Create a bigger LaTeX project and …
|
||
|
||
* prevent LaTeX documents from growing monstrously <span class="emoji">👹</span>
|
||
* keep the overview over the project structure
|
||
|
||
@preview
|
||
{style="padding: .2em; height: 100vh"}
|
||
|
||
|
||
@slide(layout=content-and-preview)
|
||
|
||
@title
|
||
Main file <span class="emoji">👑</span>
|
||
|
||
@content
|
||
* contains basic structure and front matter
|
||
* includes separate sections with \
|
||
`\input{path/to/file}` or \
|
||
`\include{path/to/file}`
|
||
|
||
``` {.lang-tex .hljs data-sourcefile=main.tex}
|
||
\documentclass{article}
|
||
\usepackage{babel}
|
||
\usepackage[utf8]{inputenc}
|
||
\usepackage[T1]{fontenc}
|
||
\title{A Title}
|
||
\begin{document}
|
||
\maketitle
|
||
\tableofcontents
|
||
\input{section1.tex}
|
||
\input{section2.tex}
|
||
\end{document}
|
||
```
|
||
|
||
@preview
|
||

|
||
|
||
|
||
@slide(layout=content-and-preview)
|
||
|
||
@title
|
||
File with a section
|
||
|
||
@content
|
||
* contains **no preamble**
|
||
* contains **no** `\begin{document}` or `\end{document}`
|
||
|
||
``` {.hljs .lang-tex data-sourcefile=part1.tex}
|
||
\section{This is section 1}
|
||
A paragraph about the content
|
||
of section 1.
|
||
|
||
% …
|
||
```
|
||
|
||
``` {.hljs .lang-tex data-sourcefile=part2.tex}
|
||
\section{This is section 2}
|
||
A paragraph about the content
|
||
of section 2.
|
||
|
||
% …
|
||
```
|
||
|
||
@preview
|
||
{.thin-padding}
|
||
|
||
|
||
@slide(layout=two-columns)
|
||
|
||
@title
|
||
`input` or `include`?
|
||
|
||
@column-one
|
||
``` {.hljs .lang-tex}
|
||
\input{path/to/file}
|
||
```
|
||
|
||
* file extension `.tex` **may** be added
|
||
* **nesting** possible: nested files can again be embedded using `\input{}`
|
||
* file is added to the resulting document **without a page break**
|
||
|
||
@column-two
|
||
``` {.hljs .lang-tex}
|
||
\include{path/to/file}
|
||
```
|
||
|
||
* file extension `.tex` **must not** be added
|
||
* **no nesting** possible
|
||
* each subfile starts a **new page** in the resulting document
|
||
* advantage for larger projects: `\includeonly{file1,file2,...}` can be used in the preable to compile only certain subfiles
|
||
(the entire project has to be compiled at least once before)
|
||
|
||
|
||
@slide(layout=content-and-preview-with-category)
|
||
|
||
@category
|
||
Excursion
|
||
|
||
@title
|
||
Specifying file paths <span class="emoji">👣</span>
|
||
|
||
@content
|
||
* important for `\input{}` and `\include{}`, later also for pictures
|
||
* file and folder structure = tree structure <span class="emoji">🌳</span>
|
||
|
||
@preview
|
||

|
||
|
||
|
||
@slide(layout=content-and-preview-with-category)
|
||
|
||
@category
|
||
Excursion
|
||
|
||
@title
|
||
<span data-category="Example">Specifying file paths <span class="emoji">👣</span></span>
|
||
|
||
@content
|
||
### Absolute paths
|
||
* path from the root directory to a file
|
||
* the direcories are separated by special characters:
|
||
* under UNIX: `/`
|
||
* under Windows: `\`
|
||
|
||
<div class="fragment">
|
||
<p data-category="Example">absolute path for `main.tex`</p>
|
||
|
||
* UNIX: `/home/knut/docs/latex/main.tex`
|
||
* Windows: `C:\knut\docs\latex\main.tex`
|
||
|
||
<p data-category="Caution!">In **LaTeX,** you have to use UNIX-style paths. Therefore, we will use those from here on.</p>
|
||
</div>
|
||
|
||
@preview
|
||

|
||
|
||
|
||
@slide(layout=content-and-preview-with-category)
|
||
|
||
@category
|
||
Excursion
|
||
|
||
@title
|
||
Specifying file paths <span class="emoji">👣</span>
|
||
|
||
@content
|
||
### Relative paths
|
||
* path from somewhere in the tree to a certain file
|
||
* shorter + less typing! <span class="emoji">☺</span>
|
||
* with `\input{}` and `\include{}`, you can specify the path relative to the main file
|
||
|
||
<div class="fragment">
|
||
<p data-category="Example">Relative path \
|
||
from `main.tex` to `part1.tex`</p>
|
||
|
||
`./part1.tex`
|
||
|
||
A **single dot ‘`.`’** in a relative path represents the current folder (in this case: `latex`). It is optional, you could also write `part1.tex` here.
|
||
</div>
|
||
|
||
@preview
|
||

|
||
|
||
|
||
@slide(layout=content-and-preview-with-category)
|
||
|
||
@category
|
||
Excursion
|
||
|
||
@title
|
||
Specifying paths <span class="emoji">👣</span>
|
||
|
||
@content
|
||
### Relative paths
|
||
<p data-category="Example">Relative path from `main.tex` to `part1.tex` in subfolder</p>
|
||
|
||
`./sections/part1.tex`
|
||
|
||
@preview
|
||

|
||
|
||
|
||
@slide(layout=content-and-preview-with-category)
|
||
|
||
@category
|
||
Excursion
|
||
|
||
@title
|
||
Specifying paths <span class="emoji">👣</span>
|
||
|
||
@content
|
||
### Relative paths
|
||
<p data-category="Example">Relative path from `main.tex` in its own subfolder to `part1.tex` in another subfolder</p>
|
||
|
||
`../sections/part1.tex`
|
||
|
||
**Two dots ‘`..`’** represent the parent folder of the current folder (in this case: `latex`, parent of `main`).
|
||
|
||
@preview
|
||

|
||
|
||
|
||
@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 don’t have a preamble.
|
||
|
||
|
||
@slide(layout=content-and-preview)
|
||
|
||
@title
|
||
Outsourcing the preamble
|
||
|
||
@content
|
||
What do you think happens when we outsource the preamble into its own subfile?
|
||
|
||
Will the document compile?
|
||
|
||
++ **Yes, it will!** \
|
||
A simple way of keeping the main file even more organised.
|
||
|
||
@preview
|
||
{.thin-padding}
|
||
|
||
@slide(layout=task)
|
||
|
||
@task-number
|
||
4
|
||
|
||
@title
|
||
A structured project
|
||
|
||
@content
|
||
You will find a file named `main.tex` in the folder `exercises/project-structure`.
|
||
|
||
* Extract the sections into their own files (`section1.tex`, `section2.tex`, and `section3.tex`) and insert them using the `\include` command.
|
||
* Which command is rendered superfluous by `\include`?
|
||
|