replaced minted in continuous text with codeblock commands

This commit is contained in:
Fradtschuk 2022-01-08 17:35:48 +01:00
parent 03e95d1e99
commit 16480cd7f9
9 changed files with 25 additions and 80 deletions

View File

@ -40,9 +40,7 @@ The language can be passed as an optional parameter, too (cf. \cref{sec:language
\subsection{Digression: packages}
\label{sec:packages}
\begin{minted}{latex}
\usepackage[<options>]{<packagename>}
\end{minted}
\codeblock{latex}{listings/basic-document-structure/packages.tex}
Packages provide additional commands and functionalities that we can use within our \LaTeX{} source code.
There are numerous packages for different use cases (e.\,g., typesetting formulas, lists, \textellipsis).
In order to use a package, it must be included within the preamble.
@ -51,10 +49,7 @@ The most important \LaTeX{} packages can be found in the Comprehensive \TeX\ Arc
You can also find documentation for the packages there.
\subsection{Encoding}
\begin{minted}{latex}
\usepackage[utf8]{inputenc}
\usepackage[t1]
\end{minted}
\codeblock{latex}{listings/basic-document-structure/encoding.tex}
One use case for packages is specifying the encoding of our \LaTeX{} document.
The character encoding\footnote{cf. \url{https://en.wikipedia.org/wiki/Character_encoding}} determines the available character set.
The standard encoding in \LaTeX{} is \acro{ASCII}.\footnote{cf. \url{https://en.wikipedia.org/wiki/ASCII}}
@ -66,9 +61,7 @@ The input encoding (\mono{inputenc}), which refers to our source code, and the f
\pkg{T1} is an encoding that tries to cover most European languages with a limited number of characters.
\subsection{Language}\label{sec:language}
\begin{minted}{latex}
\usepackage[ngerman]{babel}
\end{minted}
\codeblock{latex}{listings/basic-document-structure/language.tex}
The package \pkg{babel} provides language-specific information (e.\,g., on hyphenation, special characters, changing fonts, translation of labels\footnote{cf. \cref{sec:references}} like \enquote{Chapter,} \enquote{Table of Contents,} or \enquote{Figure.}
The desired language can be passed as an optional parameter.
\pkg{ngerman}, for instance, is used for the new German spelling.
@ -80,9 +73,7 @@ To do so, we pass the languages, separated by commas, as an optional parameter t
Within our document, we can switch between languages with the \code{latex}{\textbackslash selectlanguage\{<language>\}} command.
Alternatively, foreign-language text can be declared by using the following command:
\begin{minted}{latex}
\foreignlanguage{<language>}{<text>}
\end{minted}
\codeblock{latex}{listings/basic-document-structure/foreign-language.tex}
\section{Document environment}
The actual content of the \acro{PDF} document needs to be put between \code{latex}{\textbackslash begin\{document\}} and \code{latex}{\textbackslash end\{document\}}.
@ -113,15 +104,12 @@ The commands that are depicted in \cref{lst:headlines} can be used with any docu
Some document classes provide additional commands. In a \pkg{report}, you get \code{late}{\textbackslash chapter\{Chapter\}}, and in a \pkg{book}, additionally \code{latex}{\textbackslash part\{Part\}}.
You can mark the command with an asterisk if you want to omit the numbering of a section and exclude it from the table of contents:\footnote{cf. \cref{sec:table-of-contents}}
\begin{minted}{latex}
\section*{This section is excluded from the table of contents}
\end{minted}
\codeblock{latex}{listings/basic-document-structure/section.tex}
An alternative title for the table of contents can be declared as an optional parameter in square brackets between the command and the actual title:
An alternative title for the table of contents can be declared as an optional
parameter in square brackets between the command and the actual title:
\begin{minted}{latex}
\section[Title in the TOC]{Actual Chapter Title}
\end{minted}
\codeblock{latex}{listings/basic-document-structure/title-in-toc.tex}
\subsection{Front matter}
A simple front matter can be created by using the command \code{latex}{\textbackslash maketitle}.

View File

@ -64,9 +64,8 @@ Unfortunately, we cannot take away the decision if you would rather wait for the
\section{The commands}
\label{subsec:command-structure}
The commands used in source code follow a general structure:
\begin{minted}{xml}
\<command>[<optional_parameters>]{<mandatory_parameters>}
\end{minted}
\codeblock{xml}{listings/basic-functionality/command-structure.xml}
A command can use several optional and/or mandatory parameters.
Some commands have no mandatory parameters at all.
Some examples are shown in \cref{tbl:latex-commands}.
@ -92,10 +91,9 @@ Some examples are shown in \cref{tbl:latex-commands}.
If a command allows multiple optional parameters that accept similar inputs, it is sometimes necessary to specify which parameter is meant.
For example, the command for embedding graphics accepts optional parameters for width and height.
If \mono{[12cm, 4cm]} were entered, it would be unclear which value is intended for which parameter.
To make the assignment more concrete, it is possible to specify the parameters explicitly:
\begin{minted}{tex}
\includegraphics[width=12cm, height=4cm]{picture.png}
\end{minted}
To make the assignment more concrete, it is possible to specify the parameters
explicitly:
\codeblock{latex}{listings/basic-functionality/parameters.tex}
As the examples already show, many different commands can be used.
Some are intended for use in mathematical formulas, others allow the inclusion of graphics.

View File

@ -24,13 +24,7 @@ Usually, we illustrate a new paragraph by indenting the first line of it
Alternatively, paragraph spacing, i.\,e., vertical space between paragraphs,
can be used (\code{latex}{\textbackslash parskip}).
For both variants, there are adjustable parameters:
\begin{minted}{tex}
\setlength{\parindent}{0pt}
\setlength{\parskip}{1em
plus .5em % admissible stretch
minus .5em % admissible shrink
}
\end{minted}
\codeblock{latex}{listings/formatting-paragraphs/indentation.tex}
\noindent We can use \code{latex}{\textbackslash noindent} to turn off the indentation for only one
paragraph.

View File

@ -7,19 +7,12 @@ Instead, we reference external image files by a command. The figure is then embe
\section{Inserting graphics}
\label{sec:display-graphics}
In order to be able to reference graphics, the package \texttt{graphicx} has to be included. For inserting a figure, we can use the following commands:
\begin{minted}[tabsize=4]{latex}
\begin{figure}
\includegraphics{<file path>}
\caption[<short title>]{<caption>}
\end{figure}
\end{minted}
\codeblock{latex}{listings/graphics/insert-graphics.tex}
\noindent The command \mono{includegraphics} can be used to change the image size. The desired height and width of the figure can be indicated separately, as illustrated by the following example:
\begin{minted}{latex}
\includegraphics[width=0.5\textwidth,height=5cm]{<file path>}
\end{minted}
\codeblock{latex}{listings/graphics/image-size.tex}
\section{Positioning}
\label{sec:graphics-placement}
@ -49,12 +42,7 @@ On top of that, we can limit the positioning of our image more or less rigorousl
\label{tbl:placement-abbreviations}
\end{table}
\begin{minted}[tabsize=4]{latex}
\begin{figure}[<position shortcut>]
\centering
\includegraphics{<file path>}
\end{figure}
\end{minted}
\codeblock{latex}{listings/graphics/positioning.tex}
Besides the vertical positioning, also the horizontal orientation may be of importance.
By default, graphics are left-justified.

View File

@ -13,17 +13,8 @@ Our \textbf{bibliography collection} consists of multiple literature entries in
An exemplary item can be seen in \cref{lst:bibfile-sample-entry}.
\begin{figure}[H]
\begin{minted}[autogobble]{latex}
@article{turing1990,
title={The chemical basis of morphogenesis},
author={Turing, Alan Mathison},
journal={Bulletin of mathematical biology},
volume={52},
pages={153--197},
year={1990},
publisher={Springer}
}
\end{minted}
\codeblock{bibtex}{listings/literature/bibliography-entry.bib}
\caption{Exemplary bibliography entry}
\label{lst:bibfile-sample-entry}
\end{figure}

View File

@ -33,13 +33,9 @@ For this reason, it is common to insert a prefix before each label (\cref{lst:re
Note that if we use \code{latex}{\textbackslash cref\{<label>\}}\,---\,for some document classes\,---\,the generated passages only appear in the desired language (e.\,g., German) when the language is specified already within the document class command:
\begin{minted}{latex}
\documentclass[ngerman]{article}
\end{minted}
\codeblock{latex}{listings/references/set-language.tex}
\noindent Except for sections, captions\footnote{\code{latex}{\textbackslash caption\{\}}} \emph{always need to be specified and positioned before the label}\textit{.} Otherwise, they cannot be referenced later on in the text.
Labels for sections are inserted directly after the command:
\begin{minted}{latex}
\section{Comments}\label{sec:hints}
\end{minted}
\codeblock{latex}{listings/references/sections.tex}

View File

@ -20,10 +20,7 @@ or macOS.\footnote{\url{https://docs.python-guide.org/starting/install3/osx/}}
After a successful installation, you should be able to execute the aforementioned command in a terminal, confirm by pressing Enter, and see approximately the following result:
\begin{minted}[]{bash}
$ python --version
Python 3.8.5
\end{minted}
\codeblock{bash}{listings/source-code-listings/python-version.sh}
\noindent If the version number is equal to the one stated here, or higher, then everything should be set up correctly.
Next, enter the command \sh{pip install Pygments}\footnote{On some operating systems, you might have to use the command \sh{pip3 install Pygments}} in the same terminal window to install the Pygments package for Python.

View File

@ -34,12 +34,7 @@ The \pkg{longtable} environment combines the \mono{table} and \mono{tabular} env
With it, you get the following basic structure:
\begin{samepage}
\begin{minted}{latex}
\begin{longtable}
% content
\caption{<caption>}
\end{longtable}
\end{minted}
\codeblock{latex}{listings/tables/excess-length.tex}
\end{samepage}
\paragraph{Excess width}

View File

@ -40,9 +40,7 @@ This command does not only use a mono-spaced font for \acro{URL}s, it also makes
The same applies for different font sizes.
You can specify the body text font size with an option at the document class:
\begin{minted}{latex}
\documentclass[9pt]{article}
\end{minted}
\codeblock{latex}{listings/text-markup/font-size.tex}
Building upon this, \LaTeX{} generates different font sizes that can be called via the commands in \cref{tbl:type-sizes}.
It is, however, best to restrict those to title pages and similar things.
For the rest, you can trust the default settings and avoid the visual clutter.