latex在使用WinEdt10.2写带有中文注释的matlab公式时,会报错:
使用方式为:
usepackage{listings} % 插入代码要用的包
egin{document}
egin{lstlisting}[language=Matlab]
%读取训练数据并拼接
% batch_label 'training batch 1 of 5'
% data 10000x3072 uint8
% labels 10000x1 uint8
load('cifar-10-matlabcifar-10-batches-matdata_batch_1.mat');
train_data = data;
load('cifar-10-matlabcifar-10-batches-matdata_batch_2.mat');
train_data = [train_data;data];
load('cifar-10-matlabcifar-10-batches-matdata_batch_3.mat');
train_data = [train_data;data];
% load('cifar-10-matlabcifar-10-batches-matdata_batch_4.mat');
% train_data = [train_data;data];
% load('cifar-10-matlabcifar-10-batches-matdata_batch_5.mat');
% train_data = [train_data;data];
end{lstlisting}
end{document}
最后发现原来是编译使用的是快捷键F9,也就是WinEdt的编译选项,正确应使用XeLaTex选项编译,如下: