Try this code:
\documentclass[12pt]{amsart}
\usepackage{geometry}
\usepackage{listings}
\usepackage{color}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\geometry{a4paper}
\begin{document}
This is a sample file:
\lstset{
language=xml,
tabsize=3,
%frame=lines,
caption=Test,
label=code:sample,
frame=shadowbox,
rulesepcolor=\color{gray},
xleftmargin=20pt,
framexleftmargin=15pt,
keywordstyle=\color{blue}\bf,
commentstyle=\color{OliveGreen},
stringstyle=\color{red},
numbers=left,
numberstyle=\tiny,
numbersep=5pt,
breaklines=true,
showstringspaces=false,
basicstyle=\footnotesize,
emph={food,name,price},emphstyle={\color{magenta}}}
\lstinputlisting{simple.xml}
\end{document}
Using the above code I have results like this:
Please note that the I've added "price", "name" and "food" as keywords.
Credits for sample XML file:
http://www.w3schools.com/xml/xml_examples.asp
The lookup is in the aux
file, things like
\bibcite{grimm}{1}
or with hyperref
\bibcite{grimm}{{1}{}{{}}{{}}}
tell you that grimm
is [1]
so you just need to grep
for bibcite
in the aux
file and then pull that data in using a tool of your choice.
Best Answer
I don't know about the possible solutions with LaTeX and pdftex engine, but ConTeXt MkIV (which uses LuaTeX engine) supports an XML backend that is used to generate EPUB and tagged PDF.
To get the XML output from a file, you need to add
As an example, consider a simple file with some figures, math, and lists.
which generates the following PDF output
In addition, it generates the following XML file
\jobname.export
(notice that all the structural information is retained and math is exported to MathML)Two auxiliary
css
files are also generated, the first\jobname-style.css
which contains css for the font setup and any ConTeXt defined environments and colors:and a
\jobname-images.css
file that contains information about the images used in the tex file.