Wow, Ulrike, thanks. This is a really useful bit of code. I'm not sure I understand the difference between the commented out code and the initial \...@ccput line.

If I comment out the \...@ccput line, and replace EURO with €, I get the same result, correct? Why is this so, and is there a reason to do it one way or the other?

Alan



On Jun 1, 2010, at 3:51 AM, Ulrike Fischer wrote:

Am Sun, 30 May 2010 16:30:07 -0400 schrieb Alan Munn:

When I compile the attached t.tex with xelatex I get the attached
t.pdf, in which the big pi has somehow switched positions with
'a'. What's going on here? :)


This is a problem with the listings package, which is incompatible
with UTF-8 encoded files.

Well with xetex listings is more compatible with utf8 than with
standard 8-bit-pdftex, as now it no longer has the problem that a
character is split at the input in 8-bit-pieces. Non-ASCII-chars
like ä, ö, ü works (even without the extendedchars option) without
problems.

The problem here is that listings makes the necessary definitions
only for character up to position 255.

But adding the code for a new one is quite easy (I used the euro,
which has the same problem than the greek, but is easier to handle
for me). The commented part shows how to replace an input by
arbitrary text:

\documentclass{article}
\usepackage{fontspec}
\usepackage{listings}
\makeatletter
\...@ccput \...@processletter {"20AC}\z@

%\...@ccputmacro
%    \...@processother {"20AC}{EURO}
%    \...@empty\z@\...@empty

\lstset{MoreSelectCharTable=\catcode`\€\active}
\makeatother
\begin{document}
\begin{lstlisting}[columns=flexible]
a€b
\end{lstlisting}

x \lstinline|a€b| y
\end{document}

I don't think that it is a good idea to add all unicode chars as
default, compilation would need much more time if all chars had to
been reset before and after each listings, but some user commands
which allows to extend the possible input for listings would be a
good idea.



--
Ulrike Fischer



--------------------------------------------------
Subscriptions, Archive, and List information, etc.:
 http://tug.org/mailman/listinfo/xetex

--
Alan Munn
am...@gmx.com







--------------------------------------------------
Subscriptions, Archive, and List information, etc.:
 http://tug.org/mailman/listinfo/xetex

Reply via email to