I followed few answers mentioned here to highlight the XML content in my latex and tried to combine best things together from different answers but for some reason nothing is being highlighted in my XML? Can someone please help me how to make XML content in my latex to look appealing? I tried the following answer: https://tex.stackexchange.com/a/11134/226278
My XML is quite large and spans over 2-3 pages but now it's being displayed in a frame with line number so looks nice but none of the tags or strings is being highlighted except for some strings in the XML header. I would like to highlight the tags and strings in them so it would look nicer.
\usepackage{listings}
\usepackage{color}
\definecolor{gray}{rgb}{0.4,0.4,0.4}
\definecolor{darkblue}{rgb}{0.0,0.0,0.6}
\definecolor{cyan}{rgb}{0.0,0.6,0.6}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\geometry{a4paper}
\lstset{
language=xml,
tabsize=3,
%frame=lines,
caption=Bulk test data events for rail sector
label=code:rail1,
frame=shadowbox,
xleftmargin=20pt,
framexleftmargin=15pt,
numbers=left,
numberstyle=\tiny,
numbersep=5pt,
breaklines=true,
showstringspaces=false,
basicstyle=\footnotesize,
basicstyle=\ttfamily,
columns=fullflexible,
showstringspaces=false,
basicstyle=\ttfamily\footnotesize,
morestring=[b]",
moredelim=[s][\bfseries\color{Maroon}]{<}{\ },
moredelim=[s][\bfseries\color{Maroon}]{</}{>},
moredelim=[l][\bfseries\color{Maroon}]{/>},
moredelim=[l][\bfseries\color{Maroon}]{>},
morecomment=[s]{<?}{?>},
morecomment=[s]{<!--}{-->},
commentstyle=\color{DarkOliveGreen},
stringstyle=\color{blue},
identifierstyle=\color{red},
}
\lstinputlisting{pics/RailSector.xml}
For example this is my sample XML file which I want to highlight and present in the pics folder:
<?xml version="1.0"?>
<hello:mydocument>
<manufacturing>court</manufacturing>
<bend>grabbed</bend>
<quick>613049078</quick>
<am>
<brief>-2019050644</brief>
<judge>955087623.417459</judge>
<birds>green</birds>
<join>among</join>
<slight>
<box>loose</box>
<butter>table</butter>
<afternoon>good</afternoon>
<suddenly>rear</suddenly>
<kitchen>copper</kitchen>
<locate>802538930</locate>
</slight>
<wagon>1157100273.040341</wagon>
</am>
<this>1903268890</this>
<rule>-1380139207</rule>
</hello:mydocument>
pics/RailSector.xml
. Could you adjust your example to use thelstlisting
environment? I assume that it would have the same highlighting issue that you're trying to solve.lstset
andlstlisting
? is it possible to do the highlighting in the above code itself?\begin{document}
and an\end{document}
?\documentclass{...}
, the required\usepackage
's,\begin{document}
, and\end{document}
. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem.