[XeTeX] xetex + listings + inputencoding
Ulrike Fischer
news2 at nililand.de
Wed Feb 4 10:20:36 CET 2009
Am Wed, 04 Feb 2009 09:02:25 +0100 schrieb M. Niedermair:
> Hi,
>
> what is the best way, to include listings in utf8/iso8859-1 encoding.
>
> In the listings doc i found:
>
> inputencoding=<encoding>
> determines the input encoding. The usage of this key requires the
> inputenc package; nothing happens if it’s not loaded.
>
> % ---------------------------------
> \documentclass{scrartcl}
> \usepackage{xltxtra}
> \usepackage[final,writefile]{listings}
> \lstloadlanguages{java,HTML,[AlLaTeX]TeX,make}
> \begin{document}
> Listing 1 (utf8)
>
> \lstinputlisting{list1.java}
>
> Listing 2 (iso8859-1)
>
> \lstinputlisting[inputencoding=latin1]{list2.java}
> \end{document}
> % ---------------------------------
>
> If i use the sample, i see the correct chars in list1.java, but in
> list2.java the chars are missing.
>
> If i use the package inputenc, i get the message
> *** you should *not* be loading the inputenc package
>
> If i use
> \usepackage[inputencoding=utf8/latin1]{listingsutf8}
> i get some errors.
Try
\XeTeXdefaultencoding latin1
\lstinputlisting{list2.java}
\XeTeXdefaultencoding auto
Perhaps grouping with
\begingroup
\XeTeXdefaultencoding latin1
\lstinputlisting{list2.java}
\endgroup
works too -- I have forgotten if the setting is global or local and
don't have the time to test.
--
Ulrike Fischer
More information about the XeTeX
mailing list