From 16480cd7f95b36bb815b3529c3c8dcbc45d2a620 Mon Sep 17 00:00:00 2001 From: efradtschuk Date: Sat, 8 Jan 2022 17:35:48 +0100 Subject: [PATCH 1/3] replaced minted in continuous text with codeblock commands --- content/basic-document-structure.tex | 28 ++++++++-------------------- content/basic-functionality.tex | 12 +++++------- content/formatting-paragraphs.tex | 8 +------- content/graphics.tex | 20 ++++---------------- content/literature.tex | 13 ++----------- content/references.tex | 8 ++------ content/source-code-listings.tex | 5 +---- content/tables.tex | 7 +------ content/text-markup.tex | 4 +--- 9 files changed, 25 insertions(+), 80 deletions(-) diff --git a/content/basic-document-structure.tex b/content/basic-document-structure.tex index 3cde43f..bbab739 100644 --- a/content/basic-document-structure.tex +++ b/content/basic-document-structure.tex @@ -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[]{} -\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\{\}} command. Alternatively, foreign-language text can be declared by using the following command: -\begin{minted}{latex} -\foreignlanguage{}{} -\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}. diff --git a/content/basic-functionality.tex b/content/basic-functionality.tex index 5c6e6af..f1b346c 100644 --- a/content/basic-functionality.tex +++ b/content/basic-functionality.tex @@ -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} -\[]{} -\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. diff --git a/content/formatting-paragraphs.tex b/content/formatting-paragraphs.tex index f93936d..2c067ff 100644 --- a/content/formatting-paragraphs.tex +++ b/content/formatting-paragraphs.tex @@ -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. diff --git a/content/graphics.tex b/content/graphics.tex index 2bb8f09..dfc22a6 100644 --- a/content/graphics.tex +++ b/content/graphics.tex @@ -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{} - \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]{} -\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}[] - \centering - \includegraphics{} -\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. diff --git a/content/literature.tex b/content/literature.tex index 06d981d..f322800 100644 --- a/content/literature.tex +++ b/content/literature.tex @@ -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} diff --git a/content/references.tex b/content/references.tex index 04f2f6d..d3bc8b7 100644 --- a/content/references.tex +++ b/content/references.tex @@ -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\{