von Kevin » Mi 9. Jan 2013, 14:45
Hallo, ich würde gerne meinen Quellcode mit verschieden Farben hervorheben. Hier mal ein Bsp was ich hervorheben möchte:
Print #4 , "#DL"
Hierbei ist "Print" blau so wie ich es haben wollte und "#DL" grün weil es als Kommentar gewertet wird, also auch ok für mich.
Ich würde nun aber auch gerne das Raute (#) Zeichen vor der 4 farblich hervorheben und zwar rot.
Ich habe schon einiges versucht, aber nichts klappt.. Könnt Ihr mir helfen?
Hier ein Teil meines Headers:
\usepackage{xcolor} %Farben
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}
\usepackage{listings} %Quelltexte
\lstset{ % bisschen was zum Herumspielen
%float,
%frame=tb,
backgroundcolor=\color{white}, %Hintergrundfarbe
basicstyle=\ttfamily\small, %schriftformatierung
keywordstyle=\bfseries\color{blue}, %Schlüsselwörterformatierung
stringstyle=\color{dkgreen}\ttfamily, %Stringformatierung
showstringspaces=false, %Leerzeichen werden angezeigt
frame=single, % adds a frame around the code
rulecolor=\color{black}, % if not set, the frame-color may be changed on line-breaks within not-black text
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
commentstyle=\itshape, %kommentare
numbers=left, %zeilennummerierung links
numberstyle=\tiny, %kleine zahlen
numbersep=5pt, %größe
}
% Add your keywords here, and have this in a separate file
% and include it in your preamble
\lstset{emph={%
Waitms, for, Start, Config, Alias, Wait, Loop, Waitkey, Inkey, Until, Split, Getadc, Fusing, Output, Word, Bit, Single, Binary, Const, \$baud, \$baud1, \$regfile, \$crystal, \$framesize , \$swstack, \$hwstack, On, Disable, Interrupts, NOP, Watchdog,High, Low, Xor, Inputbin, As, At, Byte, enable
% hier gewünschte keywords eintragen
},emphstyle={\color{blue}\bfseries}
}
Hallo, ich würde gerne meinen Quellcode mit verschieden Farben hervorheben. Hier mal ein Bsp was ich hervorheben möchte:
Print #4 , "#DL"
Hierbei ist "Print" blau so wie ich es haben wollte und "#DL" grün weil es als Kommentar gewertet wird, also auch ok für mich.
Ich würde nun aber auch gerne das Raute (#) Zeichen vor der 4 farblich hervorheben und zwar rot.
Ich habe schon einiges versucht, aber nichts klappt.. Könnt Ihr mir helfen?
Hier ein Teil meines Headers:
[code]\usepackage{xcolor} %Farben
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}
\usepackage{listings} %Quelltexte
\lstset{ % bisschen was zum Herumspielen
%float,
%frame=tb,
backgroundcolor=\color{white}, %Hintergrundfarbe
basicstyle=\ttfamily\small, %schriftformatierung
keywordstyle=\bfseries\color{blue}, %Schlüsselwörterformatierung
stringstyle=\color{dkgreen}\ttfamily, %Stringformatierung
showstringspaces=false, %Leerzeichen werden angezeigt
frame=single, % adds a frame around the code
rulecolor=\color{black}, % if not set, the frame-color may be changed on line-breaks within not-black text
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
commentstyle=\itshape, %kommentare
numbers=left, %zeilennummerierung links
numberstyle=\tiny, %kleine zahlen
numbersep=5pt, %größe
}
% Add your keywords here, and have this in a separate file
% and include it in your preamble
\lstset{emph={%
Waitms, for, Start, Config, Alias, Wait, Loop, Waitkey, Inkey, Until, Split, Getadc, Fusing, Output, Word, Bit, Single, Binary, Const, \$baud, \$baud1, \$regfile, \$crystal, \$framesize , \$swstack, \$hwstack, On, Disable, Interrupts, NOP, Watchdog,High, Low, Xor, Inputbin, As, At, Byte, enable
% hier gewünschte keywords eintragen
},emphstyle={\color{blue}\bfseries}
}
[/code]