[OS X TeX] listings.sty and utf8

Jonathan Kew jonathan_kew at sil.org
Thu Apr 20 11:06:56 CEST 2006


On 19 Apr 2006, at 4:04 pm, Alain Matthes wrote:

> Hello
>
> is it possible to use the package listings with a file with utf8  
> encoding ?
>
> ECM
>
> \documentclass[a4paper,10pt]{article}
> \usepackage[utf8]{inputenc}
> \usepackage{fourier}
> \usepackage{listings}
> \lstset{%
> language=[AlLaTeX]TEX,%
> extendedchars=true,%
> }
> \begin{document}
>
> \begin{lstlisting}
> Justifiez votre rŽponse.
> \end{lstlisting}
>
> \end{document}
>
> the file is saved with utf8 !
>
> error : ! Package inputenc Error: Unicode char
> \u8:Ã\expandafter not set up for use with LaTeX.

I don't know anything about using {listings} along with [utf8] 
{inputenc}, but in a quick test, it seems to work to use XeTeX to do  
something similar....

%!TEX TS-program = xelatex

\documentclass[a4paper,10pt]{article}
%\usepackage[utf8]{inputenc}
%\usepackage{fourier}
\usepackage{fontspec}
\setromanfont{Times Roman}
\usepackage{listings}
\lstset{%
language=[AlLaTeX]TEX,%
extendedchars=true,%
}
\begin{document}

\begin{lstlisting}
Justifiez votre rŽponse.
\end{lstlisting}

\end{document}

This runs without error messages; as I'm not sure what the {listings}  
package is meant to do, I can't vouch for the correctness of the  
output. It seems to be using the "roman" (body text) typeface with  
monospaced characters, but perhaps that's the intent.

JK

------------------------- Info --------------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
          & FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Archive: http://tug.org/pipermail/macostex-archives/




More information about the macostex-archives mailing list