diff --git a/layouts/content-only-with-category.html b/layouts/content-only-with-category.html new file mode 100644 index 0000000..950f899 --- /dev/null +++ b/layouts/content-only-with-category.html @@ -0,0 +1,7 @@ +
pdflatex -synctex=1 -interaction=nonstopmode **\-\-shell-escape** %.tex
-@slide(layout=content-and-preview)
+
+@slide(layout=content-only)
+
+@title
+Ein Hinweis zu unserem Skript
+
+@content
+Unsere Übungsmaterialien erlauben es, zwischen `minted` und `listings` zu wählen.
+Von Haus aus nutzen wir `listings`.
+Um `minted` zu aktivieren muss eine Datei namens `listings-mode.tex` mit dem folgenden Inhalt im Wurzelverzeichnis unseres Projekts erstellt werden:
+
+```{.lang-tex .hljs}
+\newcommand\listingsmode{minted}
+```
+
+Kompiliert erneut und die Listings sollten durch `minted` erstellt worden sein.
+
+
+@slide(layout=content-and-preview-with-category)
+
+@category
+minted
@title
Code im LaTeX-Quelltext
@@ -67,10 +103,14 @@ Eine Überschrift wird so ausgezeichnet:
@preview

-@slide(layout=content-and-preview)
+
+@slide(layout=content-and-preview-with-category)
+
+@category
+minted
@title
-Code aus externen Dateien
+Externer Code
@content
Um Redundanz zu vermeiden, ist es manchmal praktisch, den Quelltext direkt aus der Quelldatei einzulesen.
@@ -91,10 +131,14 @@ public class Test {
@preview

-@slide(layout=content-only)
+
+@slide(layout=content-only-with-category)
+
+@category
+minted
@title
-`Minted` konfigurieren
+Themen und Stile
@content
Durch optionale Parameter können Zeilennummerierung, Umbrüche und Farben ausgewählt werden. Außerdem sind zahlreiche Themes verfügbar.
@@ -111,21 +155,138 @@ breaklines=true,
🔗 **[Einführung](https://www.overleaf.com/learn/latex/Code_Highlighting_with_minted)** und **[offizielle Dokumentation](https://ctan.kako-dev.de/macros/latex/contrib/minted/minted.pdf)**
+
+@slide(layout=content-and-preview-with-category)
+
+@category
+listings
+
+@title
+Code im LaTeX-Quelltext
+
+@content
+In einer eigenen Umgebung:
+
+``` {.lang-tex .hljs}
+\section*{Haskell-Magie}
+Quadrate aller geraden % …
+\begin{lstlisting}[language=Haskell]
+[x^2 | x <- [1..200], even x]
+\end{lstlisting}
+```
+
+Das Paket `listings` stellt keinen Befehl für inline-Listings zur Verfügung.
+
+@preview
+
+
+
+@slide(layout=content-and-preview-with-category)
+
+@category
+listings
+
+@title
+Externer Code
+
+@content
+Praktischerweise bietet auch `listings` einen Befehl zum Einfügen externen Codes:
+
+``` {.lang-tex .hljs}
+\section*{Einfache Java-Anwendung}
+\lstinputlisting[language=Java]{Test.java}
+```
+
+``` {.lang-java .hljs data-sourcefile="Test.java"}
+public class Test {
+ public static void main(/*…*/) {
+ System.out.println(/*…*/);
+ }
+}
+```
+
+@preview
+
+
+
+@slide(layout=content-only-with-category)
+
+@category
+listings
+
+@title
+Themen und Stile
+
+@content
+`listings` stellt keine eigenen Themes zur Verfügung. Dies kann aber durch die vielen Konfigurationsoptionen ausgeglichen werden.
+
+``` {.lang-tex .hljs}
+\begin{lstlisting}[
+ language=Java,
+ basicstyle=\footnotesize\ttfamily,
+ breaklines=true,
+ keywordstyle=\color{ForestGreen},
+ commentstyle=\color{DarkGray},
+ literate={ö}{{\"o}}1
+]
+% …
+\end{lstlisting}
+```
+
+Für die Erstellung eigener Themes ist der Befehl `\lstset` nützlich.
+
+
+@slide(layout=content-only-with-category)
+
+@category
+listings
+
+@title
+Weitere Materialien
+
+@content
+* [Einführung](https://www.overleaf.com/learn/latex/Code_listing#Reference_guide) in das Paket
+* offizielle [Dokumentation](https://www.overleaf.com/learn/latex/Code_listing#Reference_guide)
+* das Paket [`xcolor`](https://www.overleaf.com/learn/latex/Using_colours_in_LaTeX) für Farben
+* zwei [Themes](https://github.com/jez/latex-solarized) im solarized-Stil für `listings`
+
+
@slide(layout=task)
@task-number
10
@title
-Quelltext einbinden
+`minted`
@content
-* Im Ordner `exercises/source-code-listings` findet ihr eine Datei namens `Source.java`. Wir werden diese im Folgenden in unser Dokument einbinden und das Aussehen unseren Wünschen anpassen.
-* **Bindet** den Java-Quelltext in der Datei `source-code-listings.tex` **ein**. (Beachtet, dass der Dateipfad relativ zum Hauptdokument ist, also zu `main.tex`.)
+* Im Ordner `exercises/source-code-listings` findet ihr eine Datei namens `Source.java`.
+* **Bindet** den Java-Quelltext in der Datei `source-code-listings.tex` **ein**. (Beachtet, dass der Dateipfad relativ zu `main.tex` ist.)
* Aktiviert das **Syntax-Highlighting** durch Angabe der Sprache Java.
-* Verwendet eine Option, um die Zeilen zu **nummerieren**.
+* **Nummeriert** die Zeilen und aktiviert **Umbrüche**.
* Nutzt das **Theme** `native`.
-* Ändert die **Hintergrundfarbe** des Themes zu dunkelblau.
+* Ändert die **Hintergrundfarbe** des Themes zu Dunkelblau.
* Bindet jetzt nur die **Zeilen 5 bis 7** ein.
* Entfernt die **Leerzeichen** am Anfang der Zeilen durch die passende Option (Tipp: Die Dokumentation spricht hier von `gobble`).
-* Seht bei Fragen in der Dokumentation des Paketes *Minted* nach.
+
+Seht bei Fragen in der Dokumentation des Paketes `minted` nach.
+
+
+@slide(layout=task)
+
+@task-number
+10
+
+@title
+`listings`
+
+@content
+* Im Ordner `exercises/source-code-listings` findet ihr eine Datei namens `Source.java`.
+* **Bindet** den Java-Quelltext in der Datei `source-code-listings.tex` **ein**. (Beachtet, dass der Dateipfad relativ zu `main.tex` ist.)
+* Aktiviert das **Syntax-Highlighting** durch Angabe der Sprache Java.
+* **Nummeriert** die Zeilen und aktiviert **Umbrüche**.
+* Setzt mit dem Parameter `basicstyle` eine dicktengleiche Schrift (`\ttfamily \small`).
+* Ändert die Schlüsselwortfarbe zu Blau.
+* Verbergt die Sonderzeichen, die **Leerzeichen in Zeichenketten** markieren.
+
+Seht bei Fragen in der Dokumentation des Paketes `listings` nach.
diff --git a/slides/chapter-10.en.md b/slides/chapter-10.en.md
index e340ab7..67d3704 100644
--- a/slides/chapter-10.en.md
+++ b/slides/chapter-10.en.md
@@ -3,24 +3,36 @@
@title
Source code listings
+@slide(layout=content-only)
+
+@title
+Our options
+
+@content
+There are two popular ways to display source code in a LaTeX document.
+
+* ++ **`minted`** renders **very pretty** source code listings, but it requires some **extra configuration** and might not work on every operating system.
+* ++ **`listings`** is an **easy-to-use** (but not as pretty) option for those having troubles with `minted`.
+
+++ Their commands are very similar.
+
@slide(layout=content-and-preview)
@title
Installation 🖥️
@content
-`Minted`, another LaTeX package, is very useful to display source code. It requires the Python programming language.
-
-As soon as **[Python is installed](https://www.python.org/)**, we can download the corresponding Python package **[`Pygments`](http://pygments.org/)** using a command prompt:
+`minted` requires the Python programming language. As soon as **[Python is installed](https://www.python.org/)**, we can download the corresponding Python package **[`Pygments`](http://pygments.org/)** using a command prompt:
``` {.lang-sh .hljs}
pip install Pygments
```
-Add the LaTeX package and we are good to go:
+Add the LaTeX packages for `minted` or `listings` and we are good to go:
``` {.lang-tex .hljs}
\usepackage{minted}
+\usepackage{listings}
```
@preview
@@ -33,17 +45,39 @@ Compiler settings
@content
pdflatex -synctex=1 -interaction=nonstopmode **\-\-shell-escape** %.tex
-@slide(layout=content-and-preview)
+
+@slide(layout=content-only)
@title
-Listings within LaTeX documents
+A note on our script
+
+@content
+Our exercise material allows you to choose between `minted` and `listings`.
+By default, we use `listings`.
+To activate `minted`, create a file called `listings-mode.tex` in the project's root directory and add the following line:
+
+```{.lang-tex .hljs}
+\newcommand\listingsmode{minted}
+```
+
+After compiling again, your listings should be rendered by `minted`.
+
+
+@slide(layout=content-and-preview-with-category)
+
+@category
+minted
+
+@title
+In-situ listings
@content
++ Within a dedicated environment:
@@ -67,7 +101,11 @@ A headline is denoted the following way:
@preview

-@slide(layout=content-and-preview)
+
+@slide(layout=content-and-preview-with-category)
+
+@category
+minted
@title
External source code
@@ -91,10 +129,14 @@ public class Test {
@preview

-@slide(layout=content-only)
+
+@slide(layout=content-only-with-category)
+
+@category
+minted
@title
-Configuring `minted`
+Themes and styles
@content
Optional parameters allow us to activate line numbers, automated line breaks, and syntax highlighting based on numerous color schemes.
@@ -111,20 +153,137 @@ breaklines=true,
🔗 **[introduction](https://www.overleaf.com/learn/latex/Code_Highlighting_with_minted)** and **[official documentation](https://ctan.kako-dev.de/macros/latex/contrib/minted/minted.pdf)**
+
+@slide(layout=content-and-preview-with-category)
+
+@category
+listings
+
+@title
+In-situ listings
+
+@content
+Within a dedicated environment:
+
+``` {.lang-tex .hljs}
+\section*{Haskell Magic}
+Squares of all even % …
+\begin{lstlisting}[language=Haskell]
+[x^2 | x <- [1..200], even x]
+\end{lstlisting}
+```
+
+The `listings` package does not provide an inline command.
+
+@preview
+
+
+
+@slide(layout=content-and-preview-with-category)
+
+@category
+listings
+
+@title
+External source code
+
+@content
+Conveniently, also `listings` offers an import command:
+
+``` {.lang-tex .hljs}
+\section*{Simple Java Application}
+\lstinputlisting[language=Java]{Test.java}
+```
+
+``` {.lang-java .hljs data-sourcefile="Test.java"}
+public class Test {
+ public static void main(/*…*/) {
+ System.out.println(/*…*/);
+ }
+}
+```
+
+@preview
+
+
+
+@slide(layout=content-only-with-category)
+
+@category
+listings
+
+@title
+Themes and styles
+
+@content
+`listings` does not provide any themes by default, but can be configured extensively.
+
+``` {.lang-tex .hljs}
+\begin{lstlisting}[
+ language=Java,
+ basicstyle=\footnotesize\ttfamily,
+ breaklines=true,
+ keywordstyle=\color{ForestGreen},
+ commentstyle=\color{DarkGray},
+ literate={ö}{{\"o}}1
+]
+% …
+\end{lstlisting}
+```
+
+Have a look at the `\lstset` command for creating your own themes.
+
+
+@slide(layout=content-only-with-category)
+
+@category
+listings
+
+@title
+Further resources
+
+@content
+* [introduction](https://www.overleaf.com/learn/latex/Code_listing#Reference_guide) to the package
+* official [documentation](https://www.overleaf.com/learn/latex/Code_listing#Reference_guide)
+* [`xcolor` package](https://www.overleaf.com/learn/latex/Using_colours_in_LaTeX) for colors
+* two [solarized themes](https://github.com/jez/latex-solarized) for `listings`
+
+
@slide(layout=task)
@task-number
10
@title
-Listing source code
+Listings with `minted`
@content
-* In the directory `exercises/source-code-listings` you can find a file named `Source.java`, which we want to include in our document.
-* **Include** the java code in the file `source-code-listings.tex`. (Keep in mind that the file path is relative to the main LaTeX document, i. e., to `main.tex`.)
-* **Number** the code lines.
+* In the directory `exercises/source-code-listings` you can find a file named `Source.java`.
+* **Include** it in the file `source-code-listings.tex`. (Keep in mind that the file path is relative to the main LaTeX document, i. e., to `main.tex`.)
+* Activate **syntax highlighting** by stating the programming language Java.
+* **Number** the code lines and add **line breaks**.
* Use the **theme** `native`.
* Change the **background colour** to dark blue.
* Now only include **lines 5 to 7**.
* Delete the **spaces** at the beginning of the lines by using a suitable option (Hint: The documentation speaks of `gobble`).
-* If you have questions, try to consult the documentation of the Minted package.
+
+If you have questions, try to consult the documentation of the `minted` package.
+
+@slide(layout=task)
+
+@task-number
+10
+
+@title
+Listings with `listings`
+
+@content
+* In the directory `exercises/source-code-listings` you can find a file named `Source.java`.
+* **Include** it in the file `source-code-listings.tex`. (Keep in mind that the file path is relative to the main LaTeX document, i. e., to `main.tex`.)
+* Activate **syntax highlighting** by stating the programming language Java.
+* **Number** the code lines.
+* Set the `basicstyle` to a proper mono-spaced font (`\ttfamily \small`)
+* Change the **keyword color** to blue.
+* Don't show special characters for **spaces in strings**.
+
+If you have questions, try to consult the documentation of the `listings` package.
diff --git a/svg/chapter-10/listings-haskell-crop.svg b/svg/chapter-10/listings-haskell-crop.svg
new file mode 100644
index 0000000..4d3f2a9
--- /dev/null
+++ b/svg/chapter-10/listings-haskell-crop.svg
@@ -0,0 +1,296 @@
+
+
diff --git a/svg/chapter-10/listings-haskell-english-crop.svg b/svg/chapter-10/listings-haskell-english-crop.svg
new file mode 100644
index 0000000..6a32ad4
--- /dev/null
+++ b/svg/chapter-10/listings-haskell-english-crop.svg
@@ -0,0 +1,309 @@
+
+
diff --git a/svg/chapter-10/listings-haskell-english-orig.svg b/svg/chapter-10/listings-haskell-english-orig.svg
new file mode 100644
index 0000000..df25ded
--- /dev/null
+++ b/svg/chapter-10/listings-haskell-english-orig.svg
@@ -0,0 +1,309 @@
+
+
diff --git a/svg/chapter-10/listings-haskell-english.tex b/svg/chapter-10/listings-haskell-english.tex
new file mode 100644
index 0000000..158293f
--- /dev/null
+++ b/svg/chapter-10/listings-haskell-english.tex
@@ -0,0 +1,17 @@
+\documentclass[a4paper]{article}
+\usepackage{lmodern}
+\usepackage{amssymb,amsmath}
+\usepackage[T1]{fontenc}
+\usepackage[utf8]{inputenc}
+\usepackage{hyperref}
+\usepackage{listings}
+\begin{document}
+\thispagestyle{empty}
+
+\section*{Haskell Magic}
+Squares of all even numbers between 1 and 200:
+\begin{lstlisting}[language=Haskell]
+ [x^2 | x <- [1..200], even x]
+\end{lstlisting}
+
+\end{document}
diff --git a/svg/chapter-10/listings-haskell-orig.svg b/svg/chapter-10/listings-haskell-orig.svg
new file mode 100644
index 0000000..086b332
--- /dev/null
+++ b/svg/chapter-10/listings-haskell-orig.svg
@@ -0,0 +1,296 @@
+
+
diff --git a/svg/chapter-10/listings-haskell.tex b/svg/chapter-10/listings-haskell.tex
new file mode 100644
index 0000000..1e42a86
--- /dev/null
+++ b/svg/chapter-10/listings-haskell.tex
@@ -0,0 +1,17 @@
+\documentclass[a4paper]{article}
+\usepackage{lmodern}
+\usepackage{amssymb,amsmath}
+\usepackage[T1]{fontenc}
+\usepackage[utf8]{inputenc}
+\usepackage{hyperref}
+\usepackage{listings}
+\begin{document}
+\thispagestyle{empty}
+
+\section*{Haskell-Magie}
+Quadrate aller geraden Zahlen zwischen 1 und 200:
+\begin{lstlisting}[language=Haskell]
+ [x^2 | x <- [1..200], even x]
+\end{lstlisting}
+
+\end{document}
diff --git a/svg/chapter-10/listings-java-crop.svg b/svg/chapter-10/listings-java-crop.svg
new file mode 100644
index 0000000..7c8c55a
--- /dev/null
+++ b/svg/chapter-10/listings-java-crop.svg
@@ -0,0 +1,498 @@
+
+
diff --git a/svg/chapter-10/listings-java-english-crop.svg b/svg/chapter-10/listings-java-english-crop.svg
new file mode 100644
index 0000000..597ff31
--- /dev/null
+++ b/svg/chapter-10/listings-java-english-crop.svg
@@ -0,0 +1,487 @@
+
+
diff --git a/svg/chapter-10/listings-java-english-orig.svg b/svg/chapter-10/listings-java-english-orig.svg
new file mode 100644
index 0000000..6ab7bb9
--- /dev/null
+++ b/svg/chapter-10/listings-java-english-orig.svg
@@ -0,0 +1,487 @@
+
+
diff --git a/svg/chapter-10/listings-java-english.tex b/svg/chapter-10/listings-java-english.tex
new file mode 100644
index 0000000..8bb4470
--- /dev/null
+++ b/svg/chapter-10/listings-java-english.tex
@@ -0,0 +1,14 @@
+\documentclass[a4paper]{article}
+\usepackage{lmodern}
+\usepackage{amssymb,amsmath}
+\usepackage[T1]{fontenc}
+\usepackage[utf8]{inputenc}
+\usepackage{hyperref}
+\usepackage{listings}
+\begin{document}
+\thispagestyle{empty}
+
+\section*{Simple Java Application}
+\lstinputlisting[language=Java]{Test.java}
+
+\end{document}
diff --git a/svg/chapter-10/listings-java-orig.svg b/svg/chapter-10/listings-java-orig.svg
new file mode 100644
index 0000000..27c9206
--- /dev/null
+++ b/svg/chapter-10/listings-java-orig.svg
@@ -0,0 +1,498 @@
+
+
diff --git a/svg/chapter-10/listings-java.tex b/svg/chapter-10/listings-java.tex
new file mode 100644
index 0000000..ef89e5d
--- /dev/null
+++ b/svg/chapter-10/listings-java.tex
@@ -0,0 +1,14 @@
+\documentclass[a4paper]{article}
+\usepackage{lmodern}
+\usepackage{amssymb,amsmath}
+\usepackage[T1]{fontenc}
+\usepackage[utf8]{inputenc}
+\usepackage{hyperref}
+\usepackage{listings}
+\begin{document}
+\thispagestyle{empty}
+
+\section*{Einfache Java-Anwendung}
+\lstinputlisting[language=Java]{Test.java}
+
+\end{document}