TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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} ?

share|improve this question

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.