From 1897770361d6a798abdc469d536f664e6a183527 Mon Sep 17 00:00:00 2001 From: Florian Knoch Date: Sat, 8 Jan 2022 14:01:10 +0100 Subject: [PATCH] Fix semantics of the \sh command by adding a \mono command --- commands.tex | 9 +++++++++ content/basic-document-structure.tex | 2 +- content/basic-functionality.tex | 2 +- content/formatting-paragraphs.tex | 2 +- content/graphics.tex | 2 +- content/lists.tex | 10 +++++----- content/literature.tex | 6 +++--- content/maths.tex | 4 ++-- content/project-structure.tex | 4 ++-- content/prospects.tex | 2 +- content/tables.tex | 18 +++++++++--------- exercises/literature/task.tex | 4 ++-- 12 files changed, 37 insertions(+), 28 deletions(-) diff --git a/commands.tex b/commands.tex index 2284a6d..24e67a5 100644 --- a/commands.tex +++ b/commands.tex @@ -85,6 +85,15 @@ \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 % =========== % Code snippets with syntax highlighting. diff --git a/content/basic-document-structure.tex b/content/basic-document-structure.tex index c793de7..f5accc4 100644 --- a/content/basic-document-structure.tex +++ b/content/basic-document-structure.tex @@ -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. 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. \subsection{Language}\label{sec:language} diff --git a/content/basic-functionality.tex b/content/basic-functionality.tex index 3112de8..5c6e6af 100644 --- a/content/basic-functionality.tex +++ b/content/basic-functionality.tex @@ -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. 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: \begin{minted}{tex} \includegraphics[width=12cm, height=4cm]{picture.png} diff --git a/content/formatting-paragraphs.tex b/content/formatting-paragraphs.tex index ca0a0c9..f93936d 100644 --- a/content/formatting-paragraphs.tex +++ b/content/formatting-paragraphs.tex @@ -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 centering}. 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. Alternatively, we can use dedicated environments in order to influence the formatting diff --git a/content/graphics.tex b/content/graphics.tex index 4f75e3b..2bb8f09 100644 --- a/content/graphics.tex +++ b/content/graphics.tex @@ -15,7 +15,7 @@ In order to be able to reference graphics, the package \texttt{graphicx} has to \end{figure} \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} \includegraphics[width=0.5\textwidth,height=5cm]{} diff --git a/content/lists.tex b/content/lists.tex index 6a9e24c..75eacdc 100644 --- a/content/lists.tex +++ b/content/lists.tex @@ -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} -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. -If we replace sh{itemize} by sh{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}. +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 \mono{description}. 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} -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}. -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. \code{latex}{\textbackslash begin\{enumerate\}[label=\textbackslash roman*]} produces a list with Roman numerals. diff --git a/content/literature.tex b/content/literature.tex index 661e523..06d981d 100644 --- a/content/literature.tex +++ b/content/literature.tex @@ -28,7 +28,7 @@ An exemplary item can be seen in \cref{lst:bibfile-sample-entry}. \label{lst:bibfile-sample-entry} \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. 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. @@ -70,8 +70,8 @@ Make sure to include the \pkg{natbib} package for this purpose. \end{table} The \code{latex}{} 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 \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.} diff --git a/content/maths.tex b/content/maths.tex index 8fed757..10638c1 100644 --- a/content/maths.tex +++ b/content/maths.tex @@ -68,8 +68,8 @@ For inline formulas, \code{latex}{\textbackslash limits} are of bounded suitabil \section{Aligning equations} -The \sh{align} environment allows to align multiple equations horizontally, e.\,g., at the \sh{=} sign (\cref{lst:math-alignment-example}). -As in tables, the \sh{\&} sign is used to specify anchorage points. +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 \mono{\&} sign is used to specify anchorage points. Line breaks are denoted by two backslashes. \Example{lst:math-alignment-example}{maths/align-example}{maths/align-example_crop}{Equations aligned at equals signs} diff --git a/content/project-structure.tex b/content/project-structure.tex index 867a272..a34536b 100644 --- a/content/project-structure.tex +++ b/content/project-structure.tex @@ -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. -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 -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. diff --git a/content/prospects.tex b/content/prospects.tex index 3ea1b39..382e208 100644 --- a/content/prospects.tex +++ b/content/prospects.tex @@ -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}} \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: \section{Help and information} diff --git a/content/tables.tex b/content/tables.tex index f5551ce..38827d6 100644 --- a/content/tables.tex +++ b/content/tables.tex @@ -2,26 +2,26 @@ \label{sec: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. The \code{latex}{\textbackslash caption} command is the same, as well. At the table \emph{content}, the similarities end: While graphics are embedded from external files and not interpreted by \LaTeX{}, 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: -\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}{\&}. 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. -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.} -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}. @@ -30,7 +30,7 @@ A complete table can then look like the one shown in \cref{lst:sample-table}. \paragraph{Excess length} 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} 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: \begin{samepage} @@ -45,8 +45,8 @@ With it, you get the following basic structure: \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{}. 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. -Positioning and the \sh{tabular} stay unaffected. +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 \mono{tabular} stay unaffected. \paragraph{More possibilities} Of course, \LaTeX{} offers lots of additional features for sophisticated tables, e.\,g., row- or column-spanning cells. diff --git a/exercises/literature/task.tex b/exercises/literature/task.tex index 8dc1c58..ed265d5 100644 --- a/exercises/literature/task.tex +++ b/exercises/literature/task.tex @@ -14,9 +14,9 @@ \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 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 - 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} \exercisematerial{exercises/literature/literature}