GeneralProblem with Listings package syntax highlighting

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
Hessiess
Posts: 4
Joined: Sat Dec 06, 2008 1:01 pm

Problem with Listings package syntax highlighting

Post by Hessiess »

I have bean writing a document containing HTML and using Listings to hi light it.The problem is that Listings is hi lighting keywords like ``frame'', ``width'' and ``for'' within comments as keywords, which should be hi lighted the same colour as the rest of the comment.

Image

Code: Select all

\documentclass[11pt,a4paper]{article}

\usepackage[usenames]{color}
\usepackage{listings}

%set up code styling
\definecolor{darkgreen}{rgb}{0.0,0.6,0.2} 

\lstset{
	language=HTML,
	basicstyle=\color{black},
	keywordstyle=\color{darkgreen},
	identifierstyle=,
	commentstyle=\color{blue},
	stringstyle=\color{red},
	showstringspaces=false
}

\begin{document}
\begin{lstlisting}
    <!-- divide viewport horizontally into 2 frames -->
    <frameset rows="50px, *">
	<!-- The first frame is the full width header -->
	<frame src="header.html" />
	    <!-- another frameset is added to the second frame to
	    create an aria for the navigation and content -->
	    <frameset cols="120px,*">
		    <frame src="navi.html" />
		    <frame src="frame_a.html"  
		    name="showframe" />
	    </frameset>
    </frameset>
\end{lstlisting}
\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

Problem with Listings package syntax highlighting

Post by Juanjo »

Add comment=[s]{<!--}{-->} in the argument of \lstset.
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
Hessiess
Posts: 4
Joined: Sat Dec 06, 2008 1:01 pm

Re: Problem with Listings package syntax hilighting

Post by Hessiess »

Thanks.
Post Reply