Skip to content

Commit

Permalink
Demonstration of lstinputlisting
Browse files Browse the repository at this point in the history
Signed-off-by: Oliver Kopp <[email protected]>
Also-by: Patrick Diehl <[email protected]>
Also-by: [email protected]
Also-by: [email protected]
  • Loading branch information
koppor committed Jan 24, 2018
1 parent de05740 commit 53befcb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
8 changes: 8 additions & 0 deletions code/helloworld.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <cstdlib>
#include <iostream>

int main(int argc, char *argv[]) {
// print Hello World to the stdout
std::cout << "Hello World!" << std::endl;
return EXIT_SUCCESS;
}
8 changes: 5 additions & 3 deletions config.tex
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,8 @@
numberstyle=\tiny,
basewidth=.5em,
xleftmargin=.5cm,
aboveskip=0mm, %DE: deaktivieren, falls man lstlistings direkt als floating object benutzt (\begin{lstlisting}[float,...])
belowskip=0mm, %DE: deaktivieren, falls man lstlistings direkt als floating object benutzt (\begin{lstlisting}[float,...])
% aboveskip=0mm, %DE: deaktivieren, falls man lstlistings direkt als floating object benutzt (\begin{lstlisting}[float,...])
% belowskip=0mm, %DE: deaktivieren, falls man lstlistings direkt als floating object benutzt (\begin{lstlisting}[float,...])
captionpos=b
}

Expand Down Expand Up @@ -390,6 +390,7 @@

%%%
%EN: Required for proper environments of fancyvrb and lstlistings
% There is also the newfloat pacakge (recommended by minted), but we currently have no expericene with that
%DE: Wird für fancyvrb und für lstlistings verwendet
\usepackage{float}

Expand Down Expand Up @@ -814,7 +815,8 @@
}
%
%EN: New float environments for listings and algorithms
\floatstyle{ruled}
%
% \floatstyle{ruled} % TODO: enabled or disabled causes no change - listings and algorithms are always ruled
\newfloat{Listing}{tbp}{code}[chapter]
\crefname{Listing}{Listing}{Listings}
\newfloat{Algorithmus}{tbp}{alg}[chapter]
Expand Down
5 changes: 4 additions & 1 deletion latexhints-german.tex
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ \section{Mathematische Formeln}
Eine ausführliche Anleitung zum Mathematikmodus von LaTeX findet sich in \url{http://www.ctan.org/tex-archive/help/Catalogue/entries/voss-mathmode.html}.

\section{Quellcode}
\Cref{lst:ListingANDlstlisting} zeigt, wie man Programmlistings einbindet.
\Cref{lst:ListingANDlstlisting,helloworld} zeigen, wie man Programmlistings einbindet.
Mittels \texttt{\textbackslash lstinputlisting} kann man den Inhalt direkt aus Dateien lesen.

%Listing-Umgebung wurde durch \newfloat{Listing} definiert
Expand All @@ -77,6 +77,9 @@ \section{Quellcode}
\label{lst:ListingANDlstlisting}
\end{Listing}

%TODO: Currently not shown in TOC
\lstinputlisting[language=C++,label=helloworld,caption={"`hello world"' in C++.},float]{code/helloworld.cpp}

Quellcode im \lstinline|<listing />| ist auch möglich.

\section{Abbildungen}
Expand Down

0 comments on commit 53befcb

Please sign in to comment.