Two examples first:
One
-----
\documentclass[a4paper]{article}
\usepackage{listings}
\begin{document}
\lstinputlisting[linerange=1-7]{data.dat}
\end{document}
-----
In this way I will print only lines from 1 to 7 of "data.dat".
Two
-----
\documentclass[a4paper]{article}
\usepackage{listings}
\usepackage{xcolor}
\begin{document}
\lstinputlisting[emph={keyword},emphstyle=\color{red}]{data.dat}
\end{document}
-----
In this way I will print in red only the word "keyword", every time it
occurres.
My question: is there a simple way to combine the two behaviors and
obtain a defined range of lines emphasized in a chosen way?
Obviously I don't want to change the file "data.dat" neither it has
useful characters in it that can be used with "morestring" or
"morecomment".
Thanks
LuCa
> Hi to all!
> I use listings and I'm looking for a particular behaviour.
>
> Two examples first:
> In this way I will print only lines from 1 to 7 of "data.dat".
> In this way I will print in red only the word "keyword", every time it
> occurres.
> My question: is there a simple way to combine the two behaviors and
> obtain a defined range of lines emphasized in a chosen way?
> Obviously I don't want to change the file "data.dat" neither it has
> useful characters in it that can be used with "morestring" or
> "morecomment".
Well you could do something like this:
\documentclass[a4paper]{article}
\usepackage{listings}
\usepackage{xcolor}
\begin{document}
\lstinputlisting[basicstyle=\color{red},linerange=1-2,belowskip=0pt]{data.dat}
\lstinputlisting[linerange=3-4,aboveskip=0pt]{data.dat}
\end{document}
--
Ulrike Fischer
Thank, this is a nice workaround!
Non that general but it works!
;)
LuCa