Mehrseitiger Quellcode wird unterbrochen

Antwort erstellen


Diese Frage dient dazu, das automatisierte Versenden von Formularen durch Spam-Bots zu verhindern.
Smilies
:D :) :( :o :shock: :? 8) :lol: :-x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen:

BBCode ist eingeschaltet
[img] ist eingeschaltet
[flash] ist ausgeschaltet
[url] ist eingeschaltet
Smilies sind eingeschaltet

Die letzten Beiträge des Themas

Ich habe die Datenschutzerklärung gelesen und bin damit einverstanden.

   

Wenn du eine Datei oder mehrere Dateien anhängen möchtest, gib die Details unten ein.

Ansicht erweitern Die letzten Beiträge des Themas: Mehrseitiger Quellcode wird unterbrochen

von Gast » Di 30. Mai 2017, 11:05

Habe es jetzt gelöst indem ich die Gleitumgebungen entfernt habe.

Das mit dem overfull war nur weil ich das MB nicht nochmal überprüft habe, ebenso das uft8x, die Probleme habe ich in meinem eigentlichen Dokument nicht - dennoch danke für die Hinweise.

von Gast » Di 30. Mai 2017, 10:51

Wenn Du nicht willst, dass die Abbildung gleitet, dann verwende keine figure-Umgebung. Sorge außerdem dafür, dass sie keine overfull oder underfull \hbox oder \vbox verursacht:
\documentclass[12pt]{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}% utf8x bereitet mit diversen Paketen Probleme und
                           % ist selten sinnvoll
\usepackage{placeins}
\usepackage{mwe}

\usepackage{listings}
\lstset{numbers=left,
numberstyle=\tiny,
numbersep=5pt,
breaklines=true,
showstringspaces=false,
frame=l ,
xleftmargin=15pt,
xrightmargin=15pt,
basicstyle=\ttfamily\small,
stepnumber=1,
}
\begin{document}

\FloatBarrier
\section{Anhang}

\includegraphics[width=\textwidth,height=.92\textheight]{example-image}

%\lstinputlisting[language=Python]{Test.py}
\begin{lstlisting}
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
\end{lstlisting}
\end{document}
Natürlich ginge auch
\documentclass[12pt]{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}% utf8x bereitet mit diversen Paketen Probleme und
                           % ist selten sinnvoll
\usepackage{placeins}
\usepackage{mwe}

\usepackage{listings}
\lstset{numbers=left,
numberstyle=\tiny,
numbersep=5pt,
breaklines=true,
showstringspaces=false,
frame=l ,
xleftmargin=15pt,
xrightmargin=15pt,
basicstyle=\ttfamily\small,
stepnumber=1,
}
\begin{document}

\section{Anhang}
\begin{figure}[!htp]
\includegraphics[width=\textwidth,height=.92\textheight]{example-image}
\end{figure}
\FloatBarrier

%\lstinputlisting[language=Python]{Test.py}
\begin{lstlisting}
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
\end{lstlisting}
\end{document}
wäre aber ein wenig von hinten durch die Brust ins Knie.

von Gast » Di 30. Mai 2017, 10:30

Dann reich ich hier mal mein Minimalbeispiel nach, es ist etwas länger geworden, da der Code ja auch irgendwie in das Beispiel musste :D :
\documentclass[12pt]{article}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{amsmath}
\usepackage{tikz}
\usepackage{mwe}

\usepackage{listings}
\lstset{numbers=left,
	numberstyle=\tiny,
	numbersep=5pt,
	breaklines=true,
	showstringspaces=false,
	frame=l ,
	xleftmargin=15pt,
	xrightmargin=15pt,
	basicstyle=\ttfamily\small,
	stepnumber=1,
}
\begin{document}
\section{Anhang}
\begin{figure}
\includegraphics[width=15cm,height=18cm]{example-image}
\end{figure}
%\lstinputlisting[language=Python]{Test.py}
\begin{lstlisting}
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
print("This line will be printed.")
\end{lstlisting}
\end{document}
In meinem ursprünglichen Dokument füge ich den Code über \lstinputlisting[language=Python]{Test.py} in das Dokument ein, falls das einen Unterschied macht.

von Gast » Di 30. Mai 2017, 09:43

Ich vermute, du hast für das Listing Option float gesetzt. Entferne diese. Wenn ich mich irre, dann mach bitte ein Minimalbeispiel. Das solltest du bei Fragen grundsätzlich tun, damit wir nicht auf Spekulationen angewiesen sind, sondern das Problem reproduzieren und unsere Ideen testen können.

Mehrseitiger Quellcode wird unterbrochen

von Gast » Di 30. Mai 2017, 08:53

Hallo zusammen,

ich habe mithilfe von \lstinputlisting einen mehrseitigen Python Quellcode eingefügt. Das ganze funktioniert auch ohne Probleme.

Den Code hab ich im Anhang meiner Dokumentes, sobald ich weitere Anhänge hinzufüge, werden diese Anhänge zwischen meinen Quellcode geschoben.

Sieht dann so aus:
1. Seite Quellcode
2. Seite Weiterer Anhang
3. Seite restlicher Quellcode

Kann ich irgendwie verhindern das die Seiten dazwischen geschoben werden?
Ich nehme mal an das man den Code in eine Umgebung packen kann, aber die die ich bisher versucht habe, haben versucht den Code auf einer Seite darzustellen, was wegen seiner länge nicht möglich ist.

Vielen Dank!

Nach oben