0

This question is a continuation of The 'listings' package and UTF-8. I'm trying to display the characters and in a listing (from the listings package). Thanks to Ulrike's answer, I added them to the processing list of listings first and use extendedchars=true, using their Unicode positions (if I'm right, 2329 and 232A).

As shown by the following MCE, these characters are displayed but badly positioned.

How to fix this?

\documentclass{article}
\usepackage{fontspec}
\usepackage{kpfonts-otf}
\usepackage{listings}

\lstset{basicstyle=\ttfamily,extendedchars=true,frame=single}

\DeclareTextSymbol{\textlangle}\UnicodeEncodingName{"2329} \DeclareTextSymbol{\textrangle}\UnicodeEncodingName{"232A}

\makeatletter \lst@InputCatcodes \def\lst@DefEC{% \lst@CCECUse \lst@ProcessLetter ^^80^^81^^82^^83^^84^^85^^86^^87^^88^^89^^8a^^8b^^8c^^8d^^8e^^8f% ^^90^^91^^92^^93^^94^^95^^96^^97^^98^^99^^9a^^9b^^9c^^9d^^9e^^9f% ^^a0^^a1^^a2^^a3^^a4^^a5^^a6^^a7^^a8^^a9^^aa^^ab^^ac^^ad^^ae^^af% ^^b0^^b1^^b2^^b3^^b4^^b5^^b6^^b7^^b8^^b9^^ba^^bb^^bc^^bd^^be^^bf% ^^c0^^c1^^c2^^c3^^c4^^c5^^c6^^c7^^c8^^c9^^ca^^cb^^cc^^cd^^ce^^cf% ^^d0^^d1^^d2^^d3^^d4^^d5^^d6^^d7^^d8^^d9^^da^^db^^dc^^dd^^de^^df% ^^e0^^e1^^e2^^e3^^e4^^e5^^e6^^e7^^e8^^e9^^ea^^eb^^ec^^ed^^ee^^ef% ^^f0^^f1^^f2^^f3^^f4^^f5^^f6^^f7^^f8^^f9^^fa^^fb^^fc^^fd^^fe^^ff% ^^^^20ac^^^^0153^^^^0152% nouveau pour xetex ^^^^2329% Left-Pointing Angle Bracket ^^^^232a% Right-Pointing Angle Bracket ^^00} \lst@RestoreCatcodes \makeatother

\begin{document} \ttfamily{} ⟨foo⟩ \begin{lstlisting} ⟨foo⟩ \end{lstlisting} \end{document}

enter image description here

Denis Bitouzé
  • 9,652
  • 4
  • 27
  • 85

0 Answers0