Fix semantics of the \sh command by adding a \mono command

This commit is contained in:
Knoch 2022-01-08 14:01:10 +01:00
parent c5dac27ce9
commit 1897770361
12 changed files with 37 additions and 28 deletions

View File

@ -85,6 +85,15 @@
\texttt{#1}% \texttt{#1}%
} }
% Mono-spaced words
% =================
% Mono-spaced text without syntax highlighting.
% Intended for single words or small passages without special meaning.
% These can be environments, file extensions, and many more.
\newcommand\mono[1]{%
\texttt{#1}%
}
% Inline code % Inline code
% =========== % ===========
% Code snippets with syntax highlighting. % Code snippets with syntax highlighting.

View File

@ -63,7 +63,7 @@ It is an American character encoding and therefore does not contain German umlau
Instead, \acro{UTF-8}\footnote{cf. \url{https://en.wikipedia.org/wiki/UTF-8}} can be used as a universal character encoding. Instead, \acro{UTF-8}\footnote{cf. \url{https://en.wikipedia.org/wiki/UTF-8}} can be used as a universal character encoding.
In \LaTeX{}, we need to specify two character encodings: In \LaTeX{}, we need to specify two character encodings:
The input encoding (\sh{inputenc}), which refers to our source code, and the font encoding (\sh{fontenc}), which determines what the content of our \acro{PDF} document looks like.\footnote{Details on \sh{fontenc} can be found at: \url{https://tex.stackexchange.com/questions/108417/font-encoding-in-latex}} The input encoding (\mono{inputenc}), which refers to our source code, and the font encoding (\mono{fontenc}), which determines what the content of our \acro{PDF} document looks like.\footnote{Details on \mono{fontenc} can be found at: \url{https://tex.stackexchange.com/questions/108417/font-encoding-in-latex}}
\pkg{T1} is an encoding that tries to cover most European languages with a limited number of characters. \pkg{T1} is an encoding that tries to cover most European languages with a limited number of characters.
\subsection{Language}\label{sec:language} \subsection{Language}\label{sec:language}

View File

@ -91,7 +91,7 @@ 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. 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. For example, the command for embedding graphics accepts optional parameters for width and height.
If \sh{[12cm, 4cm]} were entered, it would be unclear which value is intended for which parameter. 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: To make the assignment more concrete, it is possible to specify the parameters explicitly:
\begin{minted}{tex} \begin{minted}{tex}
\includegraphics[width=12cm, height=4cm]{picture.png} \includegraphics[width=12cm, height=4cm]{picture.png}

View File

@ -8,7 +8,7 @@ However, we can also switch to ragged alignment by using the commands
\code{latex}{\textbackslash raggedright}, \code{latex}{\textbackslash raggedleft}, and \code{latex}{\textbackslash raggedright}, \code{latex}{\textbackslash raggedleft}, and
\code{latex}{\textbackslash centering}. \code{latex}{\textbackslash centering}.
These commands influence the environment that they are used in, e.\,g., the These commands influence the environment that they are used in, e.\,g., the
\sh{document} environment. Correspondingly, the text within the whole \mono{document} environment. Correspondingly, the text within the whole
document is affected. document is affected.
Alternatively, we can use dedicated environments in order to influence the Alternatively, we can use dedicated environments in order to influence the
formatting formatting

View File

@ -15,7 +15,7 @@ In order to be able to reference graphics, the package \texttt{graphicx} has to
\end{figure} \end{figure}
\end{minted} \end{minted}
\noindent The command \sh{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: \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} \begin{minted}{latex}
\includegraphics[width=0.5\textwidth,height=5cm]{<file path>} \includegraphics[width=0.5\textwidth,height=5cm]{<file path>}

View File

@ -6,17 +6,17 @@ For each of these types, there are dedicated environments whose structure is ver
\example{lst:unordered-list}{lists/nested-list}{Examplary unordered list} \example{lst:unordered-list}{lists/nested-list}{Examplary unordered list}
In \cref{lst:unordered-list-code}, different list items (\code{latex}{\textbackslash item}) are framed by an \sh{itemize} environment. In \cref{lst:unordered-list-code}, different list items (\code{latex}{\textbackslash item}) are framed by an \mono{itemize} environment.
Within a list item, we can open a new list environment to create a nested list. Within a list item, we can open a new list environment to create a nested list.
If we replace sh{itemize} by sh{enumerate}, the list becomes ordered without changing the source code any further. If we replace \mono{itemize} by \mono{enumerate}, the list becomes ordered without changing the source code any further.
To make use of the less common description lists, we have to specify the environment \sh{description}. To make use of the less common description lists, we have to specify the environment \mono{description}.
Moreover, the items need to be extended by the term to be defined, put in brackets (\cref{lst:description-list}). Moreover, the items need to be extended by the term to be defined, put in brackets (\cref{lst:description-list}).
\Example{lst:description-list}{lists/description-list}{lists/description-list_crop}{Exemplary description list} \Example{lst:description-list}{lists/description-list}{lists/description-list_crop}{Exemplary description list}
The exuberant spacing between list items can be reduced by utilizing the \sh{paralist}\footnote{\url{https://www.ctan.org/pkg/paralist}} package. The exuberant spacing between list items can be reduced by utilizing the \mono{paralist}\footnote{\url{https://www.ctan.org/pkg/paralist}} package.
To do so, we simply adjust the environment name: sh{compactitem} replaces sh{itemize}, sh{compactenum} replaces sh{enumerate}, and sh{compactdesc} replaces sh{description}. To do so, we simply adjust the environment name: sh{compactitem} replaces sh{itemize}, sh{compactenum} replaces sh{enumerate}, and sh{compactdesc} replaces sh{description}.
If the list ought to appear within a text body, \pkg{paralist} provides the extra environments \sh{inparaenum} and \sh{inparaitem}. If the list ought to appear within a text body, \pkg{paralist} provides the extra environments \mono{inparaenum} and \mono{inparaitem}.
We can customize bullet and list numbering styles via the \pkg{enumitem}\footnote{\url{https://www.ctan.org/pkg/enumitem}} package. We can customize bullet and list numbering styles via the \pkg{enumitem}\footnote{\url{https://www.ctan.org/pkg/enumitem}} package.
\code{latex}{\textbackslash begin\{enumerate\}[label=\textbackslash roman*]} produces a list with Roman numerals. \code{latex}{\textbackslash begin\{enumerate\}[label=\textbackslash roman*]} produces a list with Roman numerals.

View File

@ -28,7 +28,7 @@ An exemplary item can be seen in \cref{lst:bibfile-sample-entry}.
\label{lst:bibfile-sample-entry} \label{lst:bibfile-sample-entry}
\end{figure} \end{figure}
The type of the bibliography entry is specified after the opening \sh{@} sign (e.\,g., article, book, proceedings, …). The type of the bibliography entry is specified after the opening \mono{@} sign (e.\,g., article, book, proceedings, …).
What follows is a list of important attributes like title and author. What follows is a list of important attributes like title and author.
Whether they are required or not depends on the type of the entry. Whether they are required or not depends on the type of the entry.
In any case, we will need the first entry after the opening braces: the Bib\TeX{} key. In any case, we will need the first entry after the opening braces: the Bib\TeX{} key.
@ -70,8 +70,8 @@ Make sure to include the \pkg{natbib} package for this purpose.
\end{table} \end{table}
The \code{latex}{<source>} of a citation is always a Bib\TeX key. The \code{latex}{<source>} of a citation is always a Bib\TeX key.
The list of available citation styles\footnote{Head to Overleaf for a rather complete list: \url{https://www.overleaf.com/learn/latex/Biblatex_citation_styles}} includes \sh{alpha}, \sh{natdin}, and \sh{apa}. The list of available citation styles\footnote{Head to Overleaf for a rather complete list: \url{https://www.overleaf.com/learn/latex/Biblatex_citation_styles}} includes \mono{alpha}, \mono{natdin}, and \mono{apa}.
The table of references will always appear where the \code{latex}{\textbackslash bibliography\{\}} command was put. The table of references will always appear where the \code{latex}{\textbackslash bibliography\{\}} command was put.
The \code{latex}{\textbackslash cite} command comes with many variants.\footnote{cf. \url{https://www.economics.utoronto.ca/osborne/latex/BIBTEX.HTM}} The \code{latex}{\textbackslash cite} command comes with many variants.\footnote{cf. \url{https://www.economics.utoronto.ca/osborne/latex/BIBTEX.HTM}}
\Example{lst:natdin-example}{literature/natdin-example}{literature/natdin-example_bib}{Exemplary citations in the \sh{natdin} style.} \Example{lst:natdin-example}{literature/natdin-example}{literature/natdin-example_bib}{Exemplary citations in the \mono{natdin} style.}

View File

@ -68,8 +68,8 @@ For inline formulas, \code{latex}{\textbackslash limits} are of bounded suitabil
\section{Aligning equations} \section{Aligning equations}
The \sh{align} environment allows to align multiple equations horizontally, e.\,g., at the \sh{=} sign (\cref{lst:math-alignment-example}). The \mono{align} environment allows to align multiple equations horizontally, e.\,g., at the \mono{=} sign (\cref{lst:math-alignment-example}).
As in tables, the \sh{\&} sign is used to specify anchorage points. As in tables, the \mono{\&} sign is used to specify anchorage points.
Line breaks are denoted by two backslashes. Line breaks are denoted by two backslashes.
\Example{lst:math-alignment-example}{maths/align-example}{maths/align-example_crop}{Equations aligned at equals signs} \Example{lst:math-alignment-example}{maths/align-example}{maths/align-example_crop}{Equations aligned at equals signs}

View File

@ -19,8 +19,8 @@ The files that are included by the main file do not contain a preamble, since th
Let us now turn to the differences between the two possible commands for including \LaTeX{} files. Briefly summarized, \code{latex}{\textbackslash include} and \code{latex}{\textbackslash input} have differences in the following three aspects: The way in which the path to the file to be included is specified, the possibility of nesting inclusions, and whether a new page is started for each section. Let us now turn to the differences between the two possible commands for including \LaTeX{} files. Briefly summarized, \code{latex}{\textbackslash include} and \code{latex}{\textbackslash input} have differences in the following three aspects: The way in which the path to the file to be included is specified, the possibility of nesting inclusions, and whether a new page is started for each section.
If you use the command \code{latex}{\textbackslash input}, you can specify the file extension \sh{.tex}, but it is not mandatory. It is also possible to nest the inclusion of files: A file included with \code{latex}{\textbackslash input} can in turn include another file with the same command. The files that have been included are inserted in the finished document without starting a new page for the included section (cf. \cref{lst:main-file}). If you use the command \code{latex}{\textbackslash input}, you can specify the file extension \mono{.tex}, but it is not mandatory. It is also possible to nest the inclusion of files: A file included with \code{latex}{\textbackslash input} can in turn include another file with the same command. The files that have been included are inserted in the finished document without starting a new page for the included section (cf. \cref{lst:main-file}).
The command \code{latex}{\textbackslash include} behaves differently: Here, the file The command \code{latex}{\textbackslash include} behaves differently: Here, the file
extension \sh{.tex} \emph{must} be omitted. Nesting of embeddings is not extension \mono{.tex} \emph{must} be omitted. Nesting of embeddings is not
possible. Also, a new page is created for each included file. possible. Also, a new page is created for each included file.

View File

@ -111,7 +111,7 @@ We already have presented a selection of packages. However, there are thousands
\pkg{makecell}.\footnote{\url{https://www.ctan.org/pkg/makecell}} \pkg{makecell}.\footnote{\url{https://www.ctan.org/pkg/makecell}}
\end{description} \end{description}
\noindent \sh{beamer}, which is not a package, but another document class, can be used to create \textbf{slide shows} \noindent \mono{beamer}, which is not a package, but another document class, can be used to create \textbf{slide shows}
with \LaTeX{}. Information on the document class and examples are available at Overleaf,\footnote{\url{https://www.overleaf.com/learn/latex/Beamer}} which brings us to the next section: with \LaTeX{}. Information on the document class and examples are available at Overleaf,\footnote{\url{https://www.overleaf.com/learn/latex/Beamer}} which brings us to the next section:
\section{Help and information} \section{Help and information}

View File

@ -2,26 +2,26 @@
\label{sec:tables} \label{sec:tables}
There are two fundamental environments for tables. There are two fundamental environments for tables.
The first one, called \sh{table}, is responsible for integrating the table as a whole into the document. The first one, called \mono{table}, is responsible for integrating the table as a whole into the document.
Positioning is done the same way as it is with graphics. Positioning is done the same way as it is with graphics.
The \code{latex}{\textbackslash caption} command is the same, as well. The \code{latex}{\textbackslash caption} command is the same, as well.
At the table \emph{content}, the similarities end: At the table \emph{content}, the similarities end:
While graphics are embedded from external files and not interpreted by \LaTeX{}, While graphics are embedded from external files and not interpreted by \LaTeX{},
the inner structure of tables has to be encoded explicitly. the inner structure of tables has to be encoded explicitly.
This is done with the \sh{tabular} environment that expects a column definition as an obligatory parameter. This is done with the \mono{tabular} environment that expects a column definition as an obligatory parameter.
The column definition consists of one letter per column specifying its text alignment: The column definition consists of one letter per column specifying its text alignment:
\sh{l} for left-justified, \sh{r} for right-justified, \sh{c} for centered. \mono{l} for left-justified, \mono{r} for right-justified, \mono{c} for centered.
Within the \sh{tabular} environment, the actual table content follows. Within the \mono{tabular} environment, the actual table content follows.
Table rows are separated by \code{latex}{\textbackslash \textbackslash}, just like line breaks, and cells by an \code{latex}{\&}. Table rows are separated by \code{latex}{\textbackslash \textbackslash}, just like line breaks, and cells by an \code{latex}{\&}.
For typographically pleasing tables, we recommend the \pkg{booktabs} package.\footnote{All commands previously mentioned also work without this package, but the result will look far less professional.} For typographically pleasing tables, we recommend the \pkg{booktabs} package.\footnote{All commands previously mentioned also work without this package, but the result will look far less professional.}
This package brings along the commands \code{latex}{\textbackslash toprule}, \code{tex}{\textbackslash midrule} and \code{tex}{\textbackslash bottomrule} that draw appropriate horizontal lines above, within and below the table, respectively. This package brings along the commands \code{latex}{\textbackslash toprule}, \code{tex}{\textbackslash midrule} and \code{tex}{\textbackslash bottomrule} that draw appropriate horizontal lines above, within and below the table, respectively.
Vertical lines can be inserted as a vertical bar character (\sh{|}) in the column definition, but this is \emph{not} recommended.\footnote{The Vertical lines can be inserted as a vertical bar character (\mono{|}) in the column definition, but this is \emph{not} recommended.\footnote{The
whitespace within the table separates the columns clearly enough, additional lines just make for visual clutter.} whitespace within the table separates the columns clearly enough, additional lines just make for visual clutter.}
If you want to remove the additional whitespace that surrounds the columns by default (e.\,g., to the left of the first column and to the right of the last), you can add the string \sh{@\{\}} at the corresponding places within the column definition. If you want to remove the additional whitespace that surrounds the columns by default (e.\,g., to the left of the first column and to the right of the last), you can add the string \mono{@\{\}} at the corresponding places within the column definition.
A complete table can then look like the one shown in \cref{lst:sample-table}. A complete table can then look like the one shown in \cref{lst:sample-table}.
@ -30,7 +30,7 @@ A complete table can then look like the one shown in \cref{lst:sample-table}.
\paragraph{Excess length} \paragraph{Excess length}
For tables exceeding one page or requiring line breaks within individual cells, For tables exceeding one page or requiring line breaks within individual cells,
the \pkg{longtable} package can be used additionally (also supported by \pkg{booktabs}). the \pkg{longtable} package can be used additionally (also supported by \pkg{booktabs}).
The \pkg{longtable} environment combines the \sh{table} and \sh{tabular} environments. The \pkg{longtable} environment combines the \mono{table} and \mono{tabular} environments.
With it, you get the following basic structure: With it, you get the following basic structure:
\begin{samepage} \begin{samepage}
@ -45,8 +45,8 @@ With it, you get the following basic structure:
\paragraph{Excess width} \paragraph{Excess width}
If you want to present a very wide table instead, it is preferable on pages in portrait orientation to turn the table by 90\textdegree{}. If you want to present a very wide table instead, it is preferable on pages in portrait orientation to turn the table by 90\textdegree{}.
This can be done with the help of the \pkg{rotating} package. This can be done with the help of the \pkg{rotating} package.
The only difference between this and a normal table is that the \sh{table} environment gets replaced by a \sh{sidewaystable} environment. The only difference between this and a normal table is that the \mono{table} environment gets replaced by a \mono{sidewaystable} environment.
Positioning and the \sh{tabular} stay unaffected. Positioning and the \mono{tabular} stay unaffected.
\paragraph{More possibilities} \paragraph{More possibilities}
Of course, \LaTeX{} offers lots of additional features for sophisticated tables, e.\,g., row- or column-spanning cells. Of course, \LaTeX{} offers lots of additional features for sophisticated tables, e.\,g., row- or column-spanning cells.

View File

@ -14,9 +14,9 @@
\item Include the Bib\TeX{} file in a suitable location, where later on the references should be listed. \item Include the Bib\TeX{} file in a suitable location, where later on the references should be listed.
\item Cite the three handbooks in the \item Cite the three handbooks in the
file\\\file{exercises/literature/literature.tex}. file\\\file{exercises/literature/literature.tex}.
\item Make use of the \sh{natdin} biliography style. \item Make use of the \mono{natdin} biliography style.
\item \textbf{Note}: If compiling fails, it may help to remove all auxiliary \item \textbf{Note}: If compiling fails, it may help to remove all auxiliary
files \\(\sh{main.aux/bbl/blg/loc/out/pdf/soc/toc}) before compiling again. files \\(\mono{main.aux/bbl/blg/loc/out/pdf/soc/toc}) before compiling again.
\end{enumerate} \end{enumerate}
\exercisematerial{exercises/literature/literature} \exercisematerial{exercises/literature/literature}