Listings package: - coloured text

155 views
Skip to first unread message

Yen

unread,
Mar 22, 2010, 11:05:26 AM3/22/10
to LaTeX Users Group
Hi everybody.
I´m looking for any help with little problem with listings package. I
tried find some example on google, but no luck.

I have some bash output (response) and I need put them to my project.
For this purpose I´m using the listings package (it´s great).

There is a part of my response:
[code]
[00:00:00] 80 keys tested (256.41 k/s)

KEY FOUND! [ 12345678 ]

Master Key : 37 3E FB 3B F8 6E 40 41 69 07 16 26 FE 89 81 AD
F4 CF 55 95 93 51 CB ED 50 35 0A A2 04 ED C9 29

Transcient Key : 79 A4 3D 2B 5F 00 99 3D 83 BD 11 4B FE C1 D9 83
[/code]

And now I need some help - How can I do in simple way (if there is
one) coloured few part of this response? I read the manual for
listings package, but I´m not understand it (How should I use:
keywords, otherkeywords, morekeywords, alsodigit, alsoother, ...)

My code for LaTeX is:
[code]
\lstset{backgroundcolor=\color{bezovaC}, basicstyle=\scriptsize,
language=bash,
moredelim=[is][\bfseries]{|}{|},
%
classoffset=0,
keywords=[1]{KEY, FOUND}, keywordstyle=[1]\color{red}
\bfseries,
classoffset=1,
otherkeywords={!},
classoffset=0
}
%
\begin{lstlisting}[frame=single, framerule=1pt]
Aircrack-ng 0.9.1 r687

[00:00:00] 80 keys tested (256.41 k/s)

KEY FOUND! [ 12345678 ]

Master Key : 37 3E FB 3B F8 6E 40 41 69 07 16 26 FE 89 81 AD
F4 CF 55 95 93 51 CB ED 50 35 0A A2 04 ED C9 29

Transcient Key : 79 A4 3D 2B 5F 00 99 3D 83 BD 11 4B FE C1 D9 83
\end{lstlisting}
%
[/code]

With this code I was able to make "KEY FOUND!" in red color only. But
I need more color highlight:
"12345678" in blue
"Master Key" in green
"37 3E FB 3B F8 6E 40 41 69 07..." in other color and so on...

Anybody known the way how can I do that? :-( Maybe one of you already
do something like this and maybe can share with the source code.
Is there something like tags <...> and by the definitions everything
inside is coloured?

Any idea? Thank to everybody for any help.
(Sorry to my english grammar, I hope that it is understandable :o) )

Yen

unread,
Mar 22, 2010, 4:49:20 PM3/22/10
to LaTeX Users Group
Solved!
I had to read more carefully manual of listings package. Sorry for
spam :mrgreen:
But maybe for someone who not read carefully like me...
[code]
moredelim=[is][\color{Bittersweet}]{+}{+}, %
moredelim=*[is][\color{blue}\bfseries]{&}{&}, %
moredelim=**[is][\color{Plum}]{@}{@}, %
moredelim=***[is][\color{RoyalBlue}]{*}{*}, %
moredelim=***[is][\color{OliveGreen}]{'}{'}, %
[/code]
Paste to body of "\lstset{...}"

[code]


%
\begin{lstlisting}[frame=single, framerule=1pt]

|Transcient Key| : +79 A4 3D 2B 5F 00 99 3D 83 BD 11 4B FE C1 D9 83+
\end{lstlisting}
%
[/code]
All between delimeters +...+ will be coloured with specific color.

Reply all
Reply to author
Forward
0 new messages