von Spliffer1 » Do 9. Mär 2017, 21:40
Hallo Leute,
ich lese schon lange in Eurem genialen Forum mit ind habe heute meine erste Frage:
Ich habe C++ Code in ein Dokument eingebunden und fast erfolgreich formatiert. Nun möchte ich die include-Anweisungen in der Farbe MyMoreK hervorheben und sin() und cos() mitsamt den runden klammern in der Farbe MyTrigoFunctions hervorheben aber es klappt einfach nicht. Ich versuch das jetzt schon seit 2 Tagen. Hier ist der MinimalCode:
\documentclass[a4paper,abstracton,titlepage]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[sfdefault]{AlegreyaSans}
\usepackage[latin1]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{url}
\usepackage[locale=DE]{siunitx}
\usepackage{mdwlist}
\usepackage{paralist}
\usepackage{xcolor}
\usepackage{listings}
\definecolor{MyString}{RGB}{101,138,186}
\definecolor{MyKeyword}{RGB}{0,0,128}
\definecolor{MyBackground}{RGB}{235,235,235}
\definecolor{MyIdentifier}{RGB}{0,128,128}
\definecolor{MyMoreK}{RGB}{49,128,255}
\definecolor{MyTrigoFunctions}{RGB}{217,87,22}
\lstset{
% language=C++,
% upquote=true,
%columns=fixed,
belowcaptionskip=1\baselineskip,
breaklines=true,
backgroundcolor=\color{MyBackground},
%frame=L,
xleftmargin=\parindent,
showstringspaces=false,
basicstyle=\small,
breakatwhitespace=true,
breaklines=true,
keepspaces=false,
rulecolor=\color{black},
keywordstyle=\bfseries\color{MyKeyword},
stringstyle=\bfseries\color{MyString},
commentstyle=\color{purple!80!black},%\itshape
identifierstyle=\color{MyIdentifier},%\bfseries
% prebreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\hookleftarrow}},
tabsize=1,
showtabs=false,
emph={include},
emphstyle={\color{MyMoreK}},
}
%\lstset{style=MyCppStyle}
\begin{document}
\begin{lstlisting}[language=C++, caption={C++ code using listings}]
//#include<winbgim.h>
#include<graphics.h>
#include<cmath.h>
int SCREEN_W = 800;
int SCREEN_H = 200;
main(int argc, char*argv[])
{
initwindow(SCREEN_W, SCREEN_H);
setbkcolor(0);
cleardevice();
// Koordinaten für Kreis
int x, y;
const float PI = 3.14159265358979f;
int length = 50;
float angle = 0.0;
float angle_stepsize = 0.1;
setcolor(15);
settextstyle(10, HORIZ_DIR, 2);
outtextxy(120, 20, "Circle_001 Kreis mit Sinus() und Cosinus(): ");
// go through all angles from 0 to 2 * PI radians
while (angle < 2 * PI)
{
// calculate x, y from a vector with known length and angle
x = length * cos (angle);
y = length * sin (angle);
putpixel((x + SCREEN_W/ 2) - 20 , (y + SCREEN_H/ 2) + 20 ,15);
angle += angle_stepsize;
}
while(!kbhit())
{
delay(1);
}
return 0;
}
\end{lstlisting}
\end{document}
Hoffentlich könnt Ihr mir helfen.
Vielen Dank schonmal an dieser Stelle!
Grüße,
Spliffer
Hallo Leute,
ich lese schon lange in Eurem genialen Forum mit ind habe heute meine erste Frage:
Ich habe C++ Code in ein Dokument eingebunden und fast erfolgreich formatiert. Nun möchte ich die include-Anweisungen in der Farbe MyMoreK hervorheben und sin() und cos() mitsamt den runden klammern in der Farbe MyTrigoFunctions hervorheben aber es klappt einfach nicht. Ich versuch das jetzt schon seit 2 Tagen. Hier ist der MinimalCode:
[code]
\documentclass[a4paper,abstracton,titlepage]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[sfdefault]{AlegreyaSans}
\usepackage[latin1]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{url}
\usepackage[locale=DE]{siunitx}
\usepackage{mdwlist}
\usepackage{paralist}
\usepackage{xcolor}
\usepackage{listings}
\definecolor{MyString}{RGB}{101,138,186}
\definecolor{MyKeyword}{RGB}{0,0,128}
\definecolor{MyBackground}{RGB}{235,235,235}
\definecolor{MyIdentifier}{RGB}{0,128,128}
\definecolor{MyMoreK}{RGB}{49,128,255}
\definecolor{MyTrigoFunctions}{RGB}{217,87,22}
\lstset{
% language=C++,
% upquote=true,
%columns=fixed,
belowcaptionskip=1\baselineskip,
breaklines=true,
backgroundcolor=\color{MyBackground},
%frame=L,
xleftmargin=\parindent,
showstringspaces=false,
basicstyle=\small,
breakatwhitespace=true,
breaklines=true,
keepspaces=false,
rulecolor=\color{black},
keywordstyle=\bfseries\color{MyKeyword},
stringstyle=\bfseries\color{MyString},
commentstyle=\color{purple!80!black},%\itshape
identifierstyle=\color{MyIdentifier},%\bfseries
% prebreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\hookleftarrow}},
tabsize=1,
showtabs=false,
emph={include},
emphstyle={\color{MyMoreK}},
}
%\lstset{style=MyCppStyle}
\begin{document}
\begin{lstlisting}[language=C++, caption={C++ code using listings}]
//#include<winbgim.h>
#include<graphics.h>
#include<cmath.h>
int SCREEN_W = 800;
int SCREEN_H = 200;
main(int argc, char*argv[])
{
initwindow(SCREEN_W, SCREEN_H);
setbkcolor(0);
cleardevice();
// Koordinaten für Kreis
int x, y;
const float PI = 3.14159265358979f;
int length = 50;
float angle = 0.0;
float angle_stepsize = 0.1;
setcolor(15);
settextstyle(10, HORIZ_DIR, 2);
outtextxy(120, 20, "Circle_001 Kreis mit Sinus() und Cosinus(): ");
// go through all angles from 0 to 2 * PI radians
while (angle < 2 * PI)
{
// calculate x, y from a vector with known length and angle
x = length * cos (angle);
y = length * sin (angle);
putpixel((x + SCREEN_W/ 2) - 20 , (y + SCREEN_H/ 2) + 20 ,15);
angle += angle_stepsize;
}
while(!kbhit())
{
delay(1);
}
return 0;
}
\end{lstlisting}
\end{document}
[/code]
Hoffentlich könnt Ihr mir helfen.
Vielen Dank schonmal an dieser Stelle!
Grüße,
Spliffer