translate references

This commit is contained in:
Fradtschuk 2021-07-23 12:37:40 +02:00
parent dd87033b2b
commit b4ba69d9b4
4 changed files with 34 additions and 41 deletions

View File

@ -1,45 +1,43 @@
\chapter{Referenzen}
\chapter{References}
\label{sec:references}
Für Querverweise der Form \enquote{Wie man in Abbildung 23 sieht, \textellipsis} bringt \LaTeX\ von Haus aus den Befehl \mintinline{latex}{\ref{label}} mit, der lästige Anpassungen an der Nummerierung der Grafiken, Tabellen etc. erspart.
Er erhält als Argument ein eindeutiges Label, das auch dem referenzierten Element zugeordnet werden muss.
Anschließend erscheint an der Stelle des Befehlsaufrufs die fortlaufende Nummer des referenzierten Elements.
If we want to make references, like \enquote{\textellipsis , which you can see in figure 21, \textellipsis}, \LaTeX{} by default provides as with the command \mintinline{latex}{\ref{label}}. No more adapting of the numbering for graphics, tables, etc. needed!
the command expects a unique label as argument, that needs to be assigned to the referenced element. After that, wherever we call the command, the number of our referenced object appears in the text.
\Example{lst:fooboar-learning-latex}{references/ref}{references/ref_crop}{Example for a reference}
\Example{lst:fooboar-learning-latex}{references/ref}{references/ref_crop}{Beispiel für eine Referenzierung}
Noch smarter ist das Paket \mintinline{latex}{cleveref}.\footnote{mit nur einem \enquote{r}!}
Es bringt den Befehl \mintinline{latex}{\cref{label}} mit, dem auch -- durch Kommata getrennt -- mehrere Labels übergeben werden können.
Daraus entstehen dann automatisiert Angaben wie \enquote{Abschnitte 1 bis 3 und 5}.\footnote{für den Quelltext \mintinline{latex}{\cref{sec:section1,sec:section2,
A smarter package for references is \texttt{cleverref}.\footnote{with only one \enquote{r}!}
It provides us with the command \mintinline{latex}{\cref{label}}, which can also handle multiple labels separated by commas.
This automatically generates text like \enquote{sections 1 to 3, and 5}.\footnote{for the source code \mintinline{latex}{\cref{sec:section1,sec:section2,
sec:section3,sec:section5}}}
Zudem fügt \mintinline{latex}{\cref{label}} eigenständig die richtige Abkürzung ein, beispielsweise \enquote{Abb.} für Grafiken.
Furthermore \mintinline{latex}{\cref{label}} automatically inserts a suited abbreviaton, e.\,g., \enquote{fig.} for figures.
Referenziert werden können neben Grafiken und Tabellen unter anderem auch Abschnitte, Bilder, Quelltext-Listings und Gleichungen.
Viele Pakete nutzen das Label, um herauszufinden, zu welchem Objekttyp es gehört.
Aus diesem Grund ist es üblich, jedem Label ein Präfix voranzustellen (\cref{lst:reference-prefixes}).
We can reference graphics, tables, sections, chapters, source code listings, and equations.
Many packages use the label in order to find out the object type of the referenced element.
For this reason, it is common to insert a prefix before each label (\cref{lst:reference-prefixes}).
\begin{table}[H]
\centering
\begin{tabular}{@{}llll@{}}
\toprule
Präfix & Objekttyp & Präfix & Objekttyp \\ \midrule
fig: & Abbildungen & tbl: & Tabellen \\
sec: & Abschnitte & subsec: & Unterabschnitte \\
ch: & Kapitel & itm: & Aufzählungselemente \\
eq: & Gleichungen & lst: & Quelltext-Listings \\ \bottomrule
Prefix & Object Type & Prefix & Object Type \\ \midrule
fig: & figures & tbl: & tables \\
sec: & sections & subsec: & subsections \\
ch: & chapters & itm: & items \\
eq: & equations & lst: & source Code Listings \\ \bottomrule
\end{tabular}
\caption{Präfixe für Labels}
\caption{Prefixes for labels}
\label{lst:reference-prefixes}
\end{table}
Bei der Verwendung von \mintinline{latex}{\cref{label}} ist zu beachten, dass die generierten Passagen in einigen Dokumentklassen erst dann auf Deutsch erscheinen, wenn bereits in der Dokumentklasse die Sprache festgelegt wurde:
Note that, if we use \mintinline{latex}{\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}
\noindent Von Abschnitten abgesehen, müssen Beschriftungen\footnote{\mintinline{latex}{\caption{}}} außerdem \emph{immer vergeben und vor dem Label platziert} werden, damit sie anschließend referenziert werden können.
Bei Abschnitten wird das Label direkt hinter dem Befehl angefügt:
\noindent Except for sections, captions\footnote{\mintinline{latex}{\caption{}}} \emph{always need to be specified and positioned before the label}. Otherwise, they cannot be referenced later on in the text.
Labels for sections are inserted directly after the command:
\begin{minted}{latex}
\section{Hinweise}\label{sec:hints}
\section{Comments}\label{sec:hints}
\end{minted}

View File

@ -1,24 +1,18 @@
\begin{minted}[breaklines]{latex}
C\# ist eine objektorientierte Programmiersprache, die im Auftrag von Microsoft entwickelt wurde und die es bereits seit 2001 gibt. In \cref{fig:csharp} seht ihr das Logo der Programmiersprache.
C\# is an object-oriented programming language that was developed by Microsoft in 2011. In \cref{fig:csharp} we can see the logo of the programming language.
\begin{figure}[H]
\caption{Das Logo der Programmiersprache C\#}
\caption{The logo of C\#}
\label{fig:csharp}
\centering
\includegraphics[width=2cm]{exercises/references/csharp.png}
\end{figure}
\cref{lst:csharphelloworld} zeigt ein Programm, das den Text \enquote{Hello LaTeX friends!} auf der Konsole ausgibt. Ähnlich wie bei Java werden auch in C\# Klassen und eine Main-Methode verwendet, um eine ausführbare Anwendung zu bauen.
\Cref{lst:csharphelloworld} shows a program that prints the text \enquote{Hello LaTeX friends!} to the console. Like Java, C\# makes use of classes and main methods to build executable applications.
\begin{listing}[H]
\caption{Ein einfaches Programm in der Programmiersprache C\#}
\caption{A simple C\# program}
\label{lst:csharphelloworld}
\inputminted[breaklines, linenos=true]{csharp}{exercises/references/HelloLateXFriends.cs}
\end{listing}
\end{minted}
\end{listing}
\end{minted}

View File

@ -1,12 +1,12 @@
C\# ist eine objektorientierte Programmiersprache, die im Auftrag von Microsoft entwickelt wurde und die es bereits seit 2001 gibt. In der Abbildung seht ihr das Logo der Programmiersprache.
C\# is an object-oriented programming language that was developed by Microsoft in 2011. In the figure we can see the logo of the programming language.
\begin{figure}[H]
\caption{Das Logo der Programmiersprache C\#}
\caption{The logo of C\#}
\centering
\includegraphics[width=2cm]{exercises/references/csharp.png}
\end{figure}
Das nachstehende Quelltext-Listing zeigt ein Programm, das den Text \enquote{Hello LaTeX friends!} auf der Konsole ausgibt. Ähnlich wie bei Java werden auch in C\# Klassen und eine Main-Methode verwendet, um eine ausführbare Anwendung zu bauen.
The following source code listing shows a program that prints the text \enquote{Hello LaTeX friends!} to the console. Like Java, C\# makes use of classes and main methods to build executable applications.
\inputminted[breaklines, linenos=true]{csharp}{exercises/references/HelloLateXFriends.cs}

View File

@ -1,3 +1,4 @@
Ersetzt im Text in der Datei \mintinline{bash}{exercises/references/references.tex} die Phrasen \enquote{in der Abbildung} und \enquote{Das nachstehende Quelltext-Listing} jeweils durch eine Referenz auf das Bild und auf das Quelltext-Listing. Nutzt dafür den Befehl \mintinline{latex}{\cref}. Achtet darauf, dass ihr zunächst Labels für die Elemente, die ihr referenzieren wollt, vergeben müsst. Hüllt das Quelltext-Listing dafür zunächst in eine Umgebung namens \mintinline{latex}{listing} und fügt noch eine Beschriftung hinzu. Achtet auch auf geeignete Präfixe vor den Labels.
In file \texttt{exercises/references/references.tex}, replace \enquote{in the figure}, and \enquote{the following source code listing} with suited references. Use the command \mintinline{latex}{\cref}. Do not forget to first introduce labels for the elements that you want to reference. To do so, first of all, wrap the source code listing in a \mintinline{latex}{listing} environment. Also insert a caption for the source code listing.
Make sure to use suitable prefixes before the labels.
\exercisematerial{exercises/references/references}