列出包错误

列出包错误

我使用 listing 包在论文的几个章节中插入代码片段。我使用以下样式插入代码片段:

   \lstset{emph={sensors, string}, emphstyle={\color{blue}\bfseries\emph}, 
caption={Code snippet of the building automation domain.}, escapechar=\#,  
label=vocabDSL}
    \lstinputlisting{code-snippet/extract-vocabsec.txt} 

我收到以下错误。我的编译显示
此代码位置有错误\lstinputlisting{code-snippet/extract-vocabsec.txt}

Pdflatex> Argument of \lst@for has an extra }
pdflatex> <inserted text>
pdflatex>   \par
pdflatex> l.140 ...isting{code-snippet/extract-vocabsec.txt}
pdflatex>
pdflatex> Runaway argument?
pdflatex> ! Paragraph ended before \lst@for was complete
pdflatex> <to be read again>
pdflatex>   \par
pdflatex> l.140 ...isting{code-snippet/extract-vocabsec.txt}
pdflatex> 

作为参考,我添加了我的主要编译文档的以下标题。

\documentclass[twoside,12pt]{Classes/aesm_edspia}

\usepackage{listings}
\usepackage{xcolor}

\definecolor{name}{rgb}{0.5,0.5,0.5}
\definecolor{javared}{rgb}{0.6,0,0} % for strings
\definecolor{javagreen}{rgb}{0.25,0.5,0.35} % comments
\definecolor{javapurple}{rgb}{0.5,0,0.35} % keywords
\definecolor{javadocblue}{rgb}{0.25,0.35,0.75} % javadoc

\lstset{ %
%language=Java,                 % choose the language of the code
basicstyle=\ttfamily,     % the size of the fonts that are used for the code
keywordstyle=\color{javapurple}\bfseries,
stringstyle=\color{javared},
commentstyle=\color{javagreen},
morecomment=[s][\color{javadocblue}]{/**}{*/},
numbers=left,                   % where to put the line-numbers
numberstyle=\tiny,              % the size of the fonts that are used for the line-numbers
stepnumber=1,                   % the step between two line-numbers. If it is 1 each line will be numbered
numbersep=5pt,                  % how far the line-numbers are from the code
backgroundcolor=\color{white},  % choose the background color. You must add \usepackage{color}
showspaces=false,               % show spaces adding particular underscores
showstringspaces=false,         % underline spaces within strings
showtabs=false,                 % show tabs within strings adding particular underscores
tabsize=2,                      % sets default tabsize to 2 spaces
captionpos=b,                   % sets the caption-position to bottom
breaklines=true,                % sets automatic line breaking
breakatwhitespace=false,        % sets if automatic breaks should only happen at whitespace
escapeinside={\%*}{*)}          % if you want to add a comment within your code 
} 

\begin{document}

\end{document}

extract-vocabsec.txt 文件包含以下代码

regions:  #\label{vocab:regions-start}#
    Building: integer;
    Floor: integer;
    Room: integer;  #\label{vocab:regions-end}#
structs:                  #\label{vocab:structs-start}#
    BadgeDetectedStruct    #\label{vocab:badgedetectedstructs-start}#
        badgeID: string;
        timeStamp: long;   #\label{vocab:badgedetectedstructs-end}#
    TempStruct            #\label{vocab:tempstruct-start}#
        tempValue: double;
        unitOfMeasurement: string;  #\label{vocab:structs-end}#
resources:   
    sensors:                        #\label{vocab:sensors-start}#
        BadgeReader                 #\label{vocab:badgereader-start}# 
            generate badgeDetected: BadgeDetectedStruct;  #\label{vocab:badgereader-end}# 
        TemperatureSensor               #\label{vocab:tempsensor-end}#
            generate tempMeasurement: TempStruct;  #\label{vocab:sensors-end}#
    actuators:                   #\label{vocab:actuators-start}#
        Heater                 #\label{vocab:heater}#
            action Off();      #\label{vocab:action-end}#
            action SetTemp(setTemp: TempStruct);   #\label{vocab:actuators-end}#
    storages:       #\label{vocab:storages-start}#
        ProfileDB   #\label{vocab:profile-start}#
            generate  profile: TempStruct accessed-by badgeID: string;  #\label{vocab:storages-end}#
    userinterfaces:   #\label{vocab:ui-start}#
        EndUserGUI   #\label{vocab:endusergui-start}#
            command Off();  #\label{vocab:command-off}#
            action DisplayData(displayTemp: TempStruct);    #\label{vocab:displaydata}#     
            request profile(badgeID);    #\label{vocab:profile-ui}# 

答案1

注释掉 aesm_edspia.cls 中的第 376 行

%\def\大写{}

假设文档类别如下http://aesm.asso.univ-poitiers.fr/files/Modele_Latex.zip

相关内容