\endscname 使用包 matlab-prettifier 时出错

\endscname 使用包 matlab-prettifier 时出错

我正在尝试使用 matlab-prettifier 包准备一份 beamer 文档,但每当我包含使用代码的框架时,我都会遇到错误。我总是收到以下日志:

! Missing \endcsname inserted.
<to be read again> 
               \relax 
l.2 ...atlab-editor, basicstyle=\mlttfamily,\tiny]

The control sequence marked <to be read again> should
not appear between \csname and \endcsname.

! Extra \endcsname.
\KV@split ...csname \KV@prefix \@tempa \endcsname 
                                              \ifx \@tempc \relax \KV@er...
l.2 ...atlab-editor, basicstyle=\mlttfamily,\tiny]

I'm ignoring this, since I wasn't doing a \csname.


! Package keyval Error: \relax \fontsize {6}{7}\selectfont  undefined.

这是一个简单的例子:

\documentclass{beamer}
\usepackage[T1]{fontenc}
\usepackage[framed,numbered]{matlab-prettifier}

\begin{document}

\begin{frame} [fragile]
\frametitle{STEP 2: Parameters extraction - application}
\begin{lstlisting}[style=Matlab-editor, basicstyle=\mlttfamily,\tiny]
par_out.T(1:r, 1:r*p)    = Eaa_FB(1:r, :)/Eaa_BB;
par_out.Q(1:r, 1:r)      = (Eaa(1:r, 1:r) - par_out.T(1:r, 
1:r*p)*Eaa_FB(1:r, :)')/m;
par_out.P0(1:r*p, 1:r*p) = Ps(1:r*p, 1:r*p, 1);

%% Idiosyncratic components
% Get kalman output and initialise estimation
for i=1:n   
ind_start  = r*p+1+(i-1)*q; 
ind_vec    = ind_start:ind_start+q-1;
as_i       = as(ind_vec, :);
Ps_i       = Ps(ind_vec, ind_vec, :);
PPs_lag1_i = PPs_lag1(ind_vec, ind_vec, :);
as_i_t     = as_i(:, 2:end);
as_i_t_1   = as_i(:, 1:end-1);
end 
\end{lstlisting}
\end{frame}    

\end{document}

答案1

您的问题是一个简单的逗号,它不允许出现在那里。只需使用\mlttfamily\tiny

\documentclass{beamer}
\usepackage[framed,numbered]{matlab-prettifier}

\begin{document}

\begin{frame} [fragile]
\frametitle{STEP 2: Parameters extraction - application}
\begin{lstlisting}[style=Matlab-editor, basicstyle=\mlttfamily\tiny]
par_out.T(1:r, 1:r*p)    = Eaa_FB(1:r, :)/Eaa_BB;
par_out.Q(1:r, 1:r)      = (Eaa(1:r, 1:r) - par_out.T(1:r, 
1:r*p)*Eaa_FB(1:r, :)')/m;
par_out.P0(1:r*p, 1:r*p) = Ps(1:r*p, 1:r*p, 1);

%% Idiosyncratic components
% Get kalman output and initialise estimation
for i=1:n   
ind_start  = r*p+1+(i-1)*q; 
ind_vec    = ind_start:ind_start+q-1;
as_i       = as(ind_vec, :);
Ps_i       = Ps(ind_vec, ind_vec, :);
PPs_lag1_i = PPs_lag1(ind_vec, ind_vec, :);
as_i_t     = as_i(:, 2:end);
as_i_t_1   = as_i(:, 1:end-1);
end 
\end{lstlisting}
\end{frame}    

\end{document}

相关内容