Skip to content

Instantly share code, notes, and snippets.

@sebald
Created July 17, 2012 17:53
Show Gist options
  • Save sebald/3130827 to your computer and use it in GitHub Desktop.
Save sebald/3130827 to your computer and use it in GitHub Desktop.
Latex Listing XML Style
\usepackage{listings}
\usepackage{color}
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}
\definecolor{gray}{rgb}{0.4,0.4,0.4}
\definecolor{darkblue}{rgb}{0.0,0.0,0.6}
\definecolor{lightblue}{rgb}{0.0,0.0,0.9}
\definecolor{cyan}{rgb}{0.0,0.6,0.6}
\definecolor{darkred}{rgb}{0.6,0.0,0.0}
\lstset{
basicstyle=\ttfamily\footnotesize,
columns=fullflexible,
showstringspaces=false,
numbers=left, % where to put the line-numbers
numberstyle=\tiny\color{gray}, % the style that is used for the line-numbers
stepnumber=1,
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=none, % 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 (e.g. commens (green here))
tabsize=2, % 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
title=\lstname, % show the filename of files included with \lstinputlisting;
% also try caption instead of title
commentstyle=\color{gray}\upshape
}
\lstdefinelanguage{XML}
{
morestring=[s][\color{mauve}]{"}{"},
morestring=[s][\color{black}]{>}{<},
morecomment=[s]{<?}{?>},
morecomment=[s][\color{dkgreen}]{<!--}{-->},
stringstyle=\color{black},
identifierstyle=\color{lightblue},
keywordstyle=\color{red},
morekeywords={xmlns,xsi,noNamespaceSchemaLocation,type,id,x,y,source,target,version,tool,transRef,roleRef,objective,eventually}% list your attributes here
}
@claudia-lat
Copy link

Thanks Sebald! This gist helped me a lot!

@GuillermoYanez
Copy link

Thank you Sebald. Great gist!

@spartajet
Copy link

Many thanks!

@daschr
Copy link

daschr commented Jul 29, 2020

Thank you!

@elivaldolozer
Copy link

Thank you, Sebald!

@jpwco
Copy link

jpwco commented Sep 12, 2021

Thank you this is soooooo useful --- HOORAY Sebald!

@MashRoofa
Copy link

Cool thank you! 🤘

@TheWillyM4AK
Copy link

Its perfect, thank you.

@raul7gs
Copy link

raul7gs commented Nov 28, 2023

Really useful, thankssss

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment