I've got a HTML document with JavaScript inside that I want to show in my article.

For that I would like to use my JavaScript and HTML formatting. How can I get the listings package to use two styles?

Is there something like language={HTML, JavaScript} ?

1 Answer 1


There sure is, you can:

% Preamble

   % Languages to use
\lstloadlanguages{C, sh}

   % My C preferences
        basicstyle=\sffamily, commentstyle=\slshape,
        extendedchars, frame=lines, numbers=none,
        float, floatplacement=ht, captionpos=b,
        xleftmargin=1em, xrightmargin=1em

   % Handling of UTF-8 in listings is less than stellar, need an entry for   
   % each non-ASCII character

% Document body
  % Code inline
... \lstinline[language=C]!a * x + b * y + c * (-(u + v))! ...
  % Code from an external file as float
                   xleftmargin=3em, numbers=left,
                   caption={Ordenamiento por inserción},

There are some supposed UTF-8 clean versions around, but they didn't work for me.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .