I want to produce MATLAB prettified code with MATLAB code highlighted with tikz
background. The environment itself works. Using .\
causes error. alsoletter={.\\}
in \lstdefinestyle
does not seem to work
\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}
\newcommand{\matlabline}[1]{#1}
will fail. You can not use verbatim like material as argument. The code then can no longer adapt the catcodes.tcblisting
environment from the tcolorbox package.