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


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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