von Wiggle » Fr 3. Feb 2012, 14:47
Hallo,
ich bin gerade dabei einen Quelltext in ein LaTeX-Dokument einzufügen. Es handelt sich um ein C++-Quellcode und ich möchte gerne die Includes einfärben.
Die Struktur eines solchen Includes lautet wie folgt:
Das Schlüsselwort "#include" wird bereits eingefärbt, jedoch nicht die spitzen Klammern mit dem Inhalt.
Hat hierzu jemand eine Idee? Meine Einstellungen für das \listings-Paket sehen so aus:
\lstset{
language=C++, % 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=1, % 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
rulecolor=\color{black}, % if not set, the frame-color may be changed on line-breaks within not-black
tabsize=4, % 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
caption=\lstname, % show the filename of files included with \lstinputlisting;
% also try caption instead of title
morekeywords={*, ..., std, string, boolean, AnsiString, package, link,resource, __fastcall, __published, TGroupBox, TSplitter, TOpenDialog, TStatusBar, TScrollBox, TImage, TPopupMenu, TMenuItem, TActionList, TAction, TFrame, TForm, TListBox, TTimer, TObject, TComponent, POINT, PACKAGE, <##>},
% if you want to add more keywords to the set
numberstyle=\tiny\color{gray}, % line number style
keywordstyle=\color{blue}, % keyword style
commentstyle=\color{dkgreen}, % comment style
stringstyle=\color{mauve}, % string literal style
escapeinside={\%*}{*)}, % if you want to add a comment within your code
flexiblecolumns=false,
basicstyle=\sffamily,
literate=
*{0}{{{\color{red}0}}}1
{1}{{{\color{red}1}}}1
{2}{{{\color{red}2}}}1
{3}{{{\color{red}3}}}1
{4}{{{\color{red}4}}}1
{5}{{{\color{red}5}}}1
{6}{{{\color{red}6}}}1
{7}{{{\color{red}7}}}1
{8}{{{\color{red}8}}}1
{9}{{{\color{red}9}}}1
{-0}{{{\color{red}-0}}}1
{-1}{{{\color{red}-1}}}1
{-2}{{{\color{red}-2}}}1
{-3}{{{\color{red}-3}}}1
{-4}{{{\color{red}-4}}}1
{-5}{{{\color{red}-5}}}1
{-6}{{{\color{red}-6}}}1
{-7}{{{\color{red}-7}}}1
{-8}{{{\color{red}-8}}}1
{-9}{{{\color{red}-9}}}1
}
Ich danke schonmal für jeglichen Hinweis
Hallo,
ich bin gerade dabei einen Quelltext in ein LaTeX-Dokument einzufügen. Es handelt sich um ein C++-Quellcode und ich möchte gerne die Includes einfärben.
Die Struktur eines solchen Includes lautet wie folgt:
[code]#include<name_der_datei>[/code]
Das Schlüsselwort "#include" wird bereits eingefärbt, jedoch nicht die spitzen Klammern mit dem Inhalt.
Hat hierzu jemand eine Idee? Meine Einstellungen für das \listings-Paket sehen so aus:
[code]\lstset{
language=C++, % 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=1, % 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
rulecolor=\color{black}, % if not set, the frame-color may be changed on line-breaks within not-black
tabsize=4, % 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
caption=\lstname, % show the filename of files included with \lstinputlisting;
% also try caption instead of title
morekeywords={*, ..., std, string, boolean, AnsiString, package, link,resource, __fastcall, __published, TGroupBox, TSplitter, TOpenDialog, TStatusBar, TScrollBox, TImage, TPopupMenu, TMenuItem, TActionList, TAction, TFrame, TForm, TListBox, TTimer, TObject, TComponent, POINT, PACKAGE, <##>},
% if you want to add more keywords to the set
numberstyle=\tiny\color{gray}, % line number style
keywordstyle=\color{blue}, % keyword style
commentstyle=\color{dkgreen}, % comment style
stringstyle=\color{mauve}, % string literal style
escapeinside={\%*}{*)}, % if you want to add a comment within your code
flexiblecolumns=false,
basicstyle=\sffamily,
literate=
*{0}{{{\color{red}0}}}1
{1}{{{\color{red}1}}}1
{2}{{{\color{red}2}}}1
{3}{{{\color{red}3}}}1
{4}{{{\color{red}4}}}1
{5}{{{\color{red}5}}}1
{6}{{{\color{red}6}}}1
{7}{{{\color{red}7}}}1
{8}{{{\color{red}8}}}1
{9}{{{\color{red}9}}}1
{-0}{{{\color{red}-0}}}1
{-1}{{{\color{red}-1}}}1
{-2}{{{\color{red}-2}}}1
{-3}{{{\color{red}-3}}}1
{-4}{{{\color{red}-4}}}1
{-5}{{{\color{red}-5}}}1
{-6}{{{\color{red}-6}}}1
{-7}{{{\color{red}-7}}}1
{-8}{{{\color{red}-8}}}1
{-9}{{{\color{red}-9}}}1
}[/code]
Ich danke schonmal für jeglichen Hinweis :D