软件包 inputenc 列表中存在错误

软件包 inputenc 列表中存在错误

如果我将包含法语字符的文本放在 之外\begin{lstlisting}...\end{lstlisting},它就会起作用。例如,

\documentclass[twoside,12pt]{article}

\usepackage[utf8]{inputenc}

% for source code 
\usepackage{listingsutf8}
\usepackage{listings}
\lstset{frame=single,
  aboveskip=3mm,
  belowskip=3mm,
  columns=flexible,
  basicstyle={\small\ttfamily},
  breaklines=True,
  postbreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\hookrightarrow\space}}
}

\begin{document}
\begin{lstlisting}
route_id,agency_id,route_short_name,route_long_name,route_desc,route_type,route_url,route_color,route_text_color
\end{lstlisting}

11821949021891662,6192449487677451,67,Arènes / Plaisance Monestié (par Marquisat),Ligne Arènes / Plaisance Monestié (par Marquisat),3,,ffa8ff,FFFFFF

\end{document}

产生,

在此处输入图片描述


但如果我把它们放进去\begin{lstlisting}...\end{lstlisting}

\begin{lstlisting}
route_id,agency_id,route_short_name,route_long_name,route_desc,route_type,route_url,route_color,route_text_color
11821949021891662,6192449487677451,67,Arènes / Plaisance Monestié (par Marquisat),Ligne Arènes / Plaisance Monestié (par Marquisat),3,,ffa8ff,FFFFFF
\end{lstlisting}

它引发了错误! Package inputenc Error: Unicode char �\lst@EC� (U+9EA8)

我如何解决它?

答案1

我通过定义特殊字符来实现这一点,

\lstset{literate=
  {á}{{\'a}}1 {é}{{\'e}}1 {í}{{\'i}}1 {ó}{{\'o}}1 {ú}{{\'u}}1
  {Á}{{\'A}}1 {É}{{\'E}}1 {Í}{{\'I}}1 {Ó}{{\'O}}1 {Ú}{{\'U}}1
  {à}{{\`a}}1 {è}{{\`e}}1 {ì}{{\`i}}1 {ò}{{\`o}}1 {ù}{{\`u}}1
  {À}{{\`A}}1 {È}{{\'E}}1 {Ì}{{\`I}}1 {Ò}{{\`O}}1 {Ù}{{\`U}}1
  {ä}{{\"a}}1 {ë}{{\"e}}1 {ï}{{\"i}}1 {ö}{{\"o}}1 {ü}{{\"u}}1
  {Ä}{{\"A}}1 {Ë}{{\"E}}1 {Ï}{{\"I}}1 {Ö}{{\"O}}1 {Ü}{{\"U}}1
  {â}{{\^a}}1 {ê}{{\^e}}1 {î}{{\^i}}1 {ô}{{\^o}}1 {û}{{\^u}}1
  {Â}{{\^A}}1 {Ê}{{\^E}}1 {Î}{{\^I}}1 {Ô}{{\^O}}1 {Û}{{\^U}}1
  {œ}{{\oe}}1 {Œ}{{\OE}}1 {æ}{{\ae}}1 {Æ}{{\AE}}1 {ß}{{\ss}}1
  {ű}{{\H{u}}}1 {Ű}{{\H{U}}}1 {ő}{{\H{o}}}1 {Ő}{{\H{O}}}1
  {ç}{{\c c}}1 {Ç}{{\c C}}1 {ø}{{\o}}1 {å}{{\r a}}1 {Å}{{\r A}}1
  {€}{{\euro}}1 {£}{{\pounds}}1 {«}{{\guillemotleft}}1
  {»}{{\guillemotright}}1 {ñ}{{\~n}}1 {Ñ}{{\~N}}1 {¿}{{?`}}1
}

就我而言,我得到了

在此处输入图片描述

參閱LaTeX/源代码清单:编码问题

默认情况下,listings不支持源代码的多字节编码。该extendedchar选项仅适用于 8 位编码,例如latin1

相关内容