使用 xelatex 时,`lstlisting` 与 `ucharclasses`(等宽代码和 unicode 表情符号)混淆

使用 xelatex 时,`lstlisting` 与 `ucharclasses`(等宽代码和 unicode 表情符号)混淆

我需要在处理代码和 Unicode 的文本中使用 Unicode 表情符号。当我包含ucharclasses和正确的咒语时,我可以获得 Unicode 表情符号,但任何等宽文本似乎都会恢复为默认文本(请注意“brew install python3”和代码部分)

\usepackage{fontspec}
\setmonofont[Scale=0.9]{Source Code Pro}
\usepackage[Latin,Greek,Emoticons]{ucharclasses}

\newfontfamily\mydef{DejaVu Sans}
\setDefaultTransitions{\mydef}{}
\newfontfamily\mynormal{Palatino}
\setTransitionsForLatin{\mynormal}{}

\usepackage{listings}
 \lstset{ %
    basicstyle=\ttfamily\footnotesize,        % the size of the fonts that are used for the code
    aboveskip=5pt,
    belowskip=5pt,
  }

\begin{document}

The standard
consists of various documents or charts that map \emph{code points} (hexadecimal
numbers such as \texttt{0048} or \texttt{1F600}) to glyphs (such as \texttt{H} or 

答案1

设置与特定块或一类块之间的转换更加安全:

\documentclass{article}
\usepackage{fontspec}
\usepackage[Latin,Greek,Emoticons]{ucharclasses}
\usepackage{listings}

\setmainfont{Palatino}
\setmonofont[Scale=0.9]{Source Code Pro}

\newfontfamily\mydef{DejaVu Sans}

\setTransitionsFor{Emoticons}{\begingroup\mydef}{\endgroup}

 \lstset{
    basicstyle=\ttfamily\footnotesize,
    aboveskip=5pt,
    belowskip=5pt,
  }

\begin{document}

The standard
consists of various documents or charts that map \emph{code points} (hexadecimal
numbers such as \texttt{0048} or \texttt{1F600}) to glyphs (such as \texttt{H} or 

相关内容