在 tikzpicture 中使用 .\ 会导致问题崩溃

在 tikzpicture 中使用 .\ 会导致问题崩溃

我想生成 MATLAB 美化代码,其中 MATLAB 代码以tikz背景突出显示。环境本身可以工作。使用.\会导致错误。alsoletter={.\\}似乎\lstdefinestyle不起作用

\documentclass[aspectratio=169, xcolor={x11names}, t, handout]{beamer}

\usepackage{calc}

\usetheme{Dresden}
\usefonttheme{professionalfonts}
\renewcommand{\sfdefault}{ppl}

\usepackage[T1]{fontenc}
\renewcommand{\encodingdefault}{T1}

\usepackage{tikz}
\usetikzlibrary{backgrounds}

\usepackage{bigstrut}

% Inline MATLAB
% BEGIN_FOLD

\newlength{\widthMinimum}
\newcommand{\matlabline}[1]
{%
    \setlength{\widthMinimum}{\minof{\widthof{#1}}{\linewidth}}%
    \begin{tikzpicture}[baseline]
        
        \node[text width=\widthMinimum, align=flush left, inner xsep=0pt, inner ysep=1pt, outer xsep=0pt, outer ysep=0pt, anchor=base] (basmah) {\bigstrut#1};
        
        \begin{pgfonlayer}{background}
            
            \fill[Ivory1, opacity=1] (basmah.south west) rectangle (basmah.north east);
            
        \end{pgfonlayer}
        
    \end{tikzpicture}%
}

% END_FOLD

\usepackage{listings}

% ========== MATLAB codes packages =========
% BEGIN_FOLD

\usepackage[]{matlab-prettifier}
% BEGIN_FOLD

% Inline code
% BEGIN_FOLD

\lstdefinestyle{matlab-inline}{
    style=Matlab-editor,
    basicstyle=\linespread{0.8}\mlttfamily\color{DodgerBlue3},
    alsoletter={.\\},
    literate=
    *{.\\}{\textcolor{IndianRed1}{.\textbackslash{}}}{1}, % .\
}

\lstset{style=matlab-inline}

% END_FOLD

% END_FOLD

% END_FOLD

\begin{document}

\begin{frame}[fragile, environment=frame, allowframebreaks=0.99]
    
%   \matlabline{\lstinline[style=matlab-inline]|.\|}
    
    \lstinline[style=matlab-inline]|.\|
    
\end{frame}

\end{document}

相关内容