-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate_C_Template.tex
46 lines (41 loc) · 2 KB
/
template_C_Template.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
\usepackage{listings} % Package for highlighting code
\usepackage{color}
% Custom colors
\definecolor{MyDarkGreen}{rgb}{0.004,0.25,0.11} % Normalized values (1,64/255,28/255)
\definecolor{MyGreen}{rgb}{0.0078,0.45,0.20} % Normalized values (2/255,115/255,51/255)
\definecolor{MyLightGreen}{rgb}{0.0745,0.95,0.54} % Normalized values (19/255,242/255,138/255)
\lstset{
language=C, % Set language to C
frame=single, % Single frame around code
keywordstyle=\color{MyGreen}\bfseries, % Keywords like int in MyGreen, bold
identifierstyle=, % Default style for identifiers
commentstyle=\color{MyLightGreen}, % Comments in MyLightGreen
stringstyle=\color{MyGreen}, % Strings (inside quotes) in MyGreen
showstringspaces=false, % Don't mark spaces in strings
tabsize=4, % Tab size set to 4 spaces
numbers=left, % Line numbers on the left
firstnumber=1, % Start line numbers at 1
numberstyle=\tiny\color{gray}, % Line numbers in small gray text
stepnumber=1, % Increment line numbers by 1
morekeywords={int, uint8_t, uint16_t, uint32_t, int8_t, int16_t, int32_t}, % Add types in MyGreen
escapeinside={/*@}{@*/}, % Allows escaping LaTeX within code
morekeywords=[2]{printf, scanf, main}, % Functions in MyDarkGreen
keywordstyle=[2]\color{MyDarkGreen}, % Style for functions
morecomment=[l][\color{MyLightGreen}]{//}, % Single-line comments in MyLightGreen
morecomment=[s][\color{MyLightGreen}]{/*}{*/}, % Block comments in MyLightGreen
}
\begin{document}
\begin{lstlisting}
#include <stdio.h>
#include <stdint.h> // For standard integer types
// Function to add two integers
int add(int a, int b) {
return a + b;
}
int main() {
int x = 5, y = 10;
printf("Sum: %d\n", add(x, y));
return 0;
}
\end{lstlisting}
\end{document}