von Christian » Mo 5. Jul 2010, 21:18
Hi!
Mein erster Post hier - ich hoffe, ich mache alles richtig
Mein Problem habe ich versucht, auf das untenstehende Minimalbeispiel zusammenzuschrumpfen. Ich nutze das "listings-package" in der unten stehenden Einstellung.
Problem 1: Egal welche Sprache ich einstelle, er färbt den Code nicht ein. Also ignoriert und mit den Einstellungen korrigiert
Problem 2: Lässt man Zeile 2 und 3 im Codebeispiel, gibt es den Fehler "Missing \endcsname inserted" - aber der kommt beim listings-package bei jedem Problem.
Habt ihr eine Idee?
\documentclass[a4paper, german, 12pt, oneside]{paper}
\usepackage{ngerman}
\usepackage{listings}
\usepackage{color}
\begin{document}
\lstset{ % Einstellungen fürs Listings-Paket
language = Python, % choose the language of the code
basicstyle = \footnotesize, % the size of the fonts that are used for the code
numbers = left, % where to put the line-numbers
numberstyle = \footnotesize, % the size of the fonts that are used for the line-numbers
stepnumber = 5, % the step between two line-numbers. If it's 1 each line will be numbered
numbersep = 5pt, % how far the line-numbers are from the code
backgroundcolor = \color{white}, % choose the background color. You must add \usepackage{color}
showspaces = false, % show spaces adding particular underscores
showstringspaces = false, % underline spaces within strings
showtabs = false, % show tabs within strings adding particular underscores
frame = single, % adds a frame around the code
tabsize = 2, % sets default tabsize to 2 spaces
captionpos = b, % sets the caption-position to bottom
breaklines = true, % sets automatic line breaking
breakatwhitespace = false, % sets if automatic breaks should only happen at whitespace
keywordstyle = \textbf\color{blue},
commentstyle = \color{darkgreen},
stringstyle = \ttfamily\color{magenta}
}
\begin{lstlisting}
temp = self.achseC00063Motortemp.value
while (temp <= sollTemp):
print("Motortemperatur: " + str(temp) + "°C")
sleep(2 * rampTime + 1)
self.achseC03001Solldrehzahl.value = maxRPM
sleep(2 * rampTime + 1)
self.achseC03001Solldrehzahl.value = -maxRPM
temp = self.achseC00063Motortemp.value
\end{lstlisting}
\end{document}
Hi!
Mein erster Post hier - ich hoffe, ich mache alles richtig ;)
Mein Problem habe ich versucht, auf das untenstehende Minimalbeispiel zusammenzuschrumpfen. Ich nutze das "listings-package" in der unten stehenden Einstellung.
Problem 1: Egal welche Sprache ich einstelle, er färbt den Code nicht ein. Also ignoriert und mit den Einstellungen korrigiert ;)
Problem 2: Lässt man Zeile 2 und 3 im Codebeispiel, gibt es den Fehler "Missing \endcsname inserted" - aber der kommt beim listings-package bei jedem Problem.
Habt ihr eine Idee?
[code]
\documentclass[a4paper, german, 12pt, oneside]{paper}
\usepackage{ngerman}
\usepackage{listings}
\usepackage{color}
\begin{document}
\lstset{ % Einstellungen fürs Listings-Paket
language = Python, % choose the language of the code
basicstyle = \footnotesize, % the size of the fonts that are used for the code
numbers = left, % where to put the line-numbers
numberstyle = \footnotesize, % the size of the fonts that are used for the line-numbers
stepnumber = 5, % the step between two line-numbers. If it's 1 each line will be numbered
numbersep = 5pt, % how far the line-numbers are from the code
backgroundcolor = \color{white}, % choose the background color. You must add \usepackage{color}
showspaces = false, % show spaces adding particular underscores
showstringspaces = false, % underline spaces within strings
showtabs = false, % show tabs within strings adding particular underscores
frame = single, % adds a frame around the code
tabsize = 2, % sets default tabsize to 2 spaces
captionpos = b, % sets the caption-position to bottom
breaklines = true, % sets automatic line breaking
breakatwhitespace = false, % sets if automatic breaks should only happen at whitespace
keywordstyle = \textbf\color{blue},
commentstyle = \color{darkgreen},
stringstyle = \ttfamily\color{magenta}
}
\begin{lstlisting}
temp = self.achseC00063Motortemp.value
while (temp <= sollTemp):
print("Motortemperatur: " + str(temp) + "°C")
sleep(2 * rampTime + 1)
self.achseC03001Solldrehzahl.value = maxRPM
sleep(2 * rampTime + 1)
self.achseC03001Solldrehzahl.value = -maxRPM
temp = self.achseC00063Motortemp.value
\end{lstlisting}
\end{document}
[/code]